diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 6017ec4dc14..6e61d24b9cb 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -163,6 +163,8 @@ else TestProf::LetItBe.configure { |config| config.alias_to :fab!, refind: true } end +PER_SPEC_TIMEOUT_SECONDS = 30 + RSpec.configure do |config| config.fail_fast = ENV["RSPEC_FAIL_FAST"] == "1" config.silence_filter_announcements = ENV["RSPEC_SILENCE_FILTER_ANNOUNCEMENTS"] == "1" @@ -368,6 +370,16 @@ RSpec.configure do |config| "DiscourseEvent registrations were not cleaned up" end + if ENV["CI"] + config.around do |example| + Timeout.timeout( + PER_SPEC_TIMEOUT_SECONDS, + nil, + "Spec timed out after #{PER_SPEC_TIMEOUT_SECONDS} seconds", + ) { example.run } + end + end + config.before :each do # This allows DB.transaction_open? to work in tests. See lib/mini_sql_multisite_connection.rb DB.test_transaction = ActiveRecord::Base.connection.current_transaction