Commit edcbb344 authored by Doug Stull's avatar Doug Stull

Merge branch '352526-feature-flag-cleanup-invite_members_group_modal6' into 'master'

Cleanup invite_members_group_modal - remove group invite actions

See merge request gitlab-org/gitlab!83117
parents 22e02af0 1b3718ab
......@@ -6,24 +6,6 @@ class Groups::GroupLinksController < Groups::ApplicationController
feature_category :subgroups
def create
shared_with_group = Group.find(params[:shared_with_group_id]) if params[:shared_with_group_id].present?
if shared_with_group
result = Groups::GroupLinks::CreateService
.new(group, shared_with_group, current_user, group_link_create_params)
.execute
return render_404 if result[:http_status] == 404
flash[:alert] = result[:message] if result[:status] == :error
else
flash[:alert] = _('Please select a group.')
end
redirect_to group_group_members_path(group)
end
def update
Groups::GroupLinks::UpdateService.new(@group_link).execute(group_link_params)
......@@ -54,10 +36,6 @@ class Groups::GroupLinksController < Groups::ApplicationController
@group_link ||= group.shared_with_group_links.find(params[:id])
end
def group_link_create_params
params.permit(:shared_group_access, :expires_at)
end
def group_link_params
params.require(:group_link).permit(:group_access, :expires_at)
end
......
......@@ -7,21 +7,6 @@ class Projects::GroupLinksController < Projects::ApplicationController
feature_category :subgroups
def create
group = Group.find(params[:link_group_id]) if params[:link_group_id].present?
if group
result = Projects::GroupLinks::CreateService.new(project, current_user, group_link_create_params).execute(group)
return render_404 if result[:http_status] == 404
flash[:alert] = result[:message] if result[:http_status] == 409
else
flash[:alert] = _('Please select a group.')
end
redirect_to project_project_members_path(project)
end
def update
group_link = @project.project_group_links.find(params[:id])
Projects::GroupLinks::UpdateService.new(group_link).execute(group_link_params)
......@@ -54,10 +39,4 @@ class Projects::GroupLinksController < Projects::ApplicationController
def group_link_params
params.require(:group_link).permit(:group_access, :expires_at)
end
def group_link_create_params
params.permit(:link_group_access, :expires_at)
end
end
Projects::GroupLinksController.prepend_mod_with('Projects::GroupLinksController')
......@@ -99,7 +99,7 @@ constraints(::Constraints::GroupUrlConstrainer.new) do
delete :leave, on: :collection
end
resources :group_links, only: [:create, :update, :destroy], constraints: { id: /\d+|:id/ }
resources :group_links, only: [:update, :destroy], constraints: { id: /\d+|:id/ }
resources :uploads, only: [:create] do
collection do
......
......@@ -247,7 +247,7 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
resources :starrers, only: [:index]
resources :forks, only: [:index, :new, :create]
resources :group_links, only: [:create, :update, :destroy], constraints: { id: /\d+|:id/ }
resources :group_links, only: [:update, :destroy], constraints: { id: /\d+|:id/ }
resource :import, only: [:new, :create, :show]
resource :avatar, only: [:show, :destroy]
......
# frozen_string_literal: true
module EE
module Projects
module GroupLinksController
extend ActiveSupport::Concern
prepended do
before_action :authorize_group_share!, only: [:create]
end
protected
def authorize_group_share!
access_denied! unless project.allowed_to_share_with_group?
end
end
end
end
......@@ -27877,9 +27877,6 @@ msgstr ""
msgid "Please select a group"
msgstr ""
msgid "Please select a group."
msgstr ""
msgid "Please select a valid target branch"
msgstr ""
......
......@@ -35,120 +35,6 @@ RSpec.describe Groups::GroupLinksController do
end
end
describe '#create' do
let(:shared_with_group_id) { shared_with_group.id }
let(:shared_group_access) { GroupGroupLink.default_access }
subject do
post(:create,
params: { group_id: shared_group,
shared_with_group_id: shared_with_group_id,
shared_group_access: shared_group_access })
end
shared_examples 'creates group group link' do
it 'links group with selected group' do
expect { subject }.to change { shared_with_group.shared_groups.include?(shared_group) }.from(false).to(true)
end
it 'redirects to group links page' do
subject
expect(response).to(redirect_to(group_group_members_path(shared_group)))
end
it 'allows access for group member' do
expect { subject }.to(
change { group_member.can?(:read_group, shared_group) }.from(false).to(true))
end
end
context 'when user has correct access to both groups' do
before do
shared_with_group.add_developer(user)
shared_group.add_owner(user)
end
context 'when default access level is requested' do
include_examples 'creates group group link'
end
context 'when owner access is requested' do
let(:shared_group_access) { Gitlab::Access::OWNER }
before do
shared_with_group.add_owner(group_member)
end
include_examples 'creates group group link'
it 'allows admin access for group member' do
expect { subject }.to(
change { group_member.can?(:admin_group, shared_group) }.from(false).to(true))
end
end
it 'updates project permissions', :sidekiq_inline do
expect { subject }.to change { group_member.can?(:read_project, project) }.from(false).to(true)
end
context 'when shared with group id is not present' do
let(:shared_with_group_id) { nil }
it 'redirects to group links page' do
subject
expect(response).to(redirect_to(group_group_members_path(shared_group)))
expect(flash[:alert]).to eq('Please select a group.')
end
end
context 'when link is not persisted in the database' do
before do
allow(::Groups::GroupLinks::CreateService).to(
receive_message_chain(:new, :execute)
.and_return({ status: :error,
http_status: 409,
message: 'error' }))
end
it 'redirects to group links page' do
subject
expect(response).to(redirect_to(group_group_members_path(shared_group)))
expect(flash[:alert]).to eq('error')
end
end
end
context 'when user does not have access to the group' do
before do
shared_group.add_owner(user)
end
it 'renders 404' do
subject
expect(response).to have_gitlab_http_status(:not_found)
end
end
context 'when user does not have admin access to the shared group' do
before do
shared_with_group.add_developer(user)
shared_group.add_developer(user)
end
it 'renders 404' do
subject
expect(response).to have_gitlab_http_status(:not_found)
end
end
include_examples 'placeholder is passed as `id` parameter', :create
end
describe '#update' do
let!(:link) do
create(:group_group_link, { shared_group: shared_group,
......
......@@ -18,136 +18,6 @@ RSpec.describe Projects::GroupLinksController do
travel_back
end
describe '#create' do
shared_context 'link project to group' do
before do
post(:create, params: {
namespace_id: project.namespace,
project_id: project,
link_group_id: group.id,
link_group_access: ProjectGroupLink.default_access
})
end
end
context 'when project is not allowed to be shared with a group' do
before do
group.update!(share_with_group_lock: false)
end
include_context 'link project to group'
it 'responds with status 404' do
expect(response).to have_gitlab_http_status(:not_found)
end
end
context 'when user has access to group they want to link project to' do
before do
group.add_developer(user)
end
include_context 'link project to group'
it 'links project with selected group' do
expect(group.shared_projects).to include project
end
it 'redirects to project group links page' do
expect(response).to redirect_to(
project_project_members_path(project)
)
end
end
context 'when user doers not have access to group they want to link to' do
include_context 'link project to group'
it 'renders 404' do
expect(response).to have_gitlab_http_status(:not_found)
end
it 'does not share project with that group' do
expect(group.shared_projects).not_to include project
end
end
context 'when user does not have access to the public group' do
let(:group) { create(:group, :public) }
include_context 'link project to group'
it 'renders 404' do
expect(response).to have_gitlab_http_status(:not_found)
end
it 'does not share project with that group' do
expect(group.shared_projects).not_to include project
end
end
context 'when project group id equal link group id' do
before do
group2.add_developer(user)
post(:create, params: {
namespace_id: project.namespace,
project_id: project,
link_group_id: group2.id,
link_group_access: ProjectGroupLink.default_access
})
end
it 'does not share project with selected group' do
expect(group2.shared_projects).not_to include project
end
it 'redirects to project group links page' do
expect(response).to redirect_to(
project_project_members_path(project)
)
end
end
context 'when link group id is not present' do
before do
post(:create, params: {
namespace_id: project.namespace,
project_id: project,
link_group_access: ProjectGroupLink.default_access
})
end
it 'redirects to project group links page' do
expect(response).to redirect_to(
project_project_members_path(project)
)
expect(flash[:alert]).to eq('Please select a group.')
end
end
context 'when link is not persisted in the database' do
before do
allow(::Projects::GroupLinks::CreateService).to receive_message_chain(:new, :execute)
.and_return({ status: :error, http_status: 409, message: 'error' })
post(:create, params: {
namespace_id: project.namespace,
project_id: project,
link_group_id: group.id,
link_group_access: ProjectGroupLink.default_access
})
end
it 'redirects to project group links page' do
expect(response).to redirect_to(
project_project_members_path(project)
)
expect(flash[:alert]).to eq('error')
end
end
end
describe '#update' do
let_it_be(:link) do
create(
......
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