mirror of
https://github.com/discourse/discourse.git
synced 2025-06-06 03:06:53 +08:00
DEV: prevents time difference causing flaky spec (#12108)
This commit is contained in:
@ -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) }
|
||||||
|
@ -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}"
|
||||||
|
Reference in New Issue
Block a user