diff options
Diffstat (limited to 'activerecord/test')
-rwxr-xr-x | activerecord/test/base_test.rb | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/activerecord/test/base_test.rb b/activerecord/test/base_test.rb index fa4364e019..1792cf799c 100755 --- a/activerecord/test/base_test.rb +++ b/activerecord/test/base_test.rb @@ -16,11 +16,15 @@ class LoosePerson < ActiveRecord::Base attr_protected :credit_rating, :administrator end +class LooseDescendant < LoosePerson + attr_protected :phone_number +end + class TightPerson < ActiveRecord::Base attr_accessible :name, :address end -class TightDescendent < TightPerson +class TightDescendant < TightPerson attr_accessible :phone_number end @@ -463,8 +467,17 @@ class BasicsTest < Test::Unit::TestCase end def test_mass_assignment_protection_inheritance + assert_nil LoosePerson.accessible_attributes assert_equal [ :credit_rating, :administrator ], LoosePerson.protected_attributes + + assert_nil LooseDescendant.accessible_attributes + assert_equal [ :credit_rating, :administrator, :phone_number ], LooseDescendant.protected_attributes + assert_nil TightPerson.protected_attributes + assert_equal [ :name, :address ], TightPerson.accessible_attributes + + assert_nil TightDescendant.protected_attributes + assert_equal [ :name, :address, :phone_number ], TightDescendant.accessible_attributes end def test_multiparameter_attributes_on_date |