#NEWLINE# def test_first_or_new_finds_first_model( self ) : #NEWLINE# #INDENT# relation = self . _get_relation ( ) #NEWLINE# relation . get_query ( ) . should_receive ( 'where' ) . once ( ) . with_args ( { #NEWLINE# #INDENT# 'foo' : 'bar' , #NEWLINE# #UNINDENT# } ) . and_return ( relation . get_query ( ) ) #NEWLINE# model = flexmock ( ) #NEWLINE# model . foo = 'bar' #NEWLINE# relation . get_query ( ) . should_receive ( 'first' ) . once ( ) . with_args ( ) . and_return ( model ) #NEWLINE# model . should_receive ( 'set_attribute' ) . never ( ) #NEWLINE# self . assertEqual ( 'bar' , relation . first_or_new ( foo = 'bar' ) . foo )