diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-12-20 13:37:47 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-12-20 13:37:47 +0000 |
commit | aee0a117a889461ce8ced6fcf73207fe017f1d99 (patch) | |
tree | 891d9ef189227a8445d83f35c1b0fc99573f4380 /spec/controllers/projects_controller_spec.rb | |
parent | 8d46af3258650d305f53b819eabf7ab18d22f59e (diff) | |
download | gitlab-ce-aee0a117a889461ce8ced6fcf73207fe017f1d99.tar.gz |
Add latest changes from gitlab-org/gitlab@14-6-stable-eev14.6.0-rc42
Diffstat (limited to 'spec/controllers/projects_controller_spec.rb')
-rw-r--r-- | spec/controllers/projects_controller_spec.rb | 55 |
1 files changed, 34 insertions, 21 deletions
diff --git a/spec/controllers/projects_controller_spec.rb b/spec/controllers/projects_controller_spec.rb index dafa639a2d5..fd0f9985392 100644 --- a/spec/controllers/projects_controller_spec.rb +++ b/spec/controllers/projects_controller_spec.rb @@ -899,10 +899,34 @@ RSpec.describe ProjectsController do describe '#transfer', :enable_admin_mode do render_views - let_it_be(:project, reload: true) { create(:project) } + let(:project) { create(:project) } + let_it_be(:admin) { create(:admin) } let_it_be(:new_namespace) { create(:namespace) } + shared_examples 'project namespace is not changed' do |flash_message| + it 'project namespace is not changed' do + controller.instance_variable_set(:@project, project) + sign_in(admin) + + old_namespace = project.namespace + + put :transfer, + params: { + namespace_id: old_namespace.path, + new_namespace_id: new_namespace_id, + id: project.path + }, + format: :js + + project.reload + + expect(project.namespace).to eq(old_namespace) + expect(response).to redirect_to(edit_project_path(project)) + expect(flash[:alert]).to eq flash_message + end + end + it 'updates namespace' do sign_in(admin) @@ -917,30 +941,19 @@ RSpec.describe ProjectsController do project.reload expect(project.namespace).to eq(new_namespace) - expect(response).to have_gitlab_http_status(:ok) + expect(response).to redirect_to(edit_project_path(project)) end context 'when new namespace is empty' do - it 'project namespace is not changed' do - controller.instance_variable_set(:@project, project) - sign_in(admin) + let(:new_namespace_id) { nil } - old_namespace = project.namespace - - put :transfer, - params: { - namespace_id: old_namespace.path, - new_namespace_id: nil, - id: project.path - }, - format: :js + it_behaves_like 'project namespace is not changed', s_('TransferProject|Please select a new namespace for your project.') + end - project.reload + context 'when new namespace is the same as the current namespace' do + let(:new_namespace_id) { project.namespace.id } - expect(project.namespace).to eq(old_namespace) - expect(response).to have_gitlab_http_status(:ok) - expect(flash[:alert]).to eq s_('TransferProject|Please select a new namespace for your project.') - end + it_behaves_like 'project namespace is not changed', s_('TransferProject|Project is already in this namespace.') end end @@ -1092,7 +1105,7 @@ RSpec.describe ProjectsController do expect(forked_project.reload.forked?).to be_falsey expect(flash[:notice]).to eq(s_('The fork relationship has been removed.')) - expect(response).to render_template(:remove_fork) + expect(response).to redirect_to(edit_project_path(forked_project)) end end @@ -1108,7 +1121,7 @@ RSpec.describe ProjectsController do format: :js) expect(flash[:notice]).to be_nil - expect(response).to render_template(:remove_fork) + expect(response).to redirect_to(edit_project_path(unforked_project)) end end end |