diff options
author | José Valim <jose.valim@gmail.com> | 2012-03-08 23:28:10 -0800 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2012-03-08 23:28:10 -0800 |
commit | 2b9041ba96375467717a79b0d2c5e6ecca038b5e (patch) | |
tree | a618b1a72f5944baeb48b13e0d9314c257c173ed /activerecord/test/cases | |
parent | 98144207789893c480ed42b007f4964070d9f870 (diff) | |
parent | f18c0547b0a7ff97fec78cb1f0c95c2531290a94 (diff) | |
download | rails-2b9041ba96375467717a79b0d2c5e6ecca038b5e.tar.gz rails-2b9041ba96375467717a79b0d2c5e6ecca038b5e.tar.bz2 rails-2b9041ba96375467717a79b0d2c5e6ecca038b5e.zip |
Merge pull request #5347 from rafaelfranca/fix-has_many_association-3-2
[3-2-stable] Fix has many through associations when mass_assignment_sanitizer is :strict
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/associations/has_many_through_associations_test.rb | 24 |
1 files changed, 20 insertions, 4 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 6836a2b4d0..4489c3e638 100644 --- a/activerecord/test/cases/associations/has_many_through_associations_test.rb +++ b/activerecord/test/cases/associations/has_many_through_associations_test.rb @@ -44,17 +44,33 @@ class HasManyThroughAssociationsTest < ActiveRecord::TestCase end def test_associate_existing - posts(:thinking); people(:david) # Warm cache + post = posts(:thinking) + person = people(:david) assert_queries(1) do - posts(:thinking).people << people(:david) + post.people << person end assert_queries(1) do - assert posts(:thinking).people.include?(people(:david)) + assert post.people.include?(person) end - assert posts(:thinking).reload.people(true).include?(people(:david)) + assert post.reload.people(true).include?(person) + end + + def test_associate_existing_with_strict_mass_assignment_sanitizer + SecureReader.mass_assignment_sanitizer = :strict + + SecureReader.new + + post = posts(:thinking) + person = people(:david) + + assert_queries(1) do + post.secure_people << person + end + ensure + SecureReader.mass_assignment_sanitizer = :logger end def test_associate_existing_record_twice_should_add_to_target_twice |