A platform for community discussion. Free, open, simple.
DEV: prevents time difference causing flaky spec (#12108)
Joffrey JAFFEUX7cad5dfa836b
diff --git a/spec/models/topic_spec.rb b/spec/models/topic_spec.rbindex fb451850e07..661ffd24f22 100644--- a/spec/models/topic_spec.rb+++ b/spec/models/topic_spec.rb@@ -1612,12 +1612,12 @@ describe Topic dodescribe 'when new category is set to auto close by default' dobefore do+ freeze_timenew_category.update!(auto_close_hours: 5)topic.user.update!(admin: true)endit 'should set a topic timer' do- freeze_timenow = Time.zone.nowexpect { topic.change_category_to_id(new_category.id) }diff --git a/spec/support/time_matcher.rb b/spec/support/time_matcher.rbindex b578fe38335..360e3eef8b5 100644--- a/spec/support/time_matcher.rb+++ b/spec/support/time_matcher.rb@@ -2,7 +2,7 @@RSpec::Matchers.define :be_within_one_second_of do |expected_time|match do |actual_time|- (actual_time - expected_time).abs < 1+ (actual_time - expected_time).abs <= 1endfailure_message do |actual_time|"#{actual_time} is not within 1 second of #{expected_time}"