Merge pull request #637 from ParsePlatform/nlutsenko.files.expand
Fix missing file URL for short-circuited _User in RestWrite.
This commit is contained in:
@@ -82,8 +82,6 @@ describe('Parse.User testing', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("user login with files", (done) => {
|
it("user login with files", (done) => {
|
||||||
"use strict";
|
|
||||||
|
|
||||||
let file = new Parse.File("yolo.txt", [1,2,3], "text/plain");
|
let file = new Parse.File("yolo.txt", [1,2,3], "text/plain");
|
||||||
file.save().then((file) => {
|
file.save().then((file) => {
|
||||||
return Parse.User.signUp("asdf", "zxcv", { "file" : file });
|
return Parse.User.signUp("asdf", "zxcv", { "file" : file });
|
||||||
@@ -930,6 +928,29 @@ describe('Parse.User testing', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('log in with provider with files', done => {
|
||||||
|
let provider = getMockFacebookProvider();
|
||||||
|
Parse.User._registerAuthenticationProvider(provider);
|
||||||
|
let file = new Parse.File("yolo.txt", [1, 2, 3], "text/plain");
|
||||||
|
file.save().then(file => {
|
||||||
|
let user = new Parse.User();
|
||||||
|
user.set('file', file);
|
||||||
|
return user._linkWith('facebook', {});
|
||||||
|
}).then(user => {
|
||||||
|
expect(user._isLinked("facebook")).toBeTruthy();
|
||||||
|
return Parse.User._logInWith('facebook', {});
|
||||||
|
}).then(user => {
|
||||||
|
let fileAgain = user.get('file');
|
||||||
|
expect(fileAgain.name()).toMatch(/yolo.txt$/);
|
||||||
|
expect(fileAgain.url()).toMatch(/yolo.txt$/);
|
||||||
|
}).then(() => {
|
||||||
|
done();
|
||||||
|
}, error => {
|
||||||
|
fail(error);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it("log in with provider twice", (done) => {
|
it("log in with provider twice", (done) => {
|
||||||
var provider = getMockFacebookProvider();
|
var provider = getMockFacebookProvider();
|
||||||
Parse.User._registerAuthenticationProvider(provider);
|
Parse.User._registerAuthenticationProvider(provider);
|
||||||
|
|||||||
@@ -73,6 +73,8 @@ RestWrite.prototype.execute = function() {
|
|||||||
return this.validateAuthData();
|
return this.validateAuthData();
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
return this.transformUser();
|
return this.transformUser();
|
||||||
|
}).then(() => {
|
||||||
|
return this.expandFilesForExistingObjects();
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
return this.runDatabaseOperation();
|
return this.runDatabaseOperation();
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
@@ -704,6 +706,16 @@ RestWrite.prototype.handleInstallation = function() {
|
|||||||
return promise;
|
return promise;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// If we short-circuted the object response - then we need to make sure we expand all the files,
|
||||||
|
// since this might not have a query, meaning it won't return the full result back.
|
||||||
|
// TODO: (nlutsenko) This should die when we move to per-class based controllers on _Session/_User
|
||||||
|
RestWrite.prototype.expandFilesForExistingObjects = function() {
|
||||||
|
// Check whether we have a short-circuited response - only then run expansion.
|
||||||
|
if (this.response && this.response.response) {
|
||||||
|
this.config.filesController.expandFilesInObject(this.config, this.response.response);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
RestWrite.prototype.runDatabaseOperation = function() {
|
RestWrite.prototype.runDatabaseOperation = function() {
|
||||||
if (this.response) {
|
if (this.response) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user