Skip to content

Commit

Permalink
A few more specs for disabling tracking
Browse files Browse the repository at this point in the history
  • Loading branch information
samlown committed Aug 19, 2016
1 parent 6f9e4dd commit 93432e1
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
1 change: 1 addition & 0 deletions spec/fixtures/models/person.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

class Person
include ::CouchRest::Model::Embeddable

property :pet, Cat
property :name, [String]

Expand Down
3 changes: 3 additions & 0 deletions spec/fixtures/models/project.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
class Project < CouchRest::Model::Base
use_database DB

disable_dirty_tracking true

property :name, String
timestamps!

Expand Down
33 changes: 33 additions & 0 deletions spec/unit/dirty_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -581,4 +581,37 @@ def should_not_change_hash

end

context "when dirty tracking is disabled" do

let :obj do
Project.new(:name => 'Test')
end

it "should be persisted correctly" do
obj.save!
expect(Project.get(obj.id)).to_not be_nil
end

it "should always assume the doc has changed" do
expect(obj.changed?).to be_true
obj.save!
expect(obj.changed?).to be_true
end

it "should provide a nil changes set" do
expect(obj.changes).to be_nil
end

it "should not store a changes cache" do
expect(obj.send(:original_change_data)).to be_nil
end

it "should asume all properties have changed" do
obj.save!
obj.name = "Fooo"
expect(obj.name_changed?).to be_true
expect(obj.name_change).to eql(nil)
end

end
end

0 comments on commit 93432e1

Please sign in to comment.