Commit dc5b0500 authored by Michael Kozono's avatar Michael Kozono

Merge branch 'da-remove-design-registry-entries' into 'master'

Geo - Remove design registry entries when removing a project on the secondary

See merge request gitlab-org/gitlab!19899
parents 30454d76 ebe37aab
...@@ -35,8 +35,9 @@ module Geo ...@@ -35,8 +35,9 @@ module Geo
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
def destroy_registry_entries def destroy_registry_entries
::Geo::ProjectRegistry.where(project_id: id).delete_all ::Geo::ProjectRegistry.where(project_id: id).delete_all
::Geo::DesignRegistry.where(project_id: id).delete_all
log_info("Project registry entry removed", project_id: id) log_info("Registry entries removed", project_id: id)
end end
# rubocop: enable CodeReuse/ActiveRecord # rubocop: enable CodeReuse/ActiveRecord
......
...@@ -54,10 +54,14 @@ describe Geo::RepositoryDestroyService do ...@@ -54,10 +54,14 @@ describe Geo::RepositoryDestroyService do
service.execute service.execute
end end
it 'removes the tracking entry' do it 'removes the tracking entries' do
create(:geo_project_registry, project: project) create(:geo_project_registry, project: project)
create(:geo_design_registry, project: project)
expect { service.execute }.to change(Geo::ProjectRegistry, :count).by(-1) service.execute
expect(Geo::ProjectRegistry.where(project: project)).to be_empty
expect(Geo::DesignRegistry.where(project: project)).to be_empty
end end
end end
...@@ -92,10 +96,14 @@ describe Geo::RepositoryDestroyService do ...@@ -92,10 +96,14 @@ describe Geo::RepositoryDestroyService do
service.execute service.execute
end end
it 'removes the tracking entry' do it 'removes the tracking entries' do
create(:geo_project_registry, project: project) create(:geo_project_registry, project: project)
create(:geo_design_registry, project: project)
expect { service.execute }.to change(Geo::ProjectRegistry, :count).by(-1) service.execute
expect(Geo::ProjectRegistry.where(project: project)).to be_empty
expect(Geo::DesignRegistry.where(project: project)).to be_empty
end end
end end
...@@ -110,12 +118,14 @@ describe Geo::RepositoryDestroyService do ...@@ -110,12 +118,14 @@ describe Geo::RepositoryDestroyService do
service.execute service.execute
end end
it 'removes the tracking entry' do it 'removes the tracking entries' do
create(:geo_project_registry, project: project) create(:geo_project_registry, project: project)
create(:geo_design_registry, project: project)
expect { service.execute }.to raise_error RuntimeError, 'storage not found: "broken"' expect { service.execute }.to raise_error RuntimeError, 'storage not found: "broken"'
expect(Geo::ProjectRegistry.where(project: project)).to be_empty expect(Geo::ProjectRegistry.where(project: project)).to be_empty
expect(Geo::DesignRegistry.where(project: project)).to be_empty
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