mock projects using our helper so we don't have to be concerned about those validations any more

git-svn-id: https://dev.finn.de/svn/cockpit/branches/reporting_merge@1693 7926756e-e54e-46e6-9721-ed318f58905e
pull/6827/head
j.wollert 14 years ago
parent 9576035611
commit 4c9ac0d1e2
  1. 34
      spec/models/cost_query/operator_spec.rb

@ -91,66 +91,66 @@ describe CostQuery do
it "does w (this week)" do
#somehow this test doesn't work on sundays
n = query('projects', 'created_on', 'w').size
Project.generate! :created_on => Time.now
Project.mock! :created_on => Time.now
query('projects', 'created_on', 'w').size.should == n + 1
Project.generate! :created_on => Date.today + 7
Project.generate! :created_on => Date.today - 7
Project.mock! :created_on => Date.today + 7
Project.mock! :created_on => Date.today - 7
query('projects', 'created_on', 'w').size.should == n + 1
end
it "does t (today)" do
s = query('projects', 'created_on', 't').size
Project.generate! :created_on => Date.yesterday
Project.mock! :created_on => Date.yesterday
query('projects', 'created_on', 't').size.should == s
Project.generate! :created_on => Time.now
Project.mock! :created_on => Time.now
query('projects', 'created_on', 't').size.should == s + 1
end
it "does <t+ (before the day which is n days in the future)" do
n = query('projects', 'created_on', '<t+', 2).size
Project.generate! :created_on => Date.tomorrow + 1
Project.mock! :created_on => Date.tomorrow + 1
query('projects', 'created_on', '<t+', 2).size.should == n + 1
Project.generate! :created_on => Date.tomorrow + 2
Project.mock! :created_on => Date.tomorrow + 2
query('projects', 'created_on', '<t+', 2).size.should == n + 1
end
it "does t+ (n days in the future)" do
n = query('projects', 'created_on', 't+', 1).size
Project.generate! :created_on => Date.tomorrow
Project.mock! :created_on => Date.tomorrow
query('projects', 'created_on', 't+', 1).size.should == n + 1
Project.generate! :created_on => Date.tomorrow + 2
Project.mock! :created_on => Date.tomorrow + 2
query('projects', 'created_on', 't+', 1).size.should == n + 1
end
it "does >t+ (after the day which is n days in the furure)" do
n = query('projects', 'created_on', '>t+', 1).size
Project.generate! :created_on => Time.now
Project.mock! :created_on => Time.now
query('projects', 'created_on', '>t+', 1).size.should == n
Project.generate! :created_on => Date.tomorrow + 1
Project.mock! :created_on => Date.tomorrow + 1
query('projects', 'created_on', '>t+', 1).size.should == n + 1
end
it "does >t- (after the day which is n days ago)" do
n = query('projects', 'created_on', '>t-', 1).size
Project.generate! :created_on => Date.today
Project.mock! :created_on => Date.today
query('projects', 'created_on', '>t-', 1).size.should == n + 1
Project.generate! :created_on => Date.yesterday - 1
Project.mock! :created_on => Date.yesterday - 1
query('projects', 'created_on', '>t-', 1).size.should == n + 1
end
it "does t- (n days ago)" do
n = query('projects', 'created_on', 't-', 1).size
Project.generate! :created_on => Date.yesterday
Project.mock! :created_on => Date.yesterday
query('projects', 'created_on', 't-', 1).size.should == n + 1
Project.generate! :created_on => Date.yesterday - 2
Project.mock! :created_on => Date.yesterday - 2
query('projects', 'created_on', 't-', 1).size.should == n + 1
end
it "does <t- (before the day which is n days ago)" do
n = query('projects', 'created_on', '<t-', 1).size
Project.generate! :created_on => Date.today
Project.mock! :created_on => Date.today
query('projects', 'created_on', '<t-', 1).size.should == n
Project.generate! :created_on => Date.yesterday - 1
Project.mock! :created_on => Date.yesterday - 1
query('projects', 'created_on', '<t-', 1).size.should == n + 1
end

Loading…
Cancel
Save