diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-03-05 00:45:17 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-03-08 23:29:16 -0300 |
commit | 7cd4063162e47e28715cafc021241f14cf8a278d (patch) | |
tree | 75a02c5a9abb66bbcb1e2c83627d2d7a8777ee49 /activerecord/test/cases/associations | |
parent | 94b2c8c32d00e101b306875b86abf11b28b55699 (diff) | |
download | rails-7cd4063162e47e28715cafc021241f14cf8a278d.tar.gz rails-7cd4063162e47e28715cafc021241f14cf8a278d.tar.bz2 rails-7cd4063162e47e28715cafc021241f14cf8a278d.zip |
Add test case to has_many through association when mass_assignment_sanitizer is
:strict
Conflicts:
activerecord/test/models/person.rb
Diffstat (limited to 'activerecord/test/cases/associations')
-rw-r--r-- | activerecord/test/cases/associations/has_many_through_associations_test.rb | 25 |
1 files changed, 21 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..beefbffe8a 100644 --- a/activerecord/test/cases/associations/has_many_through_associations_test.rb +++ b/activerecord/test/cases/associations/has_many_through_associations_test.rb @@ -4,6 +4,7 @@ require 'models/person' require 'models/reference' require 'models/job' require 'models/reader' +require 'models/secure_reader' require 'models/comment' require 'models/tag' require 'models/tagging' @@ -44,17 +45,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 + ActiveRecord::Base.mass_assignment_sanitizer = :strict + + SecureReader.new + + post = posts(:thinking) + person = people(:david) + + assert_queries(1) do + post.secure_people << person + end + ensure + ActiveRecord::Base.mass_assignment_sanitizer = :logger end def test_associate_existing_record_twice_should_add_to_target_twice |