summaryrefslogtreecommitdiff
path: root/spec/controllers
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-07-13 15:32:31 +0200
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-07-13 15:34:36 +0200
commit613208c360f9f091a9994be2db107a46270e5fe4 (patch)
tree2d2a085bf437c5009ae6f5e5965d070734eb6cf1 /spec/controllers
parente691f5b81207b03f88ec73434db49ee47fa93a4e (diff)
downloadgitlab-ce-613208c360f9f091a9994be2db107a46270e5fe4.tar.gz
Recover from renaming project that has container images
Diffstat (limited to 'spec/controllers')
-rw-r--r--spec/controllers/projects_controller_spec.rb42
1 files changed, 31 insertions, 11 deletions
diff --git a/spec/controllers/projects_controller_spec.rb b/spec/controllers/projects_controller_spec.rb
index f96fe7ad5cb..2a3c382b82c 100644
--- a/spec/controllers/projects_controller_spec.rb
+++ b/spec/controllers/projects_controller_spec.rb
@@ -211,24 +211,44 @@ 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.reload.path).to include 'renamed_path'
+ expect(assigns(:repository).path).to include project.reload.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(project.reload.path).to_not include 'renamed_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