diff options
author | José Valim <jose.valim@gmail.com> | 2011-08-01 04:50:06 -0700 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2011-08-01 04:50:06 -0700 |
commit | 6b3af028acdd8c97b7b6088117a042ddfd7f3038 (patch) | |
tree | d70bff398e2702b7d8cea400f9b2d56be3dd28a1 /activemodel/test/cases | |
parent | 860202e8b2e3579402d48d7e56fa738a9529a340 (diff) | |
parent | b93a918337e99c3fe3ad059f093b1ee56b9e6a7d (diff) | |
download | rails-6b3af028acdd8c97b7b6088117a042ddfd7f3038.tar.gz rails-6b3af028acdd8c97b7b6088117a042ddfd7f3038.tar.bz2 rails-6b3af028acdd8c97b7b6088117a042ddfd7f3038.zip |
Merge pull request #2385 from bogdan/test_default_sanitizer2
MassAssignmentProtection: consider 'id' insensetive in StrictSanitizer
Diffstat (limited to 'activemodel/test/cases')
-rw-r--r-- | activemodel/test/cases/mass_assignment_security/sanitizer_test.rb | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/activemodel/test/cases/mass_assignment_security/sanitizer_test.rb b/activemodel/test/cases/mass_assignment_security/sanitizer_test.rb index 62a6ec9c9b..676937b5e1 100644 --- a/activemodel/test/cases/mass_assignment_security/sanitizer_test.rb +++ b/activemodel/test/cases/mass_assignment_security/sanitizer_test.rb @@ -7,7 +7,7 @@ class SanitizerTest < ActiveModel::TestCase class Authorizer < ActiveModel::MassAssignmentSecurity::PermissionSet def deny?(key) - key.in?(['admin']) + ['admin', 'id'].include?(key) end end @@ -40,4 +40,12 @@ class SanitizerTest < ActiveModel::TestCase end end + test "mass assignment insensitive attributes" do + original_attributes = {'id' => 1, 'first_name' => 'allowed'} + + assert_nothing_raised do + @strict_sanitizer.sanitize(original_attributes, @authorizer) + end + end + end |