Skip to content

Instantly share code, notes, and snippets.

@lest
Created February 9, 2012 07:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lest/6101aae3cb48b31e6c4a to your computer and use it in GitHub Desktop.
Save lest/6101aae3cb48b31e6c4a to your computer and use it in GitHub Desktop.
diff --git a/activerecord/test/cases/dirty_test.rb b/activerecord/test/cases/dirty_test.rb
index b1ce846..1b6fa95 100644
--- a/activerecord/test/cases/dirty_test.rb
+++ b/activerecord/test/cases/dirty_test.rb
@@ -150,6 +150,13 @@ class DirtyTest < ActiveRecord::TestCase
assert_equal parrot.name_change, parrot.title_change
end
+ def test_change_attribute_using_gsub
+ parrot = Parrot.create(:name => 'test')
+ parrot.name.gsub(/te/, '')
+ assert_equal('st', parrot.name)
+ assert_equal({'name' => ['test', 'st']}, parrot.changes)
+ end
+
def test_reset_attribute!
pirate = Pirate.create!(:catchphrase => 'Yar!')
pirate.catchphrase = 'Ahoy!'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment