File tree 2 files changed +28
-1
lines changed
2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -452,7 +452,15 @@ module.exports = function(AV) {
452
452
/**
453
453
* @see AV.Object#fetch
454
454
*/
455
- fetch : function ( fetchOptions , options ) {
455
+ fetch : function ( ) {
456
+ var options = null ;
457
+ var fetchOptions = { } ;
458
+ if ( arguments . length === 1 ) {
459
+ options = arguments [ 0 ] ;
460
+ } else if ( arguments . length === 2 ) {
461
+ fetchOptions = arguments [ 0 ] ;
462
+ options = arguments [ 1 ] ;
463
+ }
456
464
return AV . Object . prototype . fetch . call ( this , fetchOptions , { } )
457
465
. then ( function ( model ) {
458
466
return model . _handleSaveResult ( false ) . then ( function ( ) {
Original file line number Diff line number Diff line change @@ -81,6 +81,25 @@ describe("User", function() {
81
81
} ) ;
82
82
} ) ;
83
83
84
+ describe ( "fetch User" , function ( ) {
85
+ it ( "should resolve promise" , function ( done ) {
86
+ var currentUser = AV . User . current ( ) ;
87
+ currentUser . fetch ( ) . then ( function ( user ) {
88
+ expect ( user ) . to . be . ok ( ) ;
89
+ done ( ) ;
90
+ } ) ;
91
+ } ) ;
92
+ it ( "should run callback" , function ( done ) {
93
+ var currentUser = AV . User . current ( ) ;
94
+ currentUser . fetch ( {
95
+ success : function ( user ) {
96
+ expect ( user ) . to . be . ok ( ) ;
97
+ done ( ) ;
98
+ }
99
+ } )
100
+ } ) ; ;
101
+ } ) ;
102
+
84
103
describe ( "User update" , function ( ) {
85
104
it ( "shoud update name" , function ( done ) {
86
105
You can’t perform that action at this time.
0 commit comments