summaryrefslogtreecommitdiff
path: root/spec/support/helpers/controller_helpers.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-02-05 18:09:06 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-02-05 18:09:06 +0000
commitb042382bbf5a4977c5b5c6b0a9a33f4e8ca8d16d (patch)
treede31671ab7c6ca8c2a3721cbabd1f2a42b3d0194 /spec/support/helpers/controller_helpers.rb
parenteabf8fd774fef6a54903e5141138f47bdafeb331 (diff)
downloadgitlab-ce-b042382bbf5a4977c5b5c6b0a9a33f4e8ca8d16d.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/support/helpers/controller_helpers.rb')
-rw-r--r--spec/support/helpers/controller_helpers.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/spec/support/helpers/controller_helpers.rb b/spec/support/helpers/controller_helpers.rb
new file mode 100644
index 00000000000..8f5ef8c9696
--- /dev/null
+++ b/spec/support/helpers/controller_helpers.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+module ControllerHelpers
+ # It seems Devise::Test::ControllerHelpers#sign_in doesn't clear out the @current_user
+ # variable of the controller, hence it's not overwritten on retries.
+ # This should be fixed in Devise:
+ # - https://github.com/heartcombo/devise/issues/5190
+ # - https://github.com/heartcombo/devise/pull/5191
+ def sign_in(resource, deprecated = nil, scope: nil)
+ super
+
+ scope ||= Devise::Mapping.find_scope!(resource)
+
+ @controller.instance_variable_set(:"@current_#{scope}", nil)
+ end
+end
+
+Devise::Test::ControllerHelpers.prepend(ControllerHelpers)