aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/associations
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2012-03-08 00:13:08 -0800
committerJon Leighton <j@jonathanleighton.com>2012-03-08 00:13:08 -0800
commit104eebb4ccc7e9594095c474888c7bfd8e071394 (patch)
treea39e2fa9b37f8a84fbc4107c6571a37b458ea887 /activerecord/test/cases/associations
parent447ecb08ca1bab594198282237c4e9a027f7a3f4 (diff)
parentc9c7ee7710a637e1dd3c1d4be3960fe22f8ee3d1 (diff)
downloadrails-104eebb4ccc7e9594095c474888c7bfd8e071394.tar.gz
rails-104eebb4ccc7e9594095c474888c7bfd8e071394.tar.bz2
rails-104eebb4ccc7e9594095c474888c7bfd8e071394.zip
Merge pull request #5289 from rafaelfranca/fix-through-associations
Fix has_many through associations when mass_assignment_sanitizer is strict
Diffstat (limited to 'activerecord/test/cases/associations')
-rw-r--r--activerecord/test/cases/associations/has_many_through_associations_test.rb24
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 12cae934b6..e9b930204f 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