Add a date_attribute argument to StatsController#cumulative_hash
This commit is contained in:
parent
dbf891b333
commit
06714b5fc3
2 changed files with 27 additions and 8 deletions
|
@ -50,19 +50,38 @@ describe StatsController, type: :controller do
|
|||
end
|
||||
|
||||
describe '#cumulative_hash' do
|
||||
context "without a date attribute" do
|
||||
before do
|
||||
FactoryGirl.create(:procedure, :created_at => 45.days.ago)
|
||||
FactoryGirl.create(:procedure, :created_at => 15.days.ago)
|
||||
FactoryGirl.create(:procedure, :created_at => 15.days.ago)
|
||||
end
|
||||
|
||||
let (:association) { Procedure.all }
|
||||
|
||||
subject { StatsController.new.send(:cumulative_hash, association) }
|
||||
|
||||
it { expect(subject).to eq({
|
||||
45.days.ago.beginning_of_month => 1,
|
||||
15.days.ago.beginning_of_month => 3
|
||||
}) }
|
||||
end
|
||||
end
|
||||
|
||||
context "with a date attribute" do
|
||||
before do
|
||||
FactoryGirl.create(:procedure, :created_at => 45.days.ago)
|
||||
FactoryGirl.create(:procedure, :created_at => 15.days.ago)
|
||||
FactoryGirl.create(:procedure, :created_at => 15.days.ago)
|
||||
FactoryGirl.create(:procedure, :created_at => 45.days.ago, :updated_at => 20.days.ago)
|
||||
FactoryGirl.create(:procedure, :created_at => 15.days.ago, :updated_at => 20.days.ago)
|
||||
FactoryGirl.create(:procedure, :created_at => 15.days.ago, :updated_at => 10.days.ago)
|
||||
end
|
||||
|
||||
let (:association) { Procedure.all }
|
||||
|
||||
subject { StatsController.new.send(:cumulative_hash, association) }
|
||||
subject { StatsController.new.send(:cumulative_hash, association, :updated_at) }
|
||||
|
||||
it { expect(subject).to eq({
|
||||
45.days.ago.beginning_of_month => 1,
|
||||
15.days.ago.beginning_of_month => 3
|
||||
20.days.ago.beginning_of_month => 2,
|
||||
10.days.ago.beginning_of_month => 3
|
||||
}) }
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue