Commit 48e17e20 authored by Dmytro Zaporozhets's avatar Dmytro Zaporozhets

Merge branch '202072-fix-flaky-examples' into 'master'

Sign-out current user when calling `sign_in` in tests and fix an example that only passes on retry

Closes #202072

See merge request gitlab-org/gitlab!24454
parents 9c7d2400 93a16eaf
......@@ -96,7 +96,7 @@ describe GroupsController do
User.where(id: [admin, owner, maintainer, developer, guest]).update_all(can_create_group: can_create_group_status)
end
[:admin, :owner].each do |member_type|
[:admin, :owner, :maintainer].each do |member_type|
context "and logged in as #{member_type.capitalize}" do
it_behaves_like 'member with ability to create subgroups' do
let(:member) { send(member_type) }
......@@ -104,7 +104,7 @@ describe GroupsController do
end
end
[:guest, :developer, :maintainer].each do |member_type|
[:guest, :developer].each do |member_type|
context "and logged in as #{member_type.capitalize}" do
it_behaves_like 'member without ability to create subgroups' do
let(:member) { send(member_type) }
......
# 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)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment