Skip to content

Commit

Permalink
Merge pull request #666 from ParsePlatform/nlutsenko.files.url
Browse files Browse the repository at this point in the history
Remove 'url' as a required field on Files when they are stored on object.
  • Loading branch information
nlutsenko committed Feb 26, 2016
2 parents 1945313 + a96cb6b commit 54e46d4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
19 changes: 18 additions & 1 deletion spec/ParseFile.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// This is a port of the test suite:
// hungry/js/test/parse_file_test.js

"use strict";

var request = require('request');

var str = "Hello World!";
Expand Down Expand Up @@ -482,7 +484,22 @@ describe('Parse.File testing', () => {
);
done();
});

});

it('supports files in objects without urls', done => {
var file = {
__type: 'File',
name: '123.txt'
};
var obj = new Parse.Object('FileTest');
obj.set('file', file);
obj.save().then(() => {
var query = new Parse.Query('FileTest');
return query.first();
}).then(result => {
let fileAgain = result.get('file');
expect(fileAgain.url()).toMatch(/123.txt$/);
done();
});
});
});
2 changes: 1 addition & 1 deletion src/Schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ function getObjectType(obj) {
if (obj.__type === 'Pointer' && obj.className) {
return '*' + obj.className;
}
if (obj.__type === 'File' && obj.url && obj.name) {
if (obj.__type === 'File' && obj.name) {
return 'file';
}
if (obj.__type === 'Date' && obj.iso) {
Expand Down

0 comments on commit 54e46d4

Please sign in to comment.