Commit 745b60e4 authored by charlie ablett's avatar charlie ablett

Merge branch '262851-minimal-access-role-resending-member-invite-causes-404' into 'master'

Add the possibility to resend invites to minimal access users

See merge request gitlab-org/gitlab!44936
parents 8ae07187 36d4104d
......@@ -105,7 +105,7 @@ module MembershipActions
# rubocop: enable CodeReuse/ActiveRecord
def resend_invite
member = membershipable.members.find(params[:id])
member = membershipable_members.find(params[:id])
if member.invite?
member.resend_invite
......@@ -122,6 +122,10 @@ module MembershipActions
raise NotImplementedError
end
def membershipable_members
raise NotImplementedError
end
def root_params_key
case membershipable
when Namespace
......
......@@ -71,6 +71,10 @@ class Groups::GroupMembersController < Groups::ApplicationController
def filter_params
params.permit(:two_factor, :search).merge(sort: @sort)
end
def membershipable_members
group.members
end
end
Groups::GroupMembersController.prepend_if_ee('EE::Groups::GroupMembersController')
......@@ -57,6 +57,10 @@ class Projects::ProjectMembersController < Projects::ApplicationController
def filter_params
params.permit(:search).merge(sort: @sort)
end
def membershipable_members
project.members
end
end
Projects::ProjectMembersController.prepend_if_ee('EE::Projects::ProjectMembersController')
---
title: Allow re-sending invite to minimal access user
merge_request: 44936
author:
type: fixed
......@@ -4,6 +4,7 @@ module EE
module Groups
module GroupMembersController
extend ActiveSupport::Concern
extend ::Gitlab::Utils::Override
class_methods do
extend ::Gitlab::Utils::Override
......@@ -49,6 +50,13 @@ module EE
def override_params
params.require(:group_member).permit(:override)
end
override :membershipable_members
def membershipable_members
return super unless group.feature_available?(:minimal_access_role)
group.all_group_members
end
end
end
end
......@@ -206,4 +206,28 @@ RSpec.describe Groups::GroupMembersController do
end
end
end
describe 'POST #resend_invite' do
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 :resend_invite, params: { group_id: group, id: membership }
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 :resend_invite, params: { group_id: group, id: membership }
expect(response).to have_gitlab_http_status(:found)
end
end
end
end
end
......@@ -573,4 +573,19 @@ RSpec.describe Projects::ProjectMembersController do
end
end
end
describe 'POST resend_invite' do
let(:member) { create(:project_member, project: project) }
before do
project.add_maintainer(user)
sign_in(user)
end
it 'is successful' do
post :resend_invite, params: { namespace_id: project.namespace, project_id: project, id: member }
expect(response).to have_gitlab_http_status(:found)
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