Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorSean McGivern <sean@mcgivern.me.uk>2017-08-17 14:44:35 +0300
committerSean McGivern <sean@mcgivern.me.uk>2017-08-17 14:44:35 +0300
commitfe0ffcc78941bf9de98e3698e743c3cbb9846b6a (patch)
treeb5d5e12a6c3ccacacaa3507abd307c7dc068efd2 /spec
parent7e13bb9af391fe0f6cf87a44e5908a640a832313 (diff)
parentc9856e53ea05374dcab0a591bd0352d321120b68 (diff)
Merge branch '35072-fix-pages-delete' into 'master'
Resolve "Deleting of a GitLab Pages project results in "`PagesWorker.perform_in` cannot be called inside a transaction"" Closes #35072 See merge request !13631
Diffstat (limited to 'spec')
-rw-r--r--spec/models/project_spec.rb38
1 files changed, 38 insertions, 0 deletions
diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb
index eba71ba2f72..e1d64986a76 100644
--- a/spec/models/project_spec.rb
+++ b/spec/models/project_spec.rb
@@ -2311,6 +2311,44 @@ describe Project do
end
end
+ describe '#remove_pages' do
+ let(:project) { create(:project) }
+ let(:namespace) { project.namespace }
+ let(:pages_path) { project.pages_path }
+
+ around do |example|
+ FileUtils.mkdir_p(pages_path)
+ begin
+ example.run
+ ensure
+ FileUtils.rm_rf(pages_path)
+ end
+ end
+
+ it 'removes the pages directory' do
+ expect_any_instance_of(Projects::UpdatePagesConfigurationService).to receive(:execute)
+ expect_any_instance_of(Gitlab::PagesTransfer).to receive(:rename_project).and_return(true)
+ expect(PagesWorker).to receive(:perform_in).with(5.minutes, :remove, namespace.full_path, anything)
+
+ project.remove_pages
+ end
+
+ it 'is a no-op when there is no namespace' do
+ project.update_column(:namespace_id, nil)
+
+ expect_any_instance_of(Projects::UpdatePagesConfigurationService).not_to receive(:execute)
+ expect_any_instance_of(Gitlab::PagesTransfer).not_to receive(:rename_project)
+
+ project.remove_pages
+ end
+
+ it 'is run when the project is destroyed' do
+ expect(project).to receive(:remove_pages).and_call_original
+
+ project.destroy
+ end
+ end
+
describe '#forks_count' do
it 'returns the number of forks' do
project = build(:project)