diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-19 01:45:44 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-19 01:45:44 +0000 |
commit | 85dc423f7090da0a52c73eb66faf22ddb20efff9 (patch) | |
tree | 9160f299afd8c80c038f08e1545be119f5e3f1e1 /spec/controllers/projects_controller_spec.rb | |
parent | 15c2c8c66dbe422588e5411eee7e68f1fa440bb8 (diff) | |
download | gitlab-ce-85dc423f7090da0a52c73eb66faf22ddb20efff9.tar.gz |
Add latest changes from gitlab-org/gitlab@13-4-stable-ee
Diffstat (limited to 'spec/controllers/projects_controller_spec.rb')
-rw-r--r-- | spec/controllers/projects_controller_spec.rb | 43 |
1 files changed, 36 insertions, 7 deletions
diff --git a/spec/controllers/projects_controller_spec.rb b/spec/controllers/projects_controller_spec.rb index e59493827ba..e4374a8f104 100644 --- a/spec/controllers/projects_controller_spec.rb +++ b/spec/controllers/projects_controller_spec.rb @@ -555,26 +555,55 @@ RSpec.describe ProjectsController do end shared_examples_for 'updating a project' do + context 'when there is a conflicting project path' do + let(:random_name) { "project-#{SecureRandom.hex(8)}" } + let!(:conflict_project) { create(:project, name: random_name, path: random_name, namespace: project.namespace) } + + it 'does not show any references to the conflicting path' do + expect { update_project(path: random_name) }.not_to change { project.reload.path } + + expect(response).to have_gitlab_http_status(:ok) + expect(response.body).not_to include(random_name) + end + end + context 'when only renaming a project path' do - it "sets the repository to the right path after a rename" do + it "doesnt change the disk_path when using hashed storage" do + skip unless project.hashed_storage?(:repository) + + hashed_storage_path = ::Storage::Hashed.new(project).disk_path original_repository_path = Gitlab::GitalyClient::StorageSettings.allow_disk_access do project.repository.path end - expect { update_project path: 'renamed_path' } - .to change { project.reload.path } + expect { update_project path: 'renamed_path' }.to change { project.reload.path } expect(project.path).to include 'renamed_path' assign_repository_path = Gitlab::GitalyClient::StorageSettings.allow_disk_access do assigns(:repository).path end - if project.hashed_storage?(:repository) - expect(assign_repository_path).to eq(original_repository_path) - else - expect(assign_repository_path).to include(project.path) + expect(original_repository_path).to include(hashed_storage_path) + expect(assign_repository_path).to include(hashed_storage_path) + end + + it "upgrades and move project to hashed storage when project was originally legacy" do + skip if project.hashed_storage?(:repository) + + hashed_storage_path = Storage::Hashed.new(project).disk_path + original_repository_path = Gitlab::GitalyClient::StorageSettings.allow_disk_access do + project.repository.path + end + + expect { update_project path: 'renamed_path' }.to change { project.reload.path } + expect(project.path).to include 'renamed_path' + + assign_repository_path = Gitlab::GitalyClient::StorageSettings.allow_disk_access do + assigns(:repository).path end + expect(original_repository_path).not_to include(hashed_storage_path) + expect(assign_repository_path).to include(hashed_storage_path) expect(response).to have_gitlab_http_status(:found) end end |