Commit 6df5662c authored by Małgorzata Ksionek's avatar Małgorzata Ksionek

Add minimal access egde case to ldap override endpoint

parent ec056fa7
......@@ -26,7 +26,7 @@ module EE
# rubocop:disable Gitlab/ModuleWithInstanceVariables
# rubocop: disable CodeReuse/ActiveRecord
def override
member = @group.members.find_by!(id: params[:id])
member = membershipable_members.find_by!(id: params[:id])
updated_member = ::Members::UpdateService.new(current_user, override_params)
.execute(member, permission: :override)
......
......@@ -60,10 +60,44 @@ RSpec.describe Groups::GroupMembersController do
describe 'POST #override' do
let(:group) { create(:group_with_ldap_group_link) }
it 'is successful' do
before do
allow(Ability).to receive(:allowed?).and_call_original
allow(Ability).to receive(:allowed?).with(user, :override_group_member, membership) { true }
end
it 'is successful' do
post :override,
params: {
group_id: group,
id: membership,
group_member: { override: true }
},
format: :js
expect(response).to have_gitlab_http_status(:ok)
end
context 'when user has minimal access' do
let(:membership) { create(:group_member, :minimal_access, source: group, user: create(:user)) }
it 'is not successful' do
post :override,
params: {
group_id: group,
id: membership,
group_member: { override: true }
},
format: :js
expect(response).to have_gitlab_http_status(:not_found)
end
context 'when minimal_access_role feature is available' do
before do
stub_licensed_features(minimal_access_role: true)
end
it 'is successful' do
post :override,
params: {
group_id: group,
......@@ -76,6 +110,8 @@ RSpec.describe Groups::GroupMembersController do
end
end
end
end
end
describe 'POST request_access' do
before do
......
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