From 7cd4063162e47e28715cafc021241f14cf8a278d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Mon, 5 Mar 2012 00:45:17 -0300 Subject: Add test case to has_many through association when mass_assignment_sanitizer is :strict Conflicts: activerecord/test/models/person.rb --- .../has_many_through_associations_test.rb | 25 ++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'activerecord/test/cases/associations') 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 -- cgit v1.2.3