Files
devise/test/rails_app/config/application.rb
Carlos Antonio da Silva dd7ee27f74 Bring back Mongoid official support (#5568)
Devise hasn't been tested with Mongoid since Rails version 5, only 4.x was still running those tests.

This enables the tests again on all currently supported Rails versions, with their respective mongoid supported versions. There were a couple of minor tweaks to make it happen, namely:

* The way we were dropping the session before doesn't work in later versions so I changed back to calling `purge!` which appears to work fine. We used to call `Mongoid.purge!` but that changed in #4686.
* Some of the configs in the Rails test app were setting Active Record values when outside of the AR ORM tests, updated those to make sure they are not set when running mongoid ORM tests.
* The validations added to the shared admin code in tests were only checking for Rails version 5.1, but we need to use the same check for AR 5.1 that is used in code, otherwise it will try to use methods not available in mongoid there.
2025-10-31 11:16:02 -03:00

54 lines
1.5 KiB
Ruby

# frozen_string_literal: true
require File.expand_path('../boot', __FILE__)
require "logger"
require "action_controller/railtie"
require "action_mailer/railtie"
require "rails/test_unit/railtie"
Bundler.require :default, DEVISE_ORM
begin
require "#{DEVISE_ORM}/railtie"
rescue LoadError
end
require "devise"
module RailsApp
class Application < Rails::Application
# Add additional load paths for your own custom dirs
config.autoload_paths.reject!{ |p| p =~ /\/app\/(\w+)$/ && !%w(controllers helpers mailers views).include?($1) }
config.autoload_paths += ["#{config.root}/app/#{DEVISE_ORM}"]
# Configure generators values. Many other options are available, be sure to check the documentation.
# config.generators do |g|
# g.orm :active_record
# g.template_engine :erb
# g.test_framework :test_unit, fixture: true
# end
# Configure sensitive parameters which will be filtered from the log file.
config.filter_parameters << :password
# config.assets.enabled = false
config.action_mailer.default_url_options = { host: "localhost", port: 3000 }
# This was used to break devise in some situations
config.to_prepare do
Devise::SessionsController.layout "application"
end
if DEVISE_ORM == :active_record
if Devise::Test.rails70?
config.active_record.legacy_connection_handling = false
end
end
if Devise::Test.rails70_and_up?
config.active_support.cache_format_version = 7.0
end
end
end