Skip to content

Commit

Permalink
Ensure ActiveModel 3.2.x compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
jodosha committed Jun 25, 2012
1 parent e221051 commit ca3b8e3
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
2 changes: 1 addition & 1 deletion couchrest_model.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
Expand Down
3 changes: 2 additions & 1 deletion lib/couchrest/model/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 16 additions & 5 deletions spec/unit/dirty_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ca3b8e3

Please sign in to comment.