aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/dirty_test.rb
diff options
context:
space:
mode:
authorSean Griffin <sean@thoughtbot.com>2014-06-12 15:13:28 -0600
committerSean Griffin <sean@thoughtbot.com>2014-06-13 14:07:41 -0600
commit4bf8ffc6516312e68fb0d2b4ac97505f8d0cf192 (patch)
tree239a8205dc68ac3bada7a2712f52f2defa159f00 /activerecord/test/cases/dirty_test.rb
parent8a3046133aba188d81f31b034d6594899b23c70c (diff)
downloadrails-4bf8ffc6516312e68fb0d2b4ac97505f8d0cf192.tar.gz
rails-4bf8ffc6516312e68fb0d2b4ac97505f8d0cf192.tar.bz2
rails-4bf8ffc6516312e68fb0d2b4ac97505f8d0cf192.zip
Detect in-place changes on mutable AR attributes
We have several mutable types on Active Record now. (Serialized, JSON, HStore). We need to be able to detect if these have been modified in place.
Diffstat (limited to 'activerecord/test/cases/dirty_test.rb')
-rw-r--r--activerecord/test/cases/dirty_test.rb11
1 files changed, 10 insertions, 1 deletions
diff --git a/activerecord/test/cases/dirty_test.rb b/activerecord/test/cases/dirty_test.rb
index 87f24e32b2..5d6601a881 100644
--- a/activerecord/test/cases/dirty_test.rb
+++ b/activerecord/test/cases/dirty_test.rb
@@ -445,11 +445,20 @@ class DirtyTest < ActiveRecord::TestCase
def test_save_should_store_serialized_attributes_even_with_partial_writes
with_partial_writes(Topic) do
topic = Topic.create!(:content => {:a => "a"})
+
+ assert_not topic.changed?
+
topic.content[:b] = "b"
- #assert topic.changed? # Known bug, will fail
+
+ assert topic.changed?
+
topic.save!
+
+ assert_not topic.changed?
assert_equal "b", topic.content[:b]
+
topic.reload
+
assert_equal "b", topic.content[:b]
end
end