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 ...@@ -105,7 +105,7 @@ module MembershipActions
# rubocop: enable CodeReuse/ActiveRecord # rubocop: enable CodeReuse/ActiveRecord
def resend_invite def resend_invite
member = membershipable.all_group_members.find(params[:id]) member = membershipable_members.find(params[:id])
if member.invite? if member.invite?
member.resend_invite member.resend_invite
...@@ -122,6 +122,10 @@ module MembershipActions ...@@ -122,6 +122,10 @@ module MembershipActions
raise NotImplementedError raise NotImplementedError
end end
def membershipable_members
raise NotImplementedError
end
def root_params_key def root_params_key
case membershipable case membershipable
when Namespace when Namespace
......
...@@ -71,6 +71,10 @@ class Groups::GroupMembersController < Groups::ApplicationController ...@@ -71,6 +71,10 @@ class Groups::GroupMembersController < Groups::ApplicationController
def filter_params def filter_params
params.permit(:two_factor, :search).merge(sort: @sort) params.permit(:two_factor, :search).merge(sort: @sort)
end end
def membershipable_members
group.members
end
end end
Groups::GroupMembersController.prepend_if_ee('EE::Groups::GroupMembersController') Groups::GroupMembersController.prepend_if_ee('EE::Groups::GroupMembersController')
...@@ -57,6 +57,10 @@ class Projects::ProjectMembersController < Projects::ApplicationController ...@@ -57,6 +57,10 @@ class Projects::ProjectMembersController < Projects::ApplicationController
def filter_params def filter_params
params.permit(:search).merge(sort: @sort) params.permit(:search).merge(sort: @sort)
end end
def membershipable_members
project.members
end
end end
Projects::ProjectMembersController.prepend_if_ee('EE::Projects::ProjectMembersController') Projects::ProjectMembersController.prepend_if_ee('EE::Projects::ProjectMembersController')
...@@ -4,6 +4,7 @@ module EE ...@@ -4,6 +4,7 @@ module EE
module Groups module Groups
module GroupMembersController module GroupMembersController
extend ActiveSupport::Concern extend ActiveSupport::Concern
extend ::Gitlab::Utils::Override
class_methods do class_methods do
extend ::Gitlab::Utils::Override extend ::Gitlab::Utils::Override
...@@ -49,6 +50,13 @@ module EE ...@@ -49,6 +50,13 @@ module EE
def override_params def override_params
params.require(:group_member).permit(:override) params.require(:group_member).permit(:override)
end end
override :membershipable_members
def membershipable_members
return super unless group.feature_available?(:minimal_access_role)
group.all_group_members
end
end end
end end
end end
...@@ -209,16 +209,24 @@ RSpec.describe Groups::GroupMembersController do ...@@ -209,16 +209,24 @@ RSpec.describe Groups::GroupMembersController do
describe 'POST #resend_invite' do describe 'POST #resend_invite' do
context 'when user has minimal access' 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 it 'is not successful' do
stub_licensed_features(minimal_access_role: true) post :resend_invite, params: { group_id: group, id: membership }
expect(response).to have_gitlab_http_status(:not_found)
end end
it 'is successful' do context 'when minimal_access_role feture is available' do
post :resend_invite, params: { group_id: group, id: membership } 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 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