db_strategies.rb 773 B

12345678910111213141516171819202122232425262728293031
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. RSpec.configure do |config|
  3. config.around(:each, db_strategy: :reset) do |example|
  4. if MysqlStrategy.db?
  5. self.use_transactional_tests = false
  6. end
  7. example.run
  8. if MysqlStrategy.db?
  9. MysqlStrategy.reset
  10. else
  11. Models.all.each_key do |model|
  12. model.connection.schema_cache.clear!
  13. model.reset_column_information
  14. end
  15. end
  16. end
  17. config.filter_run_excluding db_adapter: lambda { |adapter|
  18. adapter_config = ActiveRecord::Base.connection_db_config.configuration_hash[:adapter]
  19. case adapter
  20. when :postgresql
  21. adapter_config != 'postgresql'
  22. when :mysql
  23. adapter_config != 'mysql2'
  24. else
  25. false
  26. end
  27. }
  28. end