spec/models/store_extension_spec.rb in motion-prime-0.8.6 vs spec/models/store_extension_spec.rb in motion-prime-0.8.7
- old
+ new
@@ -19,102 +19,102 @@
@store.open
@store.closed?.should.be.false
end
it "should add, delete objects and count them" do
- obj1 = Animal.new
+ obj1 = Organization.new
obj1.name = "Cat"
- obj2 = Animal.new
+ obj2 = Organization.new
obj2.name = "Dog"
- obj3 = Animal.new
+ obj3 = Organization.new
obj3.name = "Cow"
- obj4 = Animal.new
+ obj4 = Organization.new
obj4.name = "Duck"
@store << obj1
@store << [obj2, obj3]
@store += obj4
@store.save
- Animal.count.should == 4
+ Organization.count.should == 4
@store.delete(obj1)
- Animal.count.should == 3
+ Organization.count.should == 3
@store.delete_keys([obj2.key])
- Animal.count.should == 2
+ Organization.count.should == 2
@store.clear
- Animal.count.should == 0
+ Organization.count.should == 0
end
it "should discard unsave changes" do
@store.save_interval = 1000 # must use save_interval= to set auto save interval first
@store.engine.synchronousMode = SynchronousModeFull
- Animal.count.should == 0
- obj1 = Animal.new
+ Organization.count.should == 0
+ obj1 = Organization.new
obj1.name = "Cat"
- obj2 = Animal.new
+ obj2 = Organization.new
obj2.name = "Dog"
@store << [obj1, obj2]
@store.changed?.should.be.true
@store.discard
@store.changed?.should.be.false
- Animal.count.should == 0
+ Organization.count.should == 0
@store.save_interval = 1
end
it "should create a transaction and commit" do
@store.transaction do |the_store|
- Animal.count.should == 0
- obj1 = Animal.new
+ Organization.count.should == 0
+ obj1 = Organization.new
obj1.name = "Cat"
obj1.save
- obj2 = Animal.new
+ obj2 = Organization.new
obj2.name = "Dog"
obj2.save
- Animal.count.should == 2
+ Organization.count.should == 2
end
@store.save
- Animal.count.should == 2
+ Organization.count.should == 2
end
it "should create a transaction and rollback when fail" do
begin
@store.transaction do |the_store|
- Animal.count.should == 0
- obj1 = Animal.new
+ Organization.count.should == 0
+ obj1 = Organization.new
obj1.name = "Cat"
obj1.save
- obj2 = Animal.new
+ obj2 = Organization.new
obj2.name = "Dog"
obj2.save
- Animal.count.should == 2
+ Organization.count.should == 2
raise "error"
end
rescue
end
@store.save
- Animal.count.should == 0
+ Organization.count.should == 0
end
it "should save in batch" do
@store.save_interval = 1000
- Animal.count.should == 0
- obj1 = Animal.new
+ Organization.count.should == 0
+ obj1 = Organization.new
obj1.name = "Cat"
@store << obj1
- obj2 = Animal.new
+ obj2 = Organization.new
obj2.name = "Dog"
@store << obj2
@store.save
- Animal.count.should == 2
+ Organization.count.should == 2
end
end
\ No newline at end of file