Commit 54a14ad6 authored by charlie ablett's avatar charlie ablett

Merge branch 'group-destroy-worker-owner-blocked' into 'master'

Return error message when deleting group with no active owners

See merge request gitlab-org/gitlab!78500
parents c0fb41fb 72d3dcf6
...@@ -11,11 +11,15 @@ module Groups ...@@ -11,11 +11,15 @@ module Groups
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
def execute def execute
# TODO - add a policy check here https://gitlab.com/gitlab-org/gitlab/-/issues/353082
raise DestroyError, "You can't delete this group because you're blocked." if current_user.blocked?
group.prepare_for_destroy group.prepare_for_destroy
group.projects.includes(:project_feature).each do |project| group.projects.includes(:project_feature).each do |project|
# Execute the destruction of the models immediately to ensure atomic cleanup. # Execute the destruction of the models immediately to ensure atomic cleanup.
success = ::Projects::DestroyService.new(project, current_user).execute success = ::Projects::DestroyService.new(project, current_user).execute
raise DestroyError, "Project #{project.id} can't be deleted" unless success raise DestroyError, "Project #{project.id} can't be deleted" unless success
end end
......
...@@ -112,6 +112,17 @@ RSpec.describe Groups::DestroyService do ...@@ -112,6 +112,17 @@ RSpec.describe Groups::DestroyService do
end end
end end
context 'when group owner is blocked' do
before do
user.block!
end
it 'returns a more descriptive error message' do
expect { destroy_group(group, user, false) }
.to raise_error(Groups::DestroyService::DestroyError, "You can't delete this group because you're blocked.")
end
end
describe 'repository removal' do describe 'repository removal' do
before do before do
destroy_group(group, user, false) destroy_group(group, user, false)
......
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