Permalink
Browse files

Fix that changing a store should mark the store attribute as changed

  • Loading branch information...
1 parent 85b64f9 commit 5daf07704ad21d885661216281ffc48b6ea6adfb @dhh dhh committed Oct 25, 2011
Showing with 6 additions and 0 deletions.
  1. +1 −0 activerecord/lib/active_record/store.rb
  2. +5 −0 activerecord/test/cases/store_test.rb
@@ -37,6 +37,7 @@ def store_accessor(store_attribute, *keys)
Array(keys).flatten.each do |key|
define_method("#{key}=") do |value|
send(store_attribute)[key] = value
+ send("#{store_attribute}_will_change!")
end
define_method(key) do
@@ -26,4 +26,9 @@ class StoreTest < ActiveRecord::TestCase
assert 'graeters', @john.reload.settings[:icecream]
end
+
+ test "updating the store will mark it as changed" do
+ @john.color = 'red'
+ assert @john.settings_changed?
+ end
end

2 comments on commit 5daf077

Shouldn't we check if store_attribute[key] != value before triggering "#{store_attribute}_will_change! ?

Please sign in to comment.