Skip to content

Commit 818fe49

Browse files
committed
Merge pull request parse-community#774 from ParsePlatform/fosco.install-fix
Fix an installation deduplication bug
2 parents bb80e5d + bfafcd4 commit 818fe49

File tree

3 files changed

+33
-6
lines changed

3 files changed

+33
-6
lines changed

spec/ParseAPI.spec.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -853,4 +853,32 @@ describe('miscellaneous', function() {
853853
});
854854
});
855855

856+
it('dedupes an installation properly and returns updatedAt', (done) => {
857+
let headers = {
858+
'Content-Type': 'application/json',
859+
'X-Parse-Application-Id': 'test',
860+
'X-Parse-REST-API-Key': 'rest'
861+
};
862+
let data = {
863+
'installationId': 'lkjsahdfkjhsdfkjhsdfkjhsdf',
864+
'deviceType': 'embedded'
865+
};
866+
let requestOptions = {
867+
headers: headers,
868+
url: 'http://localhost:8378/1/installations',
869+
body: JSON.stringify(data)
870+
};
871+
request.post(requestOptions, (error, response, body) => {
872+
expect(error).toBe(null);
873+
let b = JSON.parse(body);
874+
expect(typeof b.objectId).toEqual('string');
875+
request.post(requestOptions, (error, response, body) => {
876+
expect(error).toBe(null);
877+
let b = JSON.parse(body);
878+
expect(typeof b.updatedAt).toEqual('string');
879+
done();
880+
});
881+
});
882+
});
883+
856884
});

src/RestWrite.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -782,8 +782,10 @@ RestWrite.prototype.runDatabaseOperation = function() {
782782
// Run an update
783783
return this.config.database.update(
784784
this.className, this.query, this.data, this.runOptions).then((resp) => {
785-
this.response = resp;
786-
this.response.updatedAt = this.updatedAt;
785+
resp.updatedAt = this.updatedAt;
786+
this.response = {
787+
response: resp
788+
};
787789
});
788790
} else {
789791
// Set the default ACL for the new _User

src/Routers/ClassesRouter.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,7 @@ export class ClassesRouter extends PromiseRouter {
8585
}
8686

8787
handleUpdate(req) {
88-
return rest.update(req.config, req.auth, req.params.className, req.params.objectId, req.body)
89-
.then((response) => {
90-
return {response: response};
91-
});
88+
return rest.update(req.config, req.auth, req.params.className, req.params.objectId, req.body);
9289
}
9390

9491
handleDelete(req) {

0 commit comments

Comments
 (0)