diff options
author | Nick Thomas <nick@gitlab.com> | 2018-01-23 22:03:02 +0300 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2018-02-05 13:38:57 +0300 |
commit | 30a43b7e04b98616f379bdd800532c3354df8b19 (patch) | |
tree | 62711e0084cf584b350469e41f5a02e5654de427 /spec/models/project_spec.rb | |
parent | f5990e444a98dc259e2af8c373910cd9ec15b0bd (diff) |
Fix export removal for hashed-storage projects within a renamed or deleted namespace
Diffstat (limited to 'spec/models/project_spec.rb')
-rw-r--r-- | spec/models/project_spec.rb | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index df4c796c61e..da940571bc1 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -2503,6 +2503,37 @@ describe Project do end end + describe '#remove_exports' do + let(:project) { create(:project, :with_export) } + + it 'removes the exports directory for the project' do + expect(File.exist?(project.export_path)).to be_truthy + + allow(FileUtils).to receive(:rm_rf).and_call_original + expect(FileUtils).to receive(:rm_rf).with(project.export_path).and_call_original + project.remove_exports + + expect(File.exist?(project.export_path)).to be_falsy + end + + it 'is a no-op when there is no namespace' do + export_path = project.export_path + project.update_column(:namespace_id, nil) + + expect(FileUtils).not_to receive(:rm_rf).with(export_path) + + project.remove_exports + + expect(File.exist?(export_path)).to be_truthy + end + + it 'is run when the project is destroyed' do + expect(project).to receive(:remove_exports).and_call_original + + project.destroy + end + end + describe '#forks_count' do it 'returns the number of forks' do project = build(:project) |