#NEWLINE# def test_detach_remove_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 ( 'where' ) . once ( ) . with_args ( 'taggable_id' , 1 ) . and_return ( query ) #NEWLINE# query . should_receive ( 'where' ) . once ( ) . with_args ( 'taggable_type' , relation . get_parent ( ) . __class__ . __name__ ) . and_return ( query ) #NEWLINE# query . should_receive ( 'where_in' ) . once ( ) . with_args ( 'tag_id' , [ 1 , 2 , 3 ] ) #NEWLINE# query . should_receive ( 'delete' ) . once ( ) . and_return ( True ) #NEWLINE# mock_query_builder = flexmock ( ) #NEWLINE# relation . get_query ( ) . should_receive ( 'get_query' ) . and_return ( mock_query_builder ) #NEWLINE# mock_query_builder . should_receive ( 'new_query' ) . once ( ) . and_return ( query ) #NEWLINE# relation . should_receive ( 'touch_if_touching' ) . once ( ) #NEWLINE# self . assertTrue ( relation . detach ( [ 1 , 2 , 3 ] ) )