2017-07-09 04:51:59 -04:00
|
|
|
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:)
|
2018-01-09 11:47:31 -05:00
|
|
|
env = env_from_context(context)
|
2017-07-09 04:51:59 -04:00
|
|
|
|
|
|
|
env['devise.mapping'] = Devise.mappings[:user] if env
|
|
|
|
end
|
2018-01-09 11:47:31 -05:00
|
|
|
|
|
|
|
def env_from_context(context)
|
|
|
|
if context.respond_to?(:env_config)
|
|
|
|
context.env_config
|
|
|
|
elsif context.respond_to?(:env)
|
|
|
|
context.env
|
|
|
|
end
|
|
|
|
end
|
2017-07-09 04:51:59 -04:00
|
|
|
end
|