From 961957d5709b6e18a0c6adf0b4783297cc21140a Mon Sep 17 00:00:00 2001 From: Francesco Rodriguez Date: Sat, 14 Jul 2012 16:26:05 -0500 Subject: Fix ActiveModel tests that depend on run order --- activemodel/test/cases/mass_assignment_security_test.rb | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'activemodel') diff --git a/activemodel/test/cases/mass_assignment_security_test.rb b/activemodel/test/cases/mass_assignment_security_test.rb index 0c6352cd71..45757615f5 100644 --- a/activemodel/test/cases/mass_assignment_security_test.rb +++ b/activemodel/test/cases/mass_assignment_security_test.rb @@ -11,7 +11,6 @@ class CustomSanitizer < ActiveModel::MassAssignmentSecurity::Sanitizer end class MassAssignmentSecurityTest < ActiveModel::TestCase - def test_attribute_protection user = User.new expected = { "name" => "John Smith", "email" => "john@smith.com" } @@ -96,7 +95,6 @@ class MassAssignmentSecurityTest < ActiveModel::TestCase assert_blank TightDescendant.protected_attributes(:admin) - TightDescendant.attributes_protected_by_default assert_equal Set.new(['name', 'address', 'admin', 'super_powers']), TightDescendant.accessible_attributes(:admin) - end def test_mass_assignment_multiparameter_protector @@ -107,14 +105,14 @@ class MassAssignmentSecurityTest < ActiveModel::TestCase end def test_custom_sanitizer + old_sanitizer = User._mass_assignment_sanitizer + user = User.new User.mass_assignment_sanitizer = CustomSanitizer.new assert_raise StandardError do user.sanitize_for_mass_assignment("admin" => true) end ensure - User.mass_assignment_sanitizer = nil - + User.mass_assignment_sanitizer = old_sanitizer end - -end +end \ No newline at end of file -- cgit v1.2.3