aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/test
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2013-10-03 11:37:10 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2013-10-03 11:37:10 -0300
commitc48c111bb2aa13d72f5ae6cf7d51a921766c7dfe (patch)
tree0b8fca50037791e67f8c5534d80bcc59db6114c9 /activemodel/test
parent2dabee25176b6fef7255bbcc1f9641cdd5d6514c (diff)
parent0e655873d4f41922fa2614919342482b1dbd2343 (diff)
downloadrails-c48c111bb2aa13d72f5ae6cf7d51a921766c7dfe.tar.gz
rails-c48c111bb2aa13d72f5ae6cf7d51a921766c7dfe.tar.bz2
rails-c48c111bb2aa13d72f5ae6cf7d51a921766c7dfe.zip
Merge pull request #8791 from griffinmyers/master
Updated DirtyModel's @changed_attributes hash to be symbol/string agnostic Conflicts: activemodel/CHANGELOG.md
Diffstat (limited to 'activemodel/test')
-rw-r--r--activemodel/test/cases/dirty_test.rb17
1 files changed, 16 insertions, 1 deletions
diff --git a/activemodel/test/cases/dirty_test.rb b/activemodel/test/cases/dirty_test.rb
index ed34ca8a6e..a90d0b1299 100644
--- a/activemodel/test/cases/dirty_test.rb
+++ b/activemodel/test/cases/dirty_test.rb
@@ -3,11 +3,12 @@ require "cases/helper"
class DirtyTest < ActiveModel::TestCase
class DirtyModel
include ActiveModel::Dirty
- define_attribute_methods :name, :color
+ define_attribute_methods :name, :color, :size
def initialize
@name = nil
@color = nil
+ @size = nil
end
def name
@@ -28,6 +29,15 @@ class DirtyTest < ActiveModel::TestCase
@color = val
end
+ def size
+ @size
+ end
+
+ def size=(val)
+ attribute_will_change!(:size) unless val == @size
+ @size = val
+ end
+
def save
changes_applied
end
@@ -124,4 +134,9 @@ class DirtyTest < ActiveModel::TestCase
assert_equal ["Otto", "Mr. Manfredgensonton"], @model.name_change
assert_equal @model.name_was, "Otto"
end
+
+ test "using attribute_will_change! with a symbol" do
+ @model.size = 1
+ assert @model.size_changed?
+ end
end