gitlab-org--gitlab-foss/spec/support/devise_helpers.rb
Jacopo 0b5133bac2 Extract "@request.env['devise.mapping'] = Devise.mappings[:user]" to a test helper
Extracted `@request.env['devise.mapping'] = Devise.mappings[:user]` and `Rails.application.env_config['devise.mapping'] = Devise.mappings[:user]`
in our tests into the helper method `set_devise_mapping`
2017-07-20 18:36:53 +02:00

14 lines
401 B
Ruby

module DeviseHelpers
# explicitly tells Devise which mapping to use
# this is needed when we are testing a Devise controller bypassing the router
def set_devise_mapping(context:)
env =
if context.respond_to?(:env_config)
context.env_config
elsif context.respond_to?(:env)
context.env
end
env['devise.mapping'] = Devise.mappings[:user] if env
end
end