Permalink
Browse files

Base.skip_time_zone_conversion_for_attributes uses class_inheritable_…

…accessor, so that subclasses don't overwrite Base [#346 state:resolved]
  • Loading branch information...
1 parent d28c724 commit 9c4730d01e892df8d5c5493a08e0cddf0de5d575 @miloops miloops committed with gbuesing Sep 12, 2008
View
2 activerecord/CHANGELOG
@@ -1,5 +1,7 @@
*Edge*
+* Base.skip_time_zone_conversion_for_attributes uses class_inheritable_accessor, so that subclasses don't overwrite Base [#346 state:resolved] [miloops]
+
* Added find_last_by dynamic finder #762 [miloops]
* Internal API: configurable association options and build_association method for reflections so plugins may extend and override. #985 [Hongli Lai]
View
2 activerecord/lib/active_record/attribute_methods.rb
@@ -10,7 +10,7 @@ def self.included(base)
base.attribute_types_cached_by_default = ATTRIBUTE_TYPES_CACHED_BY_DEFAULT
base.cattr_accessor :time_zone_aware_attributes, :instance_writer => false
base.time_zone_aware_attributes = false
- base.cattr_accessor :skip_time_zone_conversion_for_attributes, :instance_writer => false
+ base.class_inheritable_accessor :skip_time_zone_conversion_for_attributes, :instance_writer => false
base.skip_time_zone_conversion_for_attributes = []
end
View
9 activerecord/test/cases/attribute_methods_test.rb
@@ -1,5 +1,6 @@
require "cases/helper"
require 'models/topic'
+require 'models/minimalistic'
class AttributeMethodsTest < ActiveRecord::TestCase
fixtures :topics
@@ -219,6 +220,14 @@ def test_setting_time_zone_aware_attribute_in_current_time_zone
end
end
+ def test_setting_time_zone_conversion_for_attributes_should_write_value_on_class_variable
+ Topic.skip_time_zone_conversion_for_attributes = [:field_a]
+ Minimalistic.skip_time_zone_conversion_for_attributes = [:field_b]
+
+ assert_equal [:field_a], Topic.skip_time_zone_conversion_for_attributes
+ assert_equal [:field_b], Minimalistic.skip_time_zone_conversion_for_attributes
+ end
+
private
def time_related_columns_on_topic
Topic.columns.select{|c| [:time, :date, :datetime, :timestamp].include?(c.type)}.map(&:name)

0 comments on commit 9c4730d

Please sign in to comment.