1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Added *instance_writer: false* for stored/serialized attributes.

This commit is contained in:
kennyj 2012-07-07 16:35:45 +09:00
parent 9f5d2b1202
commit 75322ac5b8
4 changed files with 16 additions and 2 deletions

View file

@ -6,7 +6,7 @@ module ActiveRecord
included do
# Returns a hash of all the attributes that have been specified for serialization as
# keys and their class restriction as values.
class_attribute :serialized_attributes
class_attribute :serialized_attributes, instance_writer: false
self.serialized_attributes = {}
end

View file

@ -43,7 +43,7 @@ module ActiveRecord
extend ActiveSupport::Concern
included do
class_attribute :stored_attributes
class_attribute :stored_attributes, instance_writer: false
self.stored_attributes = {}
end

View file

@ -51,4 +51,11 @@ class SerializationTest < ActiveRecord::TestCase
assert_equal @contact_attributes[:awesome], contact.awesome, "For #{format}"
end
end
def test_serialized_attributes_are_class_level_settings
assert_raise NoMethodError do
topic = Topic.new
topic.serialized_attributes = []
end
end
end

View file

@ -120,4 +120,11 @@ class StoreTest < ActiveRecord::TestCase
test "stored attributes are returned" do
assert_equal [:color, :homepage], Admin::User.stored_attributes[:settings]
end
test "stores_attributes are class level settings" do
assert_raise NoMethodError do
@john.stored_attributes = {}
end
end
end