From 3a3e7efee9443fad159dc88a670ad28f12b98438 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Wed, 28 Nov 2007 20:13:17 +0000 Subject: attr_protected and _accessible use sets of strings instead of arrays of symbols internally. Closes #10300. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8231 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activerecord/test/base_test.rb | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'activerecord/test') diff --git a/activerecord/test/base_test.rb b/activerecord/test/base_test.rb index 6fac80b2c4..3c1cac0d49 100755 --- a/activerecord/test/base_test.rb +++ b/activerecord/test/base_test.rb @@ -40,6 +40,11 @@ class LooseDescendant < LoosePerson attr_protected :phone_number end +class LooseDescendantSecond< LoosePerson + attr_protected :phone_number + attr_protected :name +end + class TightPerson < ActiveRecord::Base self.table_name = 'people' attr_accessible :name, :address @@ -843,16 +848,19 @@ class BasicsTest < Test::Unit::TestCase def test_mass_assignment_protection_inheritance assert_nil LoosePerson.accessible_attributes - assert_equal [ :credit_rating, :administrator ], LoosePerson.protected_attributes + assert_equal Set.new([ 'credit_rating', 'administrator' ]), LoosePerson.protected_attributes assert_nil LooseDescendant.accessible_attributes - assert_equal [ :credit_rating, :administrator, :phone_number ], LooseDescendant.protected_attributes + assert_equal Set.new([ 'credit_rating', 'administrator', 'phone_number' ]), LooseDescendant.protected_attributes + + assert_nil LooseDescendantSecond.accessible_attributes + assert_equal Set.new([ 'credit_rating', 'administrator', 'phone_number', 'name' ]), LooseDescendantSecond.protected_attributes, 'Running attr_protected twice in one class should merge the protections' assert_nil TightPerson.protected_attributes - assert_equal [ :name, :address ], TightPerson.accessible_attributes + assert_equal Set.new([ 'name', 'address' ]), TightPerson.accessible_attributes assert_nil TightDescendant.protected_attributes - assert_equal [ :name, :address, :phone_number ], TightDescendant.accessible_attributes + assert_equal Set.new([ 'name', 'address', 'phone_number' ]), TightDescendant.accessible_attributes end def test_readonly_attributes -- cgit v1.2.3