Add StatsController#thirty_days_flow_hash
This commit is contained in:
parent
e192038045
commit
2074ac93ba
2 changed files with 39 additions and 4 deletions
26
spec/controllers/stats_controller_spec.rb
Normal file
26
spec/controllers/stats_controller_spec.rb
Normal file
|
@ -0,0 +1,26 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe StatsController, type: :controller do
|
||||
describe '#thirty_days_flow_hash' do
|
||||
before do
|
||||
FactoryGirl.create(:procedure, :created_at => 45.days.ago)
|
||||
FactoryGirl.create(:procedure, :created_at => 15.days.ago)
|
||||
FactoryGirl.create(:procedure, :created_at => 1.day.ago)
|
||||
|
||||
@expected_hash = {}
|
||||
(15.days.ago.to_date..1.day.ago.to_date).each do |day|
|
||||
if [15.days.ago.to_date, 1.day.ago.to_date].include?(day)
|
||||
@expected_hash[day] = 1
|
||||
else
|
||||
@expected_hash[day] = 0
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
let (:association) { Procedure.all }
|
||||
|
||||
subject { StatsController.new.send(:thirty_days_flow_hash, association) }
|
||||
|
||||
it { expect(subject).to eq(@expected_hash) }
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue