diff options
author | Jon Leighton <j@jonathanleighton.com> | 2012-06-15 16:01:38 +0100 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2012-06-15 19:15:37 +0100 |
commit | a205bf878084d74872fbad45fac030ad2cb74970 (patch) | |
tree | c36b54603a81c71a0e4ec33686e62ee8d55654d2 /activerecord/test/cases | |
parent | e030f26ad3de98205edec9d8b59ecca9508cb57d (diff) | |
download | rails-a205bf878084d74872fbad45fac030ad2cb74970.tar.gz rails-a205bf878084d74872fbad45fac030ad2cb74970.tar.bz2 rails-a205bf878084d74872fbad45fac030ad2cb74970.zip |
Fix config.active_record.whitelist_attributes with AR::Model
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/mass_assignment_security_test.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/activerecord/test/cases/mass_assignment_security_test.rb b/activerecord/test/cases/mass_assignment_security_test.rb index 214546802a..c75a0be98e 100644 --- a/activerecord/test/cases/mass_assignment_security_test.rb +++ b/activerecord/test/cases/mass_assignment_security_test.rb @@ -251,6 +251,33 @@ class MassAssignmentSecurityTest < ActiveRecord::TestCase assert !Task.new.respond_to?("#{method}=") end end + + test "ActiveRecord::Model.whitelist_attributes works for models which include Model" do + begin + prev, ActiveRecord::Model.whitelist_attributes = ActiveRecord::Model.whitelist_attributes, true + + klass = Class.new { include ActiveRecord::Model } + assert_equal ActiveModel::MassAssignmentSecurity::WhiteList, klass.active_authorizers[:default].class + assert_equal [], klass.active_authorizers[:default].to_a + ensure + ActiveRecord::Model.whitelist_attributes = prev + end + end + + test "ActiveRecord::Model.whitelist_attributes works for models which inherit Base" do + begin + prev, ActiveRecord::Model.whitelist_attributes = ActiveRecord::Model.whitelist_attributes, true + + klass = Class.new(ActiveRecord::Base) + assert_equal ActiveModel::MassAssignmentSecurity::WhiteList, klass.active_authorizers[:default].class + assert_equal [], klass.active_authorizers[:default].to_a + + klass.attr_accessible 'foo' + assert_equal ['foo'], Class.new(klass).active_authorizers[:default].to_a + ensure + ActiveRecord::Model.whitelist_attributes = prev + end + end end |