aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--activerecord/CHANGELOG.md5
-rw-r--r--activerecord/lib/active_record/store.rb2
-rw-r--r--activerecord/test/cases/store_test.rb7
3 files changed, 13 insertions, 1 deletions
diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md
index bf6a26b1be..0d3852f199 100644
--- a/activerecord/CHANGELOG.md
+++ b/activerecord/CHANGELOG.md
@@ -42,6 +42,11 @@
*kennyj*
+* Fix `ActiveRecord::Store` incorrectly tracking changes of its attributes.
+ Fixes #10373.
+
+ *Janko Marohnić*
+
## Rails 3.2.13 (Mar 18, 2013) ##
diff --git a/activerecord/lib/active_record/store.rb b/activerecord/lib/active_record/store.rb
index 49d01de365..bacb78e2e1 100644
--- a/activerecord/lib/active_record/store.rb
+++ b/activerecord/lib/active_record/store.rb
@@ -37,8 +37,8 @@ module ActiveRecord
Array(keys).flatten.each do |key|
define_method("#{key}=") do |value|
send("#{store_attribute}=", {}) unless send(store_attribute).is_a?(Hash)
- send(store_attribute)[key] = value
send("#{store_attribute}_will_change!")
+ send(store_attribute)[key] = value
end
define_method(key) do
diff --git a/activerecord/test/cases/store_test.rb b/activerecord/test/cases/store_test.rb
index 277fc9d676..bbcbeac959 100644
--- a/activerecord/test/cases/store_test.rb
+++ b/activerecord/test/cases/store_test.rb
@@ -40,4 +40,11 @@ class StoreTest < ActiveRecord::TestCase
@john.remember_login = false
assert_equal false, @john.remember_login
end
+
+ test "updating the store will track changes correctly" do
+ @john.color = "blue"
+ assert_equal [{:color => "black"}, {:color => "blue"}], @john.settings_change
+ @john.homepage = "37signals.com"
+ assert_equal [{:color => "black"}, {:color => "blue", :homepage => "37signals.com"}], @john.settings_change
+ end
end