Skip to content

Instantly share code, notes, and snippets.

@mlangenberg
Created November 11, 2011 11:06
Show Gist options
  • Save mlangenberg/1357752 to your computer and use it in GitHub Desktop.
Save mlangenberg/1357752 to your computer and use it in GitHub Desktop.
def test_find_or_initialize_updates_collection_size_only_once
number_of_clients = companies(:first_firm).clients_of_firm.size
client = companies(:first_firm).clients_of_firm.find_or_initialize_by_name("name" => "Another Client")
client.save
assert_equal number_of_clients + 1, companies(:first_firm).clients_of_firm.size
end
@mlangenberg
Copy link
Author

1) Failure:
test_find_or_initialize_updates_collection_size_only_once(HasManyAssociationsTest)
    [test/cases/associations/has_many_associations_test.rb:734:in `test_find_or_initialize_updates_collection_size_only_once'
     /Users/mlangenberg/dev/rails/activesupport/lib/active_support/testing/setup_and_teardown.rb:67:in `__send__'
     /Users/mlangenberg/dev/rails/activesupport/lib/active_support/testing/setup_and_teardown.rb:67:in `run'
     /Users/mlangenberg/dev/rails/activesupport/lib/active_support/callbacks.rb:403:in `_run_setup_callbacks'
     /Users/mlangenberg/dev/rails/activesupport/lib/active_support/callbacks.rb:81:in `send'
     /Users/mlangenberg/dev/rails/activesupport/lib/active_support/callbacks.rb:81:in `run_callbacks'
     /Users/mlangenberg/dev/rails/activesupport/lib/active_support/testing/setup_and_teardown.rb:65:in `run']:
<2> expected but was
<3>.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment