Skip to content

Instantly share code, notes, and snippets.

@mrkurt
Created April 11, 2010 02:29
Show Gist options
  • Select an option

  • Save mrkurt/362449 to your computer and use it in GitHub Desktop.

Select an option

Save mrkurt/362449 to your computer and use it in GitHub Desktop.
diff --git a/spec/unit/mongoid/dirty_spec.rb b/spec/unit/mongoid/dirty_spec.rb
index e412abc..43103c9 100644
--- a/spec/unit/mongoid/dirty_spec.rb
+++ b/spec/unit/mongoid/dirty_spec.rb
@@ -45,6 +45,18 @@ describe Mongoid::Dirty do
end
end
+ context "when the attribute is mutated in place" do
+ before do
+ @person = Person.new(:title => "Grand Poobah")
+ @person.title.sub!("Grand", "Most High")
+ end
+
+ it "tracks field changes" do
+ @person.attribute_change("title").should ==
+ [ "Grand Poobah", "Most High Poobah" ]
+ end
+ end
+
context "when the attribute is removed" do
before do
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment