spec/gatoroid_spec.rb in gatoroid-0.2.9 vs spec/gatoroid_spec.rb in gatoroid-0.2.10
- old
+ new
@@ -118,10 +118,16 @@
it "should reset value to zero" do
@obj.visits.reset(:date => Time.now, :siteid=>100).should_not raise_error Mongoid::Errors::ModelNotSaved
@obj.visits.today(:siteid=>100).should == 0
end
+ it "should have 1 record using range method for today and yesterday at day grain", :test => true do
+ lambda { @obj.visits.add(1,:siteid=>100) }.should_not raise_error Mongoid::Errors::ModelNotSaved
+ lambda { @obj.visits.add(1,:siteid=>200) }.should_not raise_error Mongoid::Errors::ModelNotSaved
+ lambda { @obj.visits.add(1,:siteid=>200) }.should_not raise_error Mongoid::Errors::ModelNotSaved
+ @obj.visits.group_by(Time.now..Time.now + 1.day).should have(2).record
+ end
end
describe "when using as a model" do
it "should deny access to undefined methods" do
@@ -199,8 +205,16 @@
it "should reset value to zero" do
Test.visits.reset(:date => Time.now, :siteid=>200).should_not raise_error Mongoid::Errors::ModelNotSaved
Test.visits.today(:siteid=>200).should == 0
end
+
+ it "should have 1 record using range method for today and yesterday at day grain", :test => true do
+ lambda { Test.visits.add(1,:siteid=>100) }.should_not raise_error Mongoid::Errors::ModelNotSaved
+ lambda { Test.visits.add(1,:siteid=>200) }.should_not raise_error Mongoid::Errors::ModelNotSaved
+ lambda { Test.visits.add(1,:siteid=>200) }.should_not raise_error Mongoid::Errors::ModelNotSaved
+ Test.visits.group_by(Time.now..Time.now + 1.day).should have(2).record
+ end
+
end
end
\ No newline at end of file