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-05 16:58:19 -0300 |
commit | e9bf0e3157fcc15f3520559a34bbfdd894dd8112 (patch) | |
tree | 28fd3bc8841a69e0e78d3e3abbe11484fb7a79f5 /activerecord/test/cases/associations | |
parent | c97a1666910aa82b9c4348402cc8f52492b58692 (diff) | |
download | rails-e9bf0e3157fcc15f3520559a34bbfdd894dd8112.tar.gz rails-e9bf0e3157fcc15f3520559a34bbfdd894dd8112.tar.bz2 rails-e9bf0e3157fcc15f3520559a34bbfdd894dd8112.zip |
Add test case to has_many through association 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.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 9cc09194dc..8e64fd7c70 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 |