diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2017-07-14 15:18:50 +0000 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2017-07-14 15:18:50 +0000 |
commit | 0618ad12e2b50dd01ec1c5ce440345cb64e26133 (patch) | |
tree | 4a72bc4f5477f22557a9d6f47e1e5af5abcea5e0 /spec/controllers | |
parent | 78f7080e8ba4f1c8af80a441f947532fa236312c (diff) | |
parent | bfdd34c52a085cec25b439ed41a3c07901bb9708 (diff) | |
download | gitlab-ce-0618ad12e2b50dd01ec1c5ce440345cb64e26133.tar.gz |
Merge branch 'fix/gb/recover-from-renaming-project-with-container-images' into 'master'
Recover from renaming project that has container images
Closes #23019
See merge request !12840
Diffstat (limited to 'spec/controllers')
-rw-r--r-- | spec/controllers/projects_controller_spec.rb | 41 |
1 files changed, 30 insertions, 11 deletions
diff --git a/spec/controllers/projects_controller_spec.rb b/spec/controllers/projects_controller_spec.rb index f96fe7ad5cb..192cca45d99 100644 --- a/spec/controllers/projects_controller_spec.rb +++ b/spec/controllers/projects_controller_spec.rb @@ -211,24 +211,43 @@ describe ProjectsController do let(:admin) { create(:admin) } let(:project) { create(:project, :repository) } - let(:new_path) { 'renamed_path' } - let(:project_params) { { path: new_path } } before do sign_in(admin) end - it "sets the repository to the right path after a rename" do - controller.instance_variable_set(:@project, project) + context 'when only renaming a project path' do + it "sets the repository to the right path after a rename" do + expect { update_project path: 'renamed_path' } + .to change { project.reload.path } - put :update, - namespace_id: project.namespace, - id: project.id, - project: project_params + expect(project.path).to include 'renamed_path' + expect(assigns(:repository).path).to include project.path + expect(response).to have_http_status(302) + end + end - expect(project.repository.path).to include(new_path) - expect(assigns(:repository).path).to eq(project.repository.path) - expect(response).to have_http_status(302) + context 'when project has container repositories with tags' do + before do + stub_container_registry_config(enabled: true) + stub_container_registry_tags(repository: /image/, tags: %w[rc1]) + create(:container_repository, project: project, name: :image) + end + + it 'does not allow to rename the project' do + expect { update_project path: 'renamed_path' } + .not_to change { project.reload.path } + + expect(controller).to set_flash[:alert].to(/container registry tags/) + expect(response).to have_http_status(200) + end + end + + def update_project(**parameters) + put :update, + namespace_id: project.namespace.path, + id: project.path, + project: parameters end end |