From 1a11bffde107bf5b2daa997a61133cc8a76445e0 Mon Sep 17 00:00:00 2001 From: Rick Olson Date: Sun, 28 Jan 2007 01:31:31 +0000 Subject: Don't create instance writer methods for class attributes. Closes #7401 [Rick] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6051 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activerecord/test/base_test.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'activerecord/test/base_test.rb') diff --git a/activerecord/test/base_test.rb b/activerecord/test/base_test.rb index e1dd5704db..95c758f805 100755 --- a/activerecord/test/base_test.rb +++ b/activerecord/test/base_test.rb @@ -748,6 +748,16 @@ class BasicsTest < Test::Unit::TestCase firm.attributes = { "name" => "Next Angle", "rating" => 5 } assert_equal 1, firm.rating end + + def test_mass_assignment_protection_against_class_attribute_writers + [:logger, :configurations, :primary_key_prefix_type, :table_name_prefix, :table_name_suffix, :pluralize_table_names, :colorize_logging, + :default_timezone, :allow_concurrency, :generate_read_methods, :schema_format, :verification_timeout, :lock_optimistically, :record_timestamps].each do |method| + assert Task.respond_to?(method) + assert Task.respond_to?("#{method}=") + assert Task.new.respond_to?(method) + assert !Task.new.respond_to?("#{method}=") + end + end def test_customized_primary_key_remains_protected subscriber = Subscriber.new(:nick => 'webster123', :name => 'nice try') -- cgit v1.2.3