#NEWLINE# def test_attach_inserts_pivot_table_record( self ) : #NEWLINE# #INDENT# flexmock ( MorphToMany , touch_if_touching = ( lambda : True ) ) #NEWLINE# relation = self . _get_relation ( ) #NEWLINE# query = flexmock ( ) #NEWLINE# query . should_receive ( 'from_' ) . once ( ) . with_args ( 'taggables' ) . and_return ( query ) #NEWLINE# query . should_receive ( 'insert' ) . once ( ) . with_args ( [ { #NEWLINE# #INDENT# 'taggable_id' : 1 , #NEWLINE# 'taggable_type' : relation . get_parent ( ) . __class__ . __name__ , #NEWLINE# 'tag_id' : 2 , #NEWLINE# 'foo' : 'bar' , #NEWLINE# #UNINDENT# } ] ) . and_return ( True ) #NEWLINE# mock_query_builder = flexmock ( ) #NEWLINE# relation . get_query ( ) . should_receive ( 'get_query' ) . and_return ( self ) #NEWLINE# mock_query_builder . should_receive ( 'new_query' ) . once ( ) . and_return ( query ) #NEWLINE# relation . should_receive ( 'touch_if_touching' ) . once ( ) #NEWLINE# relation . attach ( 2 , { #NEWLINE# #INDENT# 'foo' : 'bar' , #NEWLINE# #UNINDENT# } )