File tree Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Expand file tree Collapse file tree 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) {
452452 /**
453453 * @see AV.Object#fetch
454454 */
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+ }
456464 return AV . Object . prototype . fetch . call ( this , fetchOptions , { } )
457465 . then ( function ( model ) {
458466 return model . _handleSaveResult ( false ) . then ( function ( ) {
Original file line number Diff line number Diff line change @@ -81,6 +81,25 @@ describe("User", function() {
8181 } ) ;
8282 } ) ;
8383
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+
84103 describe ( "User update" , function ( ) {
85104 it ( "shoud update name" , function ( done ) {
86105
You can’t perform that action at this time.
0 commit comments