aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/associations/has_many_through_associations_test.rb
diff options
context:
space:
mode:
authorMarcelo Giorgi <marklazz.uy@gmail.com>2010-09-15 12:26:54 -0300
committerSantiago Pastorino <santiago@wyeworks.com>2010-09-28 15:22:50 -0300
commitcdfd013dd7953fc87038c73ecddbaa8cfe29a301 (patch)
treeaec0099a5b67e415c9255c2c63fcb723dd4154dc /activerecord/test/cases/associations/has_many_through_associations_test.rb
parent1ef2b47fb12a94f960b34c4bb1e6ad1f9c900e18 (diff)
downloadrails-cdfd013dd7953fc87038c73ecddbaa8cfe29a301.tar.gz
rails-cdfd013dd7953fc87038c73ecddbaa8cfe29a301.tar.bz2
rails-cdfd013dd7953fc87038c73ecddbaa8cfe29a301.zip
Set attributes properly for model built from association with conditions [#5562 state:resolved]
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
Diffstat (limited to 'activerecord/test/cases/associations/has_many_through_associations_test.rb')
-rw-r--r--activerecord/test/cases/associations/has_many_through_associations_test.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/has_many_through_associations_test.rb b/activerecord/test/cases/associations/has_many_through_associations_test.rb
index 45f8bd64eb..0dac633852 100644
--- a/activerecord/test/cases/associations/has_many_through_associations_test.rb
+++ b/activerecord/test/cases/associations/has_many_through_associations_test.rb
@@ -421,4 +421,18 @@ class HasManyThroughAssociationsTest < ActiveRecord::TestCase
assert_raises(ActiveRecord::RecordNotFound) {company.developer_ids= ids}
end
+ def test_build_a_model_from_hm_through_association_with_where_clause
+ assert_nothing_raised { books(:awdr).subscribers.where(:nick => "marklazz").build }
+ end
+
+ def test_attributes_are_being_set_when_initialized_from_hm_through_association_with_where_clause
+ new_subscriber = books(:awdr).subscribers.where(:nick => "marklazz").build
+ assert_equal new_subscriber.nick, "marklazz"
+ end
+
+ def test_attributes_are_being_set_when_initialized_from_hm_through_association_with_multiple_where_clauses
+ new_subscriber = books(:awdr).subscribers.where(:nick => "marklazz").where(:name => 'Marcelo Giorgi').build
+ assert_equal new_subscriber.nick, "marklazz"
+ assert_equal new_subscriber.name, "Marcelo Giorgi"
+ end
end