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
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-08-27 18:10:21 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-08-27 18:10:21 +0300
commiteef9c80f1c3e81fcb50c51d8f419ab095d4747fd (patch)
tree5052967f5239d74e34527e94600621e6c1ebfcc4 /spec/models/namespace_spec.rb
parentd6404862287ded00725865e56cda3a6fb4f2a1c7 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models/namespace_spec.rb')
-rw-r--r--spec/models/namespace_spec.rb117
1 files changed, 99 insertions, 18 deletions
diff --git a/spec/models/namespace_spec.rb b/spec/models/namespace_spec.rb
index f685fe12e13..39ece3d1cb3 100644
--- a/spec/models/namespace_spec.rb
+++ b/spec/models/namespace_spec.rb
@@ -391,14 +391,14 @@ RSpec.describe Namespace do
let(:uploads_dir) { FileUploader.root }
let(:pages_dir) { File.join(TestEnv.pages_path) }
- def expect_project_directories_at(namespace_path)
+ def expect_project_directories_at(namespace_path, with_pages: true)
expected_repository_path = File.join(TestEnv.repos_path, namespace_path, 'the-project.git')
expected_upload_path = File.join(uploads_dir, namespace_path, 'the-project')
expected_pages_path = File.join(pages_dir, namespace_path, 'the-project')
expect(File.directory?(expected_repository_path)).to be_truthy
expect(File.directory?(expected_upload_path)).to be_truthy
- expect(File.directory?(expected_pages_path)).to be_truthy
+ expect(File.directory?(expected_pages_path)).to be(with_pages)
end
before do
@@ -412,7 +412,7 @@ RSpec.describe Namespace do
FileUtils.remove_entry(File.join(TestEnv.repos_path, new_parent.full_path), true)
FileUtils.remove_entry(File.join(TestEnv.repos_path, child.full_path), true)
FileUtils.remove_entry(File.join(uploads_dir, project.full_path), true)
- FileUtils.remove_entry(File.join(pages_dir, project.full_path), true)
+ FileUtils.remove_entry(pages_dir, true)
end
context 'renaming child' do
@@ -426,10 +426,22 @@ RSpec.describe Namespace do
end
end
- it 'correctly moves the repository, uploads and pages', :sidekiq_inline do
- child.update!(path: 'renamed')
+ context 'when no projects have pages deployed' do
+ it 'moves the repository and uploads', :sidekiq_inline do
+ project.pages_metadatum.update!(deployed: false)
+ child.update!(path: 'renamed')
+
+ expect_project_directories_at('parent/renamed', with_pages: false)
+ end
+ end
+
+ context 'when the project has pages deployed' do
+ it 'correctly moves the repository, uploads and pages', :sidekiq_inline do
+ project.pages_metadatum.update!(deployed: true)
+ child.update!(path: 'renamed')
- expect_project_directories_at('parent/renamed')
+ expect_project_directories_at('parent/renamed')
+ end
end
end
@@ -444,10 +456,22 @@ RSpec.describe Namespace do
end
end
- it 'correctly moves the repository, uploads and pages', :sidekiq_inline do
- parent.update!(path: 'renamed')
+ context 'when no projects have pages deployed' do
+ it 'moves the repository and uploads', :sidekiq_inline do
+ project.pages_metadatum.update!(deployed: false)
+ parent.update!(path: 'renamed')
+
+ expect_project_directories_at('renamed/child', with_pages: false)
+ end
+ end
+
+ context 'when the project has pages deployed' do
+ it 'correctly moves the repository, uploads and pages', :sidekiq_inline do
+ project.pages_metadatum.update!(deployed: true)
+ parent.update!(path: 'renamed')
- expect_project_directories_at('renamed/child')
+ expect_project_directories_at('renamed/child')
+ end
end
end
@@ -462,10 +486,22 @@ RSpec.describe Namespace do
end
end
- it 'correctly moves the repository, uploads and pages', :sidekiq_inline do
- child.update!(parent: new_parent)
+ context 'when no projects have pages deployed' do
+ it 'moves the repository and uploads', :sidekiq_inline do
+ project.pages_metadatum.update!(deployed: false)
+ child.update!(parent: new_parent)
+
+ expect_project_directories_at('new_parent/child', with_pages: false)
+ end
+ end
+
+ context 'when the project has pages deployed' do
+ it 'correctly moves the repository, uploads and pages', :sidekiq_inline do
+ project.pages_metadatum.update!(deployed: true)
+ child.update!(parent: new_parent)
- expect_project_directories_at('new_parent/child')
+ expect_project_directories_at('new_parent/child')
+ end
end
end
@@ -480,10 +516,22 @@ RSpec.describe Namespace do
end
end
- it 'correctly moves the repository, uploads and pages', :sidekiq_inline do
- child.update!(parent: nil)
+ context 'when no projects have pages deployed' do
+ it 'moves the repository and uploads', :sidekiq_inline do
+ project.pages_metadatum.update!(deployed: false)
+ child.update!(parent: nil)
+
+ expect_project_directories_at('child', with_pages: false)
+ end
+ end
+
+ context 'when the project has pages deployed' do
+ it 'correctly moves the repository, uploads and pages', :sidekiq_inline do
+ project.pages_metadatum.update!(deployed: true)
+ child.update!(parent: nil)
- expect_project_directories_at('child')
+ expect_project_directories_at('child')
+ end
end
end
@@ -498,10 +546,22 @@ RSpec.describe Namespace do
end
end
- it 'correctly moves the repository, uploads and pages', :sidekiq_inline do
- parent.update!(parent: new_parent)
+ context 'when no projects have pages deployed' do
+ it 'moves the repository and uploads', :sidekiq_inline do
+ project.pages_metadatum.update!(deployed: false)
+ parent.update!(parent: new_parent)
- expect_project_directories_at('new_parent/parent/child')
+ expect_project_directories_at('new_parent/parent/child', with_pages: false)
+ end
+ end
+
+ context 'when the project has pages deployed' do
+ it 'correctly moves the repository, uploads and pages', :sidekiq_inline do
+ project.pages_metadatum.update!(deployed: true)
+ parent.update!(parent: new_parent)
+
+ expect_project_directories_at('new_parent/parent/child')
+ end
end
end
end
@@ -1174,6 +1234,27 @@ RSpec.describe Namespace do
end
end
+ describe '#any_project_with_pages_deployed?' do
+ it 'returns true if any project nested under the group has pages deployed' do
+ parent_1 = create(:group) # Three projects, one with pages
+ child_1_1 = create(:group, parent: parent_1) # Two projects, one with pages
+ child_1_2 = create(:group, parent: parent_1) # One project, no pages
+ parent_2 = create(:group) # No projects
+
+ create(:project, group: child_1_1).tap do |project|
+ project.pages_metadatum.update!(deployed: true)
+ end
+
+ create(:project, group: child_1_1)
+ create(:project, group: child_1_2)
+
+ expect(parent_1.any_project_with_pages_deployed?).to be(true)
+ expect(child_1_1.any_project_with_pages_deployed?).to be(true)
+ expect(child_1_2.any_project_with_pages_deployed?).to be(false)
+ expect(parent_2.any_project_with_pages_deployed?).to be(false)
+ end
+ end
+
describe '#has_parent?' do
it 'returns true when the group has a parent' do
group = create(:group, :nested)