Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Don't mark the store as changed if an attribute isn't changed.

  • Loading branch information...
commit 9196b93111b5f89f030b089d32d7a3a9d49b0df9 1 parent 215d41d
@kennyj kennyj authored
View
7 activerecord/lib/active_record/store.rb
@@ -58,8 +58,11 @@ def store_accessor(store_attribute, *keys)
keys.each do |key|
define_method("#{key}=") do |value|
initialize_store_attribute(store_attribute)
- send(store_attribute)[key] = value
- send :"#{store_attribute}_will_change!"
+ attribute = send(store_attribute)
+ if value != attribute[key]
+ attribute[key] = value
+ send :"#{store_attribute}_will_change!"
+ end
end
define_method(key) do
View
5 activerecord/test/cases/store_test.rb
@@ -34,6 +34,11 @@ class StoreTest < ActiveRecord::TestCase
assert @john.settings_changed?
end
+ test "updating the store won't mark it as changed if an attribute isn't changed" do
+ @john.color = @john.color
+ assert !@john.settings_changed?
+ end
+
test "object initialization with not nullable column" do
assert_equal true, @john.remember_login
end
Please sign in to comment.
Something went wrong with that request. Please try again.