diff options
Diffstat (limited to 'activerecord/test')
-rwxr-xr-x | activerecord/test/base_test.rb | 16 |
1 files changed, 12 insertions, 4 deletions
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 |