File tree 4 files changed +14
-0
lines changed
4 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -619,6 +619,9 @@ module.exports = function(AV) {
619
619
* completes.
620
620
*/
621
621
fetch ( fetchOptions , options ) {
622
+ if ( ! this . id ) {
623
+ throw new Error ( 'Cannot fetch unsaved file' ) ;
624
+ }
622
625
var request = AVRequest (
623
626
'files' ,
624
627
null ,
Original file line number Diff line number Diff line change @@ -946,6 +946,9 @@ module.exports = function(AV) {
946
946
* completes.
947
947
*/
948
948
fetch : function ( fetchOptions = { } , options ) {
949
+ if ( ! this . id ) {
950
+ throw new Error ( 'Cannot fetch unsaved object' ) ;
951
+ }
949
952
var self = this ;
950
953
var request = _request (
951
954
'classes' ,
Original file line number Diff line number Diff line change @@ -188,6 +188,10 @@ describe('File', function() {
188
188
. fetch ( )
189
189
. then ( file => ( this . file = file ) ) ;
190
190
} ) ;
191
+ it ( 'should throws when objectId is empty' , ( ) => {
192
+ const file = new AV . File ( 'filename' , { base64 : 'dGVzdA==' } ) ;
193
+ expect ( file . fetch ) . throwError ( ) ;
194
+ } ) ;
191
195
it ( 'should retrieve all data' , function ( ) {
192
196
var file = this . file ;
193
197
expect ( file ) . to . be . a ( AV . File ) ;
Original file line number Diff line number Diff line change @@ -447,6 +447,10 @@ describe('Objects', function() {
447
447
expect ( score . createdAt ) . to . be . a ( Date ) ;
448
448
expect ( score . id ) . to . be . eql ( gameScore . id ) ;
449
449
} ) ) ;
450
+ it ( 'should throws when objectId is empty' , ( ) => {
451
+ const object = new AV . Object ( 'GameScore' ) ;
452
+ expect ( object . fetch ) . throwError ( ) ;
453
+ } ) ;
450
454
it ( 'fetch should remove deleted keys' , ( ) => {
451
455
const getFakedScore = ( ) =>
452
456
AV . parseJSON (
You can’t perform that action at this time.
0 commit comments