مراية لـ
https://github.com/postalserver/postal.git
تم المزامنة 2026-01-18 05:49:47 +00:00
test: add tests for message unqueueing
This adds a comprehensive set of tests for the message unqueueing service. Additionally, it improves how message databases are used for testing environments.
هذا الالتزام موجود في:
@@ -14,8 +14,10 @@ DatabaseCleaner.allow_remote_database_url = true
|
||||
ActiveRecord::Base.logger = Logger.new("/dev/null")
|
||||
|
||||
Dir[File.expand_path("factories/*.rb", __dir__)].each { |f| require f }
|
||||
Dir[File.expand_path("helpers/**/*.rb", __dir__)].each { |f| require f }
|
||||
|
||||
ActiveRecord::Migration.maintain_test_schema!
|
||||
|
||||
RSpec.configure do |config|
|
||||
config.use_transactional_fixtures = true
|
||||
config.infer_spec_type_from_file_location!
|
||||
@@ -25,29 +27,9 @@ RSpec.configure do |config|
|
||||
config.before(:suite) do
|
||||
# Test that the factories are working as they should and then clean up before getting started on
|
||||
# the rest of the suite.
|
||||
begin
|
||||
DatabaseCleaner.start
|
||||
FactoryBot.lint
|
||||
ensure
|
||||
DatabaseCleaner.clean
|
||||
end
|
||||
|
||||
# We're going to create a global server that can be used by any tests.
|
||||
# Because the mail databases don't use any transactions, all data left in the
|
||||
# database will be left there unless removed.
|
||||
DatabaseCleaner.start
|
||||
|
||||
# rubocop:disable Lint/ConstantDefinitionInBlock
|
||||
GLOBAL_SERVER = FactoryBot.create(:server, provision_database: true)
|
||||
# rubocop:enable Lint/ConstantDefinitionInBlock
|
||||
end
|
||||
|
||||
config.after(:suite) do
|
||||
# Remove the global server after the suite has finished running and then
|
||||
# clean the database in case it left anything lying around.
|
||||
if defined?(GLOBAL_SERVER)
|
||||
GLOBAL_SERVER.destroy
|
||||
DatabaseCleaner.clean
|
||||
end
|
||||
FactoryBot.lint
|
||||
ensure
|
||||
DatabaseCleaner.clean
|
||||
end
|
||||
end
|
||||
|
||||
المرجع في مشكلة جديدة
حظر مستخدم