fix(stat): enforce time travel when dealing with relative dates
This commit is contained in:
parent
8b98b3b657
commit
8fc14faa2a
1 changed files with 16 additions and 12 deletions
|
@ -1,3 +1,5 @@
|
||||||
|
include ActiveSupport::Testing::TimeHelpers
|
||||||
|
|
||||||
describe Stat do
|
describe Stat do
|
||||||
describe '.deleted_dossiers_states' do
|
describe '.deleted_dossiers_states' do
|
||||||
subject { Stat.send(:deleted_dossiers_states) }
|
subject { Stat.send(:deleted_dossiers_states) }
|
||||||
|
@ -78,6 +80,7 @@ describe Stat do
|
||||||
|
|
||||||
describe '.last_four_months_hash' do
|
describe '.last_four_months_hash' do
|
||||||
it 'works count and cumulate counters by month for both dossier and deleted dossiers' do
|
it 'works count and cumulate counters by month for both dossier and deleted dossiers' do
|
||||||
|
travel_to Time.zone.local(2021, 11, 25) do
|
||||||
4.downto(1).map do |i|
|
4.downto(1).map do |i|
|
||||||
create(:dossier, state: :en_construction, en_construction_at: i.months.ago)
|
create(:dossier, state: :en_construction, en_construction_at: i.months.ago)
|
||||||
create(:deleted_dossier, dossier_id: i + 100, state: :en_construction, deleted_at: i.month.ago)
|
create(:deleted_dossier, dossier_id: i + 100, state: :en_construction, deleted_at: i.month.ago)
|
||||||
|
@ -93,6 +96,7 @@ describe Stat do
|
||||||
])
|
])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe '.sum_hashes' do
|
describe '.sum_hashes' do
|
||||||
it 'sum up hashes keys' do
|
it 'sum up hashes keys' do
|
||||||
|
|
Loading…
Add table
Reference in a new issue