summaryrefslogtreecommitdiff
path: root/spec/support/devise_helpers.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/support/devise_helpers.rb')
-rw-r--r--spec/support/devise_helpers.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/spec/support/devise_helpers.rb b/spec/support/devise_helpers.rb
new file mode 100644
index 00000000000..890a2d9d287
--- /dev/null
+++ b/spec/support/devise_helpers.rb
@@ -0,0 +1,14 @@
+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