diff options
author | Jacob Atzen <jacob@jacobatzen.dk> | 2010-03-12 10:22:29 +0100 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-03-27 10:48:32 +0100 |
commit | a5d637d86c02d911b07d48bdbfbc4f23fb59d720 (patch) | |
tree | 0f79272a6c135a75cac138e79d4a5da628b79c7a /activemodel/test | |
parent | 140cc9caf640d9c32649e396cecbaad3743fd907 (diff) | |
download | rails-a5d637d86c02d911b07d48bdbfbc4f23fb59d720.tar.gz rails-a5d637d86c02d911b07d48bdbfbc4f23fb59d720.tar.bz2 rails-a5d637d86c02d911b07d48bdbfbc4f23fb59d720.zip |
ActiveModel::Dirty#changes should return a HashWithIndifferentAccess [#4157 state:resolved]
Keep the Rails style of inject
Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'activemodel/test')
-rw-r--r-- | activemodel/test/cases/dirty_test.rb | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/activemodel/test/cases/dirty_test.rb b/activemodel/test/cases/dirty_test.rb new file mode 100644 index 0000000000..c910cb43d4 --- /dev/null +++ b/activemodel/test/cases/dirty_test.rb @@ -0,0 +1,29 @@ +require "cases/helper" + +class DirtyTest < ActiveModel::TestCase + class DirtyModel + include ActiveModel::Dirty + define_attribute_methods [:name] + + def initialize + @name = nil + end + + def name + @name + end + + def name=(val) + name_will_change! + @name = val + end + end + + test "changes accessible through both strings and symbols" do + model = DirtyModel.new + model.name = "David" + assert !model.changes[:name].nil? + assert !model.changes['name'].nil? + end + +end |