Commit 0f2adf6b authored by Vitali Tatarintev's avatar Vitali Tatarintev

Merge branch 'remove-pipeline-subscriptions-when-migrating-project-to-a-free-group' into 'master'

Delete pipeline subscriptions when migrating project to a free group

See merge request gitlab-org/gitlab!66695
parents 4ffbed29 67223c66
...@@ -49,6 +49,7 @@ module EE ...@@ -49,6 +49,7 @@ module EE
override :remove_paid_features override :remove_paid_features
def remove_paid_features def remove_paid_features
revoke_project_access_tokens revoke_project_access_tokens
delete_pipeline_subscriptions
end end
def revoke_project_access_tokens def revoke_project_access_tokens
...@@ -59,6 +60,12 @@ module EE ...@@ -59,6 +60,12 @@ module EE
.execute .execute
.update_all(revoked: true) .update_all(revoked: true)
end end
def delete_pipeline_subscriptions
return if new_namespace.licensed_feature_available?(:ci_project_subscriptions)
project.upstream_project_subscriptions.destroy_all # rubocop: disable Cop/DestroyAll
end
end end
end end
end end
...@@ -127,14 +127,17 @@ RSpec.describe Projects::TransferService do ...@@ -127,14 +127,17 @@ RSpec.describe Projects::TransferService do
end end
end end
describe 'project access tokens' do describe 'updating paid features' do
let_it_be(:premium_group) { create(:group_with_plan, plan: :premium_plan) } let_it_be(:premium_group) { create(:group_with_plan, plan: :premium_plan) }
let_it_be(:free_group) { create(:group) } let_it_be(:free_group) { create(:group) }
before do before do
premium_group.add_owner(user) premium_group.add_owner(user)
free_group.add_owner(user) free_group.add_owner(user)
end
describe 'project access tokens' do
before do
ResourceAccessTokens::CreateService.new(user, project).execute ResourceAccessTokens::CreateService.new(user, project).execute
end end
...@@ -174,4 +177,32 @@ RSpec.describe Projects::TransferService do ...@@ -174,4 +177,32 @@ RSpec.describe Projects::TransferService do
end end
end end
end end
describe 'pipeline subscriptions' do
let_it_be(:project_2) { create(:project, :public) }
before do
project.upstream_project_subscriptions.create!(upstream_project: project_2)
stub_ee_application_setting(should_check_namespace_plan: true)
end
context 'when target namespace has a premium plan' do
it 'does not delete the pipeline subscriptions' do
subject.execute(premium_group)
expect { subject.execute(premium_group) }.not_to change { project.upstream_project_subscriptions.count }
end
end
context 'when target namespace has a free plan' do
it 'deletes the upstream subscriptions' do
expect { subject.execute(free_group) }.to change { project.upstream_project_subscriptions.count }.from(1).to(0)
end
it 'deletes the downstream subscriptions' do
expect { subject.execute(free_group) }.to change { project_2.downstream_project_subscriptions.count }.from(1).to(0)
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