File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -630,6 +630,22 @@ describe('Parse User', () => {
630
630
expect ( user . get ( 'foo' ) ) . toBe ( 'bar' ) ;
631
631
} ) ;
632
632
633
+ it ( 'can get current with subclass' , async ( ) => {
634
+ Parse . User . enableUnsafeCurrentUser ( ) ;
635
+
636
+ const customUser = new CustomUser ( { foo : 'bar' } ) ;
637
+ customUser . setUsername ( 'username' ) ;
638
+ customUser . setPassword ( 'password' ) ;
639
+
640
+ await customUser . signUp ( ) ;
641
+ Parse . User . _clearCache ( ) ;
642
+
643
+ const user = CustomUser . current ( ) ;
644
+ expect ( user instanceof CustomUser ) . toBe ( true ) ;
645
+ expect ( user . doSomething ( ) ) . toBe ( 5 ) ;
646
+ expect ( user . get ( 'foo' ) ) . toBe ( 'bar' ) ;
647
+ } ) ;
648
+
633
649
it ( 'can logIn user with subclass' , async ( ) => {
634
650
Parse . User . enableUnsafeCurrentUser ( ) ;
635
651
Original file line number Diff line number Diff line change @@ -869,7 +869,7 @@ const DefaultController = {
869
869
updateUserOnDisk ( user ) {
870
870
const path = Storage . generatePath ( CURRENT_USER_KEY ) ;
871
871
const json = user . toJSON ( ) ;
872
- json . className = ' _User';
872
+ json . className = user . constructor . name === 'ParseUser' ? ' _User' : user . constructor . name ;
873
873
return Storage . setItemAsync (
874
874
path , JSON . stringify ( json )
875
875
) . then ( ( ) => {
You can’t perform that action at this time.
0 commit comments