mirror of
https://github.com/opf/openproject.git
synced 2026-06-14 03:30:14 +00:00
39 lines
1.1 KiB
Ruby
39 lines
1.1 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
RSpec.configure do |config|
|
|
config.before do
|
|
# Clear any mail deliveries
|
|
# This happens automatically for :mailer specs
|
|
ActionMailer::Base.delivery_method = :test
|
|
ActionMailer::Base.deliveries.clear
|
|
end
|
|
|
|
config.append_after do
|
|
# Cleanup after specs changing locale explicitly or
|
|
# by calling code in the app setting changing the locale.
|
|
I18n.locale = :en unless I18n.locale == :en
|
|
|
|
RequestStore.clear!
|
|
end
|
|
|
|
config.append_after(:all) do
|
|
# Ensure models don't leak between test through RequestStore if it is used in after(:all)
|
|
RequestStore.clear!
|
|
end
|
|
|
|
# We don't want this to be reported on CI as it breaks the build
|
|
unless ENV["CI"]
|
|
config.append_after(:suite) do
|
|
[User.not_builtin, Project, WorkPackage].each do |cls|
|
|
next if cls.count == 0
|
|
|
|
raise <<-EOS
|
|
Your specs left #{cls.count} #{cls.model_name.plural} in the DB
|
|
Did you use before(:all) instead of before
|
|
or forget to kill the instances in a after(:all)?
|
|
EOS
|
|
end
|
|
end
|
|
end
|
|
end
|