Skip to content

Loading…

Ensure ActiveModel 3.2.x compatibility #151

Merged
merged 1 commit into from

2 participants

@jodosha

No description provided.

@samlown samlown merged commit 90d99c0 into couchrest:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 25, 2012
  1. @jodosha
This page is out of date. Refresh to see the latest.
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
2 couchrest_model.gemspec
@@ -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"])
View
3 lib/couchrest/model/base.rb
@@ -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
21 spec/unit/dirty_spec.rb
@@ -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
Something went wrong with that request. Please try again.