DEV: prevents time difference causing flaky spec (#12108)

This commit is contained in:
Joffrey JAFFEUX
2021-02-17 10:04:25 +01:00
committed by GitHub
parent 237d172fd9
commit 7cad5dfa83
2 changed files with 2 additions and 2 deletions

View File

@ -1612,12 +1612,12 @@ describe Topic do
describe 'when new category is set to auto close by default' do describe 'when new category is set to auto close by default' do
before do before do
freeze_time
new_category.update!(auto_close_hours: 5) new_category.update!(auto_close_hours: 5)
topic.user.update!(admin: true) topic.user.update!(admin: true)
end end
it 'should set a topic timer' do it 'should set a topic timer' do
freeze_time
now = Time.zone.now now = Time.zone.now
expect { topic.change_category_to_id(new_category.id) } expect { topic.change_category_to_id(new_category.id) }

View File

@ -2,7 +2,7 @@
RSpec::Matchers.define :be_within_one_second_of do |expected_time| RSpec::Matchers.define :be_within_one_second_of do |expected_time|
match do |actual_time| match do |actual_time|
(actual_time - expected_time).abs < 1 (actual_time - expected_time).abs <= 1
end end
failure_message do |actual_time| failure_message do |actual_time|
"#{actual_time} is not within 1 second of #{expected_time}" "#{actual_time} is not within 1 second of #{expected_time}"