Commit 85558db7 authored by Małgorzata Ksionek's avatar Małgorzata Ksionek

Refactor membership action

Add differentiating between groups with minimal_access_role
switched on and not.
parent a64c12bc
......@@ -105,7 +105,7 @@ module MembershipActions
# rubocop: enable CodeReuse/ActiveRecord
def resend_invite
member = membershipable.all_group_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')
......@@ -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
......@@ -209,16 +209,24 @@ RSpec.describe Groups::GroupMembersController do
describe 'POST #resend_invite' do
context 'when user has minimal access' do
let(:membership) { create(:group_member, group: group, access_level: GroupMember::MINIMAL_ACCESS) }
let(:membership) { create(:group_member, :minimal_access, source: group, user: create(:user)) }
before do
stub_licensed_features(minimal_access_role: true)
it 'is not successful' do
post :resend_invite, params: { group_id: group, id: membership }
expect(response).to have_gitlab_http_status(:not_found)
end
it 'is successful' do
post :resend_invite, params: { group_id: group, id: membership }
context 'when minimal_access_role feture is available' do
before do
stub_licensed_features(minimal_access_role: true)
end
expect(response).to have_gitlab_http_status(:found)
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
......
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