debian-mirror-gitlab/spec/support/devise_helpers.rb

18 lines
456 B
Ruby
Raw Normal View History

2017-09-10 17:25:29 +05:30
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-03-17 18:26:18 +05:30
env = env_from_context(context)
2017-09-10 17:25:29 +05:30
env['devise.mapping'] = Devise.mappings[:user] if env
end
2018-03-17 18:26:18 +05:30
def env_from_context(context)
if context.respond_to?(:env_config)
context.env_config
elsif context.respond_to?(:env)
context.env
end
end
2017-09-10 17:25:29 +05:30
end