#NEWLINE# def test_morph_to_eagerload( self ) : #NEWLINE# #INDENT# user = OratorTestUser . create ( id = 1 , email = 'john@doe.com' ) #NEWLINE# user . photos ( ) . create ( name = 'Avatar 1' ) #NEWLINE# user . photos ( ) . create ( name = 'Avatar 2' ) #NEWLINE# post = user . posts ( ) . create ( name = 'First Post' ) #NEWLINE# post . photos ( ) . create ( name = 'Hero 1' ) #NEWLINE# post . photos ( ) . create ( name = 'Hero 2' ) #NEWLINE# photo = OratorTestPhoto . with_ ( 'imageable' ) . where ( 'name' , 'Hero 2' ) . first ( ) #NEWLINE# self . assertIsInstance ( photo . imageable , OratorTestPost ) #NEWLINE# self . assertEqual ( user . id , photo . imageable . id ) #NEWLINE# self . assertEqual ( post . id , photo . imageable ( ) . where ( 'name' , 'First Post' ) . first ( ) . id )