Commit 5dcdf1d5 authored by Rémy Coutable's avatar Rémy Coutable
Browse files

Ensure Members::ApproveAccessRequestService can fin a requester by ID


Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parent cdce66d4d793
......@@ -9,7 +9,7 @@ def request_access
end
def approve_access_request
Members::ApproveAccessRequestService.new(membershipable, current_user, user_id: params[:id]).execute
Members::ApproveAccessRequestService.new(membershipable, current_user, params).execute
redirect_to polymorphic_url([membershipable, :members])
end
......
......@@ -11,7 +11,8 @@ def initialize(source, current_user, params = {})
end
def execute
access_requester = source.requesters.find_by!(user_id: params[:user_id])
condition = params[:user_id] ? { user_id: params[:user_id] } : { id: params[:id] }
access_requester = source.requesters.find_by!(condition)
raise Gitlab::Access::AccessDeniedError if cannot_update_access_requester?(access_requester)
......
......@@ -2,9 +2,10 @@
describe Groups::GroupMembersController do
let(:user) { create(:user) }
let(:group) { create(:group) }
describe '#index' do
let(:group) { create(:group) }
before do
group.add_owner(user)
stub_application_setting(restricted_visibility_levels: [Gitlab::VisibilityLevel::PUBLIC])
......
......@@ -83,6 +83,14 @@
it_behaves_like 'a service approving an access request' do
let(:source) { group }
end
context 'when given a :id' do
let(:params) { { id: project.requesters.find_by!(user_id: access_requester.id).id } }
it_behaves_like 'a service approving an access request' do
let(:source) { project }
end
end
end
end
end
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