@@ -1428,6 +1428,53 @@ describe('User', function() {
14281428 } ) ;
14291429 } ) ;
14301430
1431+ it ( 'converts uid value to string' , function ( done ) {
1432+ var idString = '58be263abc88dd483956030a' ;
1433+ var actualVerifyHref ;
1434+
1435+ User . afterRemote ( 'create' , function ( ctx , user , next ) {
1436+ assert ( user , 'afterRemote should include result' ) ;
1437+
1438+ var options = {
1439+ type : 'email' ,
1440+ to : user . email ,
1441+ 1442+ redirect : '/' ,
1443+ protocol : ctx . req . protocol ,
1444+ host : ctx . req . get ( 'host' ) ,
1445+ templateFn : function ( options , cb ) {
1446+ actualVerifyHref = options . verifyHref ;
1447+ cb ( null , 'dummy body' ) ;
1448+ } ,
1449+ } ;
1450+
1451+ // replace the string id with an object
1452+ // TODO: find a better way to do this
1453+ Object . defineProperty ( user , 'pk' , {
1454+ get : function ( ) { return this . __data . pk ; } ,
1455+ set : function ( value ) { this . __data . pk = value ; } ,
1456+ } ) ;
1457+ user . pk = { toString : function ( ) { return idString ; } } ;
1458+
1459+ user . verify ( options , function ( err , result ) {
1460+ expect ( result . uid ) . to . be . an ( 'object' ) ;
1461+ expect ( result . uid . toString ( ) ) . to . equal ( idString ) ;
1462+ var parsed = url . parse ( actualVerifyHref , true ) ;
1463+ expect ( parsed . query . uid , 'uid query field' ) . to . eql ( idString ) ;
1464+ done ( ) ;
1465+ } ) ;
1466+ } ) ;
1467+
1468+ request ( app )
1469+ . post ( '/test-users' )
1470+ . expect ( 'Content-Type' , / j s o n / )
1471+ . expect ( 200 )
1472+ . send ( { email :
'[email protected] ' , password :
'bar' , pk :
idString } ) 1473+ . end ( function ( err , res ) {
1474+ if ( err ) return done ( err ) ;
1475+ } ) ;
1476+ } ) ;
1477+
14311478 it ( 'Verify a user\'s email address with custom token generator' , function ( done ) {
14321479 User . afterRemote ( 'create' , function ( ctx , user , next ) {
14331480 assert ( user , 'afterRemote should include result' ) ;
0 commit comments