Skip to content
Browse files

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

  • Loading branch information...
1 parent 9f5d2b1 commit 75322ac5b84198b16ad2202888a620ffec6ca9aa @kennyj committed Jul 7, 2012
View
2 activerecord/lib/active_record/attribute_methods/serialization.rb
@@ -6,7 +6,7 @@ module Serialization
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
2 activerecord/lib/active_record/store.rb
@@ -43,7 +43,7 @@ module Store
extend ActiveSupport::Concern
included do
- class_attribute :stored_attributes
+ class_attribute :stored_attributes, instance_writer: false
self.stored_attributes = {}
end
View
7 activerecord/test/cases/serialization_test.rb
@@ -51,4 +51,11 @@ def test_serialize_should_allow_attribute_except_filtering
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
7 activerecord/test/cases/store_test.rb
@@ -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

0 comments on commit 75322ac

Please sign in to comment.
Something went wrong with that request. Please try again.