diff --git a/activerecord/test/cases/associations/has_many_associations_test.rb b/activerecord/test/cases/associations/has_many_associations_test.rb index 59f7a03..05ed7a4 100644 --- a/activerecord/test/cases/associations/has_many_associations_test.rb +++ b/activerecord/test/cases/associations/has_many_associations_test.rb @@ -65,6 +65,21 @@ class HasManyAssociationsTest < ActiveRecord::TestCase assert_equal person, person.readers.first.person end + def test_find_or_create_by_with_additional_parameters + post = Post.create! :title => 'test_find_or_create_by_with_additional_parameters', :body => 'this is the body' + comment = post.comments.create! :body => 'test comment body', :type => 'test' + + assert_equal comment, post.comments.find_or_create_by_body('test comment body') + + # 2.3.8: success + # 2.3.9: + # ArgumentError: Unknown key(s): type, body + # ./test/cases/../../../activesupport/lib/active_support/core_ext/hash/keys.rb:47:in `assert_valid_keys' + post.comments.find_or_create_by_body(:body => 'other test comment body', :type => 'test') + assert_equal 2, post.comments.count + assert_equal 2, post.comments.length + end + def test_find_or_create person = Person.create! :first_name => 'tenderlove' post = Post.find :first