[Fix #264] Add the last 4 months evolution graphs to Stats
This commit is contained in:
parent
0cc5d85f13
commit
ed7ba60cf0
3 changed files with 70 additions and 0 deletions
|
@ -1,6 +1,44 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe StatsController, type: :controller do
|
||||
describe "#last_four_months_hash" do
|
||||
context "without a date attribute" do
|
||||
before do
|
||||
FactoryGirl.create(:procedure, :created_at => 6.months.ago)
|
||||
FactoryGirl.create(:procedure, :created_at => 45.days.ago)
|
||||
FactoryGirl.create(:procedure, :created_at => 1.days.ago)
|
||||
FactoryGirl.create(:procedure, :created_at => 1.days.ago)
|
||||
end
|
||||
|
||||
let (:association) { Procedure.all }
|
||||
|
||||
subject { StatsController.new.send(:last_four_months_hash, association) }
|
||||
|
||||
it { expect(subject).to eq([
|
||||
[I18n.l(45.days.ago.beginning_of_month, format: "%B %Y"), 1],
|
||||
[I18n.l(1.days.ago.beginning_of_month, format: "%B %Y"), 2]
|
||||
] ) }
|
||||
end
|
||||
|
||||
context "with a date attribute" do
|
||||
before do
|
||||
FactoryGirl.create(:procedure, :created_at => 6.months.ago, :updated_at => 6.months.ago)
|
||||
FactoryGirl.create(:procedure, :created_at => 2.months.ago, :updated_at => 45.days.ago)
|
||||
FactoryGirl.create(:procedure, :created_at => 2.months.ago, :updated_at => 45.days.ago)
|
||||
FactoryGirl.create(:procedure, :created_at => 2.months.ago, :updated_at => 1.days.ago)
|
||||
end
|
||||
|
||||
let (:association) { Procedure.all }
|
||||
|
||||
subject { StatsController.new.send(:last_four_months_hash, association, :updated_at) }
|
||||
|
||||
it { expect(subject).to eq([
|
||||
[I18n.l(45.days.ago.beginning_of_month, format: "%B %Y"), 2],
|
||||
[I18n.l(1.days.ago.beginning_of_month, format: "%B %Y"), 1]
|
||||
] ) }
|
||||
end
|
||||
end
|
||||
|
||||
describe '#thirty_days_flow_hash' do
|
||||
context "without a date_attribut" do
|
||||
before do
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue