Commit a4af2a5f authored by Thong Kuah's avatar Thong Kuah

Fix date-based failure by freezing time in the specs

Previously we only froze time while creating the namespace. We also need
to freeze time when running reset_date because that attempted to lazily
create a new Ci::Minutes::NamespaceMonthlyUsage for the current month
parent eea9ad53
...@@ -238,16 +238,16 @@ RSpec.describe Ci::Minutes::Quota do ...@@ -238,16 +238,16 @@ RSpec.describe Ci::Minutes::Quota do
describe '#reset_date' do describe '#reset_date' do
subject(:reset_date) { quota.reset_date } subject(:reset_date) { quota.reset_date }
let(:current_time) { Date.new(2021, 10, 14) } around do |example|
travel_to(Date.new(2021, 07, 14)) { example.run }
end
let(:namespace) do let(:namespace) do
travel_to(current_time) do create(:namespace, :with_ci_minutes)
create(:namespace, :with_ci_minutes)
end
end end
it 'corresponds to the beginning of the current month' do it 'corresponds to the beginning of the current month' do
expect(reset_date).to eq(Date.new(2021, 10, 1)) expect(reset_date).to eq(Date.new(2021, 07, 1))
end end
context 'when feature flag ci_use_new_monthly_minutes is disabled' do context 'when feature flag ci_use_new_monthly_minutes is disabled' do
...@@ -256,7 +256,7 @@ RSpec.describe Ci::Minutes::Quota do ...@@ -256,7 +256,7 @@ RSpec.describe Ci::Minutes::Quota do
end end
it 'corresponds to the current time' do it 'corresponds to the current time' do
expect(reset_date).to eq(current_time) expect(reset_date).to eq(Date.new(2021, 07, 14))
end end
end end
end end
......
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