2022-01-01 13:38:12 +00:00
|
|
|
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
|
2021-06-01 12:20:20 +00:00
|
|
|
|
2018-10-02 14:25:04 +00:00
|
|
|
RSpec.configure do |config|
|
|
|
|
|
2018-10-18 12:20:51 +00:00
|
|
|
config.around(:each, db_strategy: :reset) do |example|
|
2021-07-22 14:01:34 +00:00
|
|
|
if MysqlStrategy.db?
|
2021-03-22 09:45:41 +00:00
|
|
|
self.use_transactional_tests = false
|
|
|
|
end
|
2018-10-02 14:25:04 +00:00
|
|
|
example.run
|
2021-07-22 14:01:34 +00:00
|
|
|
if MysqlStrategy.db?
|
|
|
|
MysqlStrategy.reset
|
|
|
|
else
|
2021-03-22 09:45:41 +00:00
|
|
|
Models.all.each_key do |model|
|
|
|
|
model.connection.schema_cache.clear!
|
|
|
|
model.reset_column_information
|
|
|
|
end
|
|
|
|
end
|
2018-10-02 14:25:04 +00:00
|
|
|
end
|
2022-01-20 10:07:12 +00:00
|
|
|
|
|
|
|
config.filter_run_excluding db_adapter: lambda { |adapter|
|
|
|
|
adapter_config = ActiveRecord::Base.connection_config[:adapter]
|
|
|
|
case adapter
|
|
|
|
when :postgresql
|
|
|
|
adapter_config != 'postgresql'
|
|
|
|
when :mysql
|
|
|
|
adapter_config != 'mysql2'
|
|
|
|
else
|
|
|
|
false
|
|
|
|
end
|
|
|
|
}
|
2018-10-02 14:25:04 +00:00
|
|
|
end
|