提交 9196b931 编写于 作者: K kennyj

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

上级 215d41d8
......@@ -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
......
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册