Expire the caches of the design repository before rename

parent 02577fb6
...@@ -677,6 +677,17 @@ module EE ...@@ -677,6 +677,17 @@ module EE
end end
end end
override(:expire_caches_before_rename)
def expire_caches_before_rename(old_path)
super
design = ::Repository.new("#{old_path}#{EE::Gitlab::GlRepository::DESIGN.path_suffix}", self)
if design.exists?
design.before_delete
end
end
def alerts_service_available? def alerts_service_available?
feature_available?(:incident_management) feature_available?(:incident_management)
end end
......
...@@ -2383,4 +2383,29 @@ describe Project do ...@@ -2383,4 +2383,29 @@ describe Project do
describe '#license_compliance' do describe '#license_compliance' do
it { expect(subject.license_compliance).to be_instance_of(::SCA::LicenseCompliance) } it { expect(subject.license_compliance).to be_instance_of(::SCA::LicenseCompliance) }
end end
describe '#expire_caches_before_rename' do
let(:project) { create(:project, :repository) }
let(:repo) { double(:repo, exists?: true, before_delete: true) }
let(:wiki) { double(:wiki, exists?: true, before_delete: true) }
let(:design) { double(:design, exists?: true) }
it 'expires the caches of the design repository' do
allow(Repository).to receive(:new)
.with('foo', project)
.and_return(repo)
allow(Repository).to receive(:new)
.with('foo.wiki', project)
.and_return(wiki)
allow(Repository).to receive(:new)
.with('foo.design', project)
.and_return(design)
expect(design).to receive(:before_delete)
project.expire_caches_before_rename('foo')
end
end
end end
...@@ -1793,6 +1793,7 @@ describe Project do ...@@ -1793,6 +1793,7 @@ describe Project do
let(:project) { create(:project, :repository) } let(:project) { create(:project, :repository) }
let(:repo) { double(:repo, exists?: true) } let(:repo) { double(:repo, exists?: true) }
let(:wiki) { double(:wiki, exists?: true) } let(:wiki) { double(:wiki, exists?: true) }
let(:design) { double(:wiki, exists?: false) }
it 'expires the caches of the repository and wiki' do it 'expires the caches of the repository and wiki' do
allow(Repository).to receive(:new) allow(Repository).to receive(:new)
...@@ -1803,6 +1804,10 @@ describe Project do ...@@ -1803,6 +1804,10 @@ describe Project do
.with('foo.wiki', project) .with('foo.wiki', project)
.and_return(wiki) .and_return(wiki)
allow(Repository).to receive(:new)
.with('foo.design', project)
.and_return(design)
expect(repo).to receive(:before_delete) expect(repo).to receive(:before_delete)
expect(wiki).to receive(:before_delete) expect(wiki).to receive(:before_delete)
......
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