diff options
author | Andrew White <andyw@pixeltrix.co.uk> | 2011-05-21 16:28:11 +0100 |
---|---|---|
committer | Andrew White <andyw@pixeltrix.co.uk> | 2011-05-21 16:33:54 +0100 |
commit | 09daaaa1e0481207c06416f909171d4f66bc0f6d (patch) | |
tree | f5693ddc5f072afb2bfef589af430858a9480b9c /activerecord/test | |
parent | 1a959ad72fc92a82e05e8c271858a64ed14b926e (diff) | |
download | rails-09daaaa1e0481207c06416f909171d4f66bc0f6d.tar.gz rails-09daaaa1e0481207c06416f909171d4f66bc0f6d.tar.bz2 rails-09daaaa1e0481207c06416f909171d4f66bc0f6d.zip |
Add support for passing mass assignment roles to dynamic finders. Closes #1170.
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/mass_assignment_security_test.rb | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/activerecord/test/cases/mass_assignment_security_test.rb b/activerecord/test/cases/mass_assignment_security_test.rb index 765033852d..33737e12a8 100644 --- a/activerecord/test/cases/mass_assignment_security_test.rb +++ b/activerecord/test/cases/mass_assignment_security_test.rb @@ -239,6 +239,54 @@ class MassAssignmentSecurityTest < ActiveRecord::TestCase end end + def test_find_or_initialize_by_with_attr_accessible_attributes + p = TightPerson.find_or_initialize_by_first_name('Josh', attributes_hash) + + assert_default_attributes(p) + end + + def test_find_or_initialize_by_with_admin_role_with_attr_accessible_attributes + p = TightPerson.find_or_initialize_by_first_name('Josh', attributes_hash, :as => :admin) + + assert_admin_attributes(p) + end + + def test_find_or_initialize_by_with_attr_protected_attributes + p = LoosePerson.find_or_initialize_by_first_name('Josh', attributes_hash) + + assert_default_attributes(p) + end + + def test_find_or_initialize_by_with_admin_role_with_attr_protected_attributes + p = LoosePerson.find_or_initialize_by_first_name('Josh', attributes_hash, :as => :admin) + + assert_admin_attributes(p) + end + + def test_find_or_create_by_with_attr_accessible_attributes + p = TightPerson.find_or_create_by_first_name('Josh', attributes_hash) + + assert_default_attributes(p, true) + end + + def test_find_or_create_by_with_admin_role_with_attr_accessible_attributes + p = TightPerson.find_or_create_by_first_name('Josh', attributes_hash, :as => :admin) + + assert_admin_attributes(p, true) + end + + def test_find_or_create_by_with_attr_protected_attributes + p = LoosePerson.find_or_create_by_first_name('Josh', attributes_hash) + + assert_default_attributes(p, true) + end + + def test_find_or_create_by_with_admin_role_with_attr_protected_attributes + p = LoosePerson.find_or_create_by_first_name('Josh', attributes_hash, :as => :admin) + + assert_admin_attributes(p, true) + end + end |