diff options
Diffstat (limited to 'activerecord/test')
-rwxr-xr-x | activerecord/test/base_test.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/activerecord/test/base_test.rb b/activerecord/test/base_test.rb index 3171e75bac..d74a7b82b5 100755 --- a/activerecord/test/base_test.rb +++ b/activerecord/test/base_test.rb @@ -53,6 +53,12 @@ class Task < ActiveRecord::Base attr_protected :starting end +class TopicWithProtectedContentAndAccessibleAuthorName < ActiveRecord::Base + self.table_name = 'topics' + attr_accessible :author_name + attr_protected :content +end + class BasicsTest < Test::Unit::TestCase fixtures :topics, :companies, :developers, :projects, :computers, :accounts @@ -771,6 +777,12 @@ class BasicsTest < Test::Unit::TestCase assert_raise(ActiveRecord::RecordInvalid) { reply.update_attributes!(:title => nil, :content => "Have a nice evening") } end + def test_mass_assignment_should_raise_exception_if_accessible_and_protected_attribute_writers_are_both_used + topic = TopicWithProtectedContentAndAccessibleAuthorName.new + assert_raises(RuntimeError) { topic.attributes = { "author_name" => "me" } } + assert_raises(RuntimeError) { topic.attributes = { "content" => "stuff" } } + end + def test_mass_assignment_protection firm = Firm.new firm.attributes = { "name" => "Next Angle", "rating" => 5 } |