提交 051d8598 编写于 作者: S Sen-Zhang

prevent 'attribute_changed?' from returning nil

上级 db9bc809
......@@ -180,7 +180,7 @@ def attribute_changed?(attr, options = nil) #:nodoc:
result &&= options[:to] == __send__(attr) if options.key?(:to)
result &&= options[:from] == changed_attributes[attr] if options.key?(:from)
end
result
!!result
end
# Handles <tt>*_was</tt> for +method_missing+.
......
......@@ -37,8 +37,8 @@ def setup
def test_attribute_changes
# New record - no changes.
pirate = Pirate.new
assert !pirate.catchphrase_changed?
assert_nil pirate.catchphrase_change
assert_equal false, pirate.catchphrase_changed?
assert_equal false, pirate.non_validated_parrot_id_changed?
# Change catchphrase.
pirate.catchphrase = 'arrr'
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册