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:
Diffstat (limited to 'spec/controllers/projects_controller_spec.rb')
-rw-r--r--spec/controllers/projects_controller_spec.rb68
1 files changed, 63 insertions, 5 deletions
diff --git a/spec/controllers/projects_controller_spec.rb b/spec/controllers/projects_controller_spec.rb
index dea359e8fee..88d9d1228e3 100644
--- a/spec/controllers/projects_controller_spec.rb
+++ b/spec/controllers/projects_controller_spec.rb
@@ -362,6 +362,25 @@ RSpec.describe ProjectsController, feature_category: :groups_and_projects do
end
end
+ context 'when project default branch is corrupted' do
+ let_it_be(:corrupted_project) { create(:project, :small_repo, :public) }
+
+ before do
+ sign_in(user)
+
+ expect_next_instance_of(Repository) do |repository|
+ expect(repository).to receive(:root_ref).and_raise(Gitlab::Git::CommandError, 'get default branch').twice
+ end
+ end
+
+ it 'renders the missing default branch view' do
+ get :show, params: { namespace_id: corrupted_project.namespace, id: corrupted_project }
+
+ expect(response).to render_template('projects/missing_default_branch')
+ expect(response).to have_gitlab_http_status(:service_unavailable)
+ end
+ end
+
context "rendering default project view" do
let_it_be(:public_project) { create(:project, :public, :repository) }
@@ -873,12 +892,50 @@ RSpec.describe ProjectsController, feature_category: :groups_and_projects do
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 }
+ let(:message) { 'UpdateProject|Cannot rename project because it contains container registry tags!' }
- expect(controller).to set_flash[:alert].to(s_('UpdateProject|Cannot rename project because it contains container registry tags!'))
- expect(response).to have_gitlab_http_status(:ok)
+ shared_examples 'not allowing the rename of the project' do
+ 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(s_(message))
+ expect(response).to have_gitlab_http_status(:ok)
+ end
+ end
+
+ context 'when Gitlab API is not supported' do
+ before do
+ allow(ContainerRegistry::GitlabApiClient).to receive(:supports_gitlab_api?).and_return(false)
+ end
+
+ it_behaves_like 'not allowing the rename of the project'
+ end
+
+ context 'when Gitlab API is supported' do
+ before do
+ allow(ContainerRegistry::GitlabApiClient).to receive(:supports_gitlab_api?).and_return(true)
+ end
+
+ it 'allows the rename of the project' do
+ allow(ContainerRegistry::GitlabApiClient).to receive(:rename_base_repository_path).and_return(:accepted, :ok)
+
+ expect { update_project path: 'renamed_path' }
+ .to change { project.reload.path }
+
+ expect(project.path).to eq('renamed_path')
+ expect(response).to have_gitlab_http_status(:found)
+ end
+
+ context 'when rename base repository dry run in the registry fails' do
+ let(:message) { 'UpdateProject|UpdateProject|Cannot rename project, the container registry path rename validation failed: Bad Request' }
+
+ before do
+ allow(ContainerRegistry::GitlabApiClient).to receive(:rename_base_repository_path).and_return(:bad_request)
+ end
+
+ it_behaves_like 'not allowing the rename of the project'
+ end
end
end
@@ -1036,6 +1093,7 @@ RSpec.describe ProjectsController, feature_category: :groups_and_projects do
monitor_access_level
infrastructure_access_level
model_experiments_access_level
+ model_registry_access_level
]
end