Permalink
Browse files

Merge branch 'master' of github.com:couchrest/couchrest_model

Conflicts:
	lib/couchrest/model/base.rb
  • Loading branch information...
2 parents aad84fa + 90d99c0 commit acbef7acf7d80ecbee6a902395d9646de9ba5b74 @samlown samlown committed Aug 2, 2012
Showing with 17 additions and 6 deletions.
  1. +1 −1 lib/couchrest/model/base.rb
  2. +16 −5 spec/unit/dirty_spec.rb
@@ -2,7 +2,7 @@ module CouchRest
module Model
class Base < CouchRest::Document
- extend ActiveModel::Naming
+ extend ActiveModel::Naming
include ActiveModel::Conversion
include CouchRest::Model::Configuration
@@ -33,11 +33,22 @@ def code; self['_id'] || @code; end
describe "changes" do
- it "should return changes on an attribute" do
- @card = Card.new(:first_name => "matt")
- @card.first_name = "andrew"
- @card.first_name_changed?.should be_true
- @card.changes.should == { "first_name" => ["matt", "andrew"] }
+ context "when new record" do
+ it "should return changes on an attribute" do
+ @card = Card.new(:first_name => "matt")
+ @card.first_name = "andrew"
+ @card.first_name_changed?.should be_true
+ @card.changes.should == { "first_name" => [nil, "andrew"] }
+ end
+ end
+
+ context "when persisted" do
+ it "should return changes on an attribute" do
+ @card = Card.create!(:first_name => "matt")
+ @card.first_name = "andrew"
+ @card.first_name_changed?.should be_true
+ @card.changes.should == { "first_name" => ["matt", "andrew"] }
+ end
end
end

0 comments on commit acbef7a

Please sign in to comment.