#NEWLINE# def test_belongs_to_morph_many_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# posts = OratorTestPost . with_ ( 'user' , 'photos' ) . get ( ) #NEWLINE# self . assertIsInstance ( posts [ 0 ] . user , OratorTestUser ) #NEWLINE# self . assertEqual ( user . id , posts [ 0 ] . user ( ) . first ( ) . id ) #NEWLINE# self . assertIsInstance ( posts [ 0 ] . photos , Collection ) #NEWLINE# self . assertEqual ( posts [ 0 ] . photos ( ) . where ( 'name' , 'Hero 2' ) . first ( ) . name , 'Hero 2' )