diff options
author | Jon Buda <jon.buda@gmail.com> | 2010-07-27 20:04:36 -0500 |
---|---|---|
committer | Santiago Pastorino <santiago@wyeworks.com> | 2010-07-28 00:42:48 -0300 |
commit | 9d109302f139a23d18de605454074777b995e4c4 (patch) | |
tree | 85b5f8ca7ad84610e5e11ee6c3c6e6cc7cc2d4e8 /activerecord/test/cases/associations | |
parent | aa24ea41d00e4a5a1de317a7356aca357d27c3ff (diff) | |
download | rails-9d109302f139a23d18de605454074777b995e4c4.tar.gz rails-9d109302f139a23d18de605454074777b995e4c4.tar.bz2 rails-9d109302f139a23d18de605454074777b995e4c4.zip |
fixed joining of attributes when using find_or_create_by with multiple attributes through an association
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
Diffstat (limited to 'activerecord/test/cases/associations')
-rw-r--r-- | activerecord/test/cases/associations/has_many_associations_test.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/has_many_associations_test.rb b/activerecord/test/cases/associations/has_many_associations_test.rb index 6fe737a817..ac2021c369 100644 --- a/activerecord/test/cases/associations/has_many_associations_test.rb +++ b/activerecord/test/cases/associations/has_many_associations_test.rb @@ -167,6 +167,15 @@ class HasManyAssociationsTest < ActiveRecord::TestCase companies(:first_firm).readonly_clients.find(:all).each { |c| assert c.readonly? } end + def test_dynamic_find_or_create_from_two_attributes_using_an_association + author = authors(:david) + number_of_posts = Post.count + another = author.posts.find_or_create_by_title_and_body("Another Post", "This is the Body") + assert_equal number_of_posts + 1, Post.count + assert_equal another, author.posts.find_or_create_by_title_and_body("Another Post", "This is the Body") + assert !another.new_record? + end + def test_cant_save_has_many_readonly_association authors(:david).readonly_comments.each { |c| assert_raise(ActiveRecord::ReadOnlyRecord) { c.save! } } authors(:david).readonly_comments.each { |c| assert c.readonly? } |