aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/dirty_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/test/cases/dirty_test.rb')
-rw-r--r--activerecord/test/cases/dirty_test.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/activerecord/test/cases/dirty_test.rb b/activerecord/test/cases/dirty_test.rb
index ac95bac4ad..74571d923a 100644
--- a/activerecord/test/cases/dirty_test.rb
+++ b/activerecord/test/cases/dirty_test.rb
@@ -62,6 +62,16 @@ class DirtyTest < ActiveRecord::TestCase
assert_equal parrot.name_change, parrot.title_change
end
+ def test_reset_attribute!
+ pirate = Pirate.create!(:catchphrase => 'Yar!')
+ pirate.catchphrase = 'Ahoy!'
+
+ pirate.reset_catchphrase!
+ assert_equal "Yar!", pirate.catchphrase
+ assert_equal Hash.new, pirate.changes
+ assert !pirate.catchphrase_changed?
+ end
+
def test_nullable_number_not_marked_as_changed_if_new_value_is_blank
pirate = Pirate.new
@@ -288,6 +298,16 @@ class DirtyTest < ActiveRecord::TestCase
end
end
+ def test_save_should_not_save_serialized_attribute_with_partial_updates_if_not_present
+ with_partial_updates(Topic) do
+ Topic.create!(:author_name => 'Bill', :content => {:a => "a"})
+ topic = Topic.first(:select => 'id, author_name')
+ topic.update_attribute :author_name, 'John'
+ topic = Topic.first
+ assert_not_nil topic.content
+ end
+ end
+
private
def with_partial_updates(klass, on = true)
old = klass.partial_updates?