1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Merge pull request #24515 from Sen-Zhang/attribute_changed_not_return_nil

prevent 'attribute_changed?' from returning nil
This commit is contained in:
Sean Griffin 2016-04-12 14:54:31 -06:00
commit ba194d4230
2 changed files with 3 additions and 3 deletions

View file

@ -180,7 +180,7 @@ module ActiveModel
result &&= options[:to] == __send__(attr) if options.key?(:to) result &&= options[:to] == __send__(attr) if options.key?(:to)
result &&= options[:from] == changed_attributes[attr] if options.key?(:from) result &&= options[:from] == changed_attributes[attr] if options.key?(:from)
end end
result !!result
end end
# Handles <tt>*_was</tt> for +method_missing+. # Handles <tt>*_was</tt> for +method_missing+.

View file

@ -37,8 +37,8 @@ class DirtyTest < ActiveRecord::TestCase
def test_attribute_changes def test_attribute_changes
# New record - no changes. # New record - no changes.
pirate = Pirate.new pirate = Pirate.new
assert !pirate.catchphrase_changed? assert_equal false, pirate.catchphrase_changed?
assert_nil pirate.catchphrase_change assert_equal false, pirate.non_validated_parrot_id_changed?
# Change catchphrase. # Change catchphrase.
pirate.catchphrase = 'arrr' pirate.catchphrase = 'arrr'