diff --git a/test/test_helper.rb b/test/test_helper.rb index 420fee2ef..040066c49 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -60,6 +60,15 @@ class ActiveSupport::TestCase self.use_transactional_tests = true self.use_instantiated_fixtures = false + # Freeze the clock for the whole run so that fixtures (e.g. `1.minute.ago`) + # and tests share the same "now" even if the date changes mid-run. + FROZEN_TIME = Time.now + + def before_setup + travel_to FROZEN_TIME + super + end + setup do Redmine::SudoMode.stubs(:enabled?).returns(false) end