Changeset 6051
- Timestamp:
- 01/28/07 01:31:31 (2 years ago)
- Files:
-
- trunk/activerecord/CHANGELOG (modified) (1 diff)
- trunk/activerecord/lib/active_record/base.rb (modified) (8 diffs)
- trunk/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb (modified) (1 diff)
- trunk/activerecord/lib/active_record/locking/optimistic.rb (modified) (1 diff)
- trunk/activerecord/lib/active_record/timestamp.rb (modified) (1 diff)
- trunk/activerecord/test/base_test.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/activerecord/CHANGELOG
r6031 r6051 1 1 *SVN* 2 3 * Don't create instance writer methods for class attributes. Closes #7401 [Rick] 2 4 3 5 * Docs: validations examples. #7343 [zackchandler] trunk/activerecord/lib/active_record/base.rb
r6018 r6051 266 266 # Accepts a logger conforming to the interface of Log4r or the default Ruby 1.8+ Logger class, which is then passed 267 267 # on to any new database connections made and which can be retrieved on both a class and instance level by calling +logger+. 268 cattr_accessor :logger 268 cattr_accessor :logger, :instance_writer => false 269 269 270 270 include Reloadable::Deprecated … … 292 292 @@subclasses = {} 293 293 294 cattr_accessor :configurations 294 cattr_accessor :configurations, :instance_writer => false 295 295 @@configurations = {} 296 296 … … 299 299 # the primary column. If the latter is specified, the Product class will look for "product_id" instead of "id". Remember 300 300 # that this is a global setting for all Active Records. 301 cattr_accessor :primary_key_prefix_type 301 cattr_accessor :primary_key_prefix_type, :instance_writer => false 302 302 @@primary_key_prefix_type = nil 303 303 … … 305 305 # table names will be named like "basecamp_projects", "basecamp_people", etc. This is a convenient way of creating a namespace 306 306 # for tables in a shared database. By default, the prefix is the empty string. 307 cattr_accessor :table_name_prefix 307 cattr_accessor :table_name_prefix, :instance_writer => false 308 308 @@table_name_prefix = "" 309 309 310 310 # Works like +table_name_prefix+, but appends instead of prepends (set to "_basecamp" gives "projects_basecamp", 311 311 # "people_basecamp"). By default, the suffix is the empty string. 312 cattr_accessor :table_name_suffix 312 cattr_accessor :table_name_suffix, :instance_writer => false 313 313 @@table_name_suffix = "" 314 314 … … 316 316 # If true, the default table name for a +Product+ class will be +products+. If false, it would just be +product+. 317 317 # See table_name for the full rules on table/class naming. This is true, by default. 318 cattr_accessor :pluralize_table_names 318 cattr_accessor :pluralize_table_names, :instance_writer => false 319 319 @@pluralize_table_names = true 320 320 … … 322 322 # make it much easier to overview things during debugging (when used through a reader like +tail+ and on a black background), but 323 323 # may complicate matters if you use software like syslog. This is true, by default. 324 cattr_accessor :colorize_logging 324 cattr_accessor :colorize_logging, :instance_writer => false 325 325 @@colorize_logging = true 326 326 327 327 # Determines whether to use Time.local (using :local) or Time.utc (using :utc) when pulling dates and times from the database. 328 328 # This is set to :local by default. 329 cattr_accessor :default_timezone 329 cattr_accessor :default_timezone, :instance_writer => false 330 330 @@default_timezone = :local 331 331 332 332 # Determines whether or not to use a connection for each thread, or a single shared connection for all threads. 333 333 # Defaults to false. Set to true if you're writing a threaded application. 334 cattr_accessor :allow_concurrency 334 cattr_accessor :allow_concurrency, :instance_writer => false 335 335 @@allow_concurrency = false 336 336 … … 339 339 # attributes by name. You might want to set this to false in development 340 340 # mode, because the methods would be regenerated on each request. 341 cattr_accessor :generate_read_methods 341 cattr_accessor :generate_read_methods, :instance_writer => false 342 342 @@generate_read_methods = true 343 343 … … 348 348 # supports migrations. Use :ruby if you want to have different database 349 349 # adapters for, e.g., your development and test environments. 350 cattr_accessor :schema_format 350 cattr_accessor :schema_format , :instance_writer => false 351 351 @@schema_format = :ruby 352 352 trunk/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb
r5955 r6051 12 12 # Check for activity after at least +verification_timeout+ seconds. 13 13 # Defaults to 0 (always check.) 14 cattr_accessor :verification_timeout 14 cattr_accessor :verification_timeout, :instance_writer => false 15 15 @@verification_timeout = 0 16 16 trunk/activerecord/lib/active_record/locking/optimistic.rb
r5007 r6051 27 27 base.extend ClassMethods 28 28 29 base.cattr_accessor :lock_optimistically 29 base.cattr_accessor :lock_optimistically, :instance_writer => false 30 30 base.lock_optimistically = true 31 31 trunk/activerecord/lib/active_record/timestamp.rb
r4706 r6051 24 24 base.alias_method_chain :update, :timestamps 25 25 26 base.cattr_accessor :record_timestamps 26 base.cattr_accessor :record_timestamps, :instance_writer => false 27 27 base.record_timestamps = true 28 28 end trunk/activerecord/test/base_test.rb
r5958 r6051 749 749 assert_equal 1, firm.rating 750 750 end 751 752 def test_mass_assignment_protection_against_class_attribute_writers 753 [:logger, :configurations, :primary_key_prefix_type, :table_name_prefix, :table_name_suffix, :pluralize_table_names, :colorize_logging, 754 :default_timezone, :allow_concurrency, :generate_read_methods, :schema_format, :verification_timeout, :lock_optimistically, :record_timestamps].each do |method| 755 assert Task.respond_to?(method) 756 assert Task.respond_to?("#{method}=") 757 assert Task.new.respond_to?(method) 758 assert !Task.new.respond_to?("#{method}=") 759 end 760 end 751 761 752 762 def test_customized_primary_key_remains_protected