diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2008-07-31 15:56:46 +0100 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2008-07-31 15:56:46 +0100 |
commit | 108db00aa90fe266564483ab301cf0669cae600f (patch) | |
tree | cbf457189f968bd61d28124c675ff20337094ef3 /activerecord/test | |
parent | f64bd2ca85595f94cbbe809f51a52cdb9b68af19 (diff) | |
download | rails-108db00aa90fe266564483ab301cf0669cae600f.tar.gz rails-108db00aa90fe266564483ab301cf0669cae600f.tar.bz2 rails-108db00aa90fe266564483ab301cf0669cae600f.zip |
Raise UnknownAttributeError when unknown attributes are supplied via mass assignment
Diffstat (limited to 'activerecord/test')
-rwxr-xr-x | activerecord/test/cases/base_test.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/activerecord/test/cases/base_test.rb b/activerecord/test/cases/base_test.rb index 9e4f268db7..e6d1b5ddfd 100755 --- a/activerecord/test/cases/base_test.rb +++ b/activerecord/test/cases/base_test.rb @@ -904,6 +904,14 @@ class BasicsTest < ActiveRecord::TestCase assert_nil keyboard.id end + def test_mass_assigning_invalid_attribute + firm = Firm.new + + assert_raises(ActiveRecord::UnknownAttributeError) do + firm.attributes = { "id" => 5, "type" => "Client", "i_dont_even_exist" => 20 } + end + end + def test_mass_assignment_protection_on_defaults firm = Firm.new firm.attributes = { "id" => 5, "type" => "Client" } |