Permalink
Browse files

Merge pull request #151 from ifad/activemodel-3.2.x

Ensure ActiveModel 3.2.x compatibility
  • Loading branch information...
2 parents e221051 + ca3b8e3 commit 90d99c08f3a9533315ca1404115f87d261e9e6d3 @samlown samlown committed Aug 2, 2012
Showing with 19 additions and 7 deletions.
  1. +1 −1 couchrest_model.gemspec
  2. +2 −1 lib/couchrest/model/base.rb
  3. +16 −5 spec/unit/dirty_spec.rb
View
@@ -25,7 +25,7 @@ Gem::Specification.new do |s|
s.add_dependency(%q<couchrest>, "~> 1.1.2")
s.add_dependency(%q<mime-types>, "~> 1.15")
- s.add_dependency(%q<activemodel>, "~> 3.1.0")
+ s.add_dependency(%q<activemodel>, "~> 3.2.0")
s.add_dependency(%q<tzinfo>, "~> 0.3.22")
s.add_development_dependency(%q<rspec>, "~> 2.6.0")
s.add_development_dependency(%q<json>, ["~> 1.5.1"])
@@ -2,7 +2,8 @@ module CouchRest
module Model
class Base < CouchRest::Document
- extend ActiveModel::Naming
+ extend ActiveModel::Naming
+ include ActiveModel::Conversion
include CouchRest::Model::Configuration
include CouchRest::Model::Connection
View
@@ -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 90d99c0

Please sign in to comment.