Commit 12543f49 authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Fix time-dependent spec

Freeze time to a specific date because the spec does not work at the
beginning of months since `1.day.ago` will be earlier than
`1.month.ago.end_of_month`.
parent 53613d24
......@@ -11,7 +11,7 @@ RSpec.describe Analytics::DevopsAdoption::Snapshot, type: :model do
describe '.latest_for_namespace_ids' do
it 'returns for previous month finalized snapshot for the given namespace ids based on snapshot end_time' do
freeze_time do
travel_to(Date.new(2021, 07, 15)) do
group1 = create(:group)
group1_latest_snapshot = create(:devops_adoption_snapshot, namespace: group1, end_time: 1.month.ago.end_of_month, recorded_at: 1.day.ago)
create(:devops_adoption_snapshot, namespace: group1, end_time: 2.months.ago.end_of_month, recorded_at: 1.day.ago)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment