diff options
author | Jose Ivan Vargas <jvargas@gitlab.com> | 2017-05-09 10:09:20 -0500 |
---|---|---|
committer | Jose Ivan Vargas <jvargas@gitlab.com> | 2017-05-22 12:55:01 -0500 |
commit | 42604d4c33e6098ba696d464c9a7b3d16656bf54 (patch) | |
tree | 49ce5e49ff2778ed6b996cdadf1f19d98b288782 /spec | |
parent | 18a6d9c5326bc2b90a1f0cc8664d638a39885924 (diff) | |
download | gitlab-ce-42604d4c33e6098ba696d464c9a7b3d16656bf54.tar.gz |
Prevent project transfer if a new group is not selected
Diffstat (limited to 'spec')
-rw-r--r-- | spec/controllers/projects_controller_spec.rb | 45 | ||||
-rw-r--r-- | spec/services/projects/transfer_service_spec.rb | 1 |
2 files changed, 46 insertions, 0 deletions
diff --git a/spec/controllers/projects_controller_spec.rb b/spec/controllers/projects_controller_spec.rb index a8be6768a47..f117598555b 100644 --- a/spec/controllers/projects_controller_spec.rb +++ b/spec/controllers/projects_controller_spec.rb @@ -226,6 +226,51 @@ describe ProjectsController do end end + describe '#transfer' do + render_views + + subject(:project) { create(:project) } + let(:admin) { create(:admin) } + let(:new_namespace) { create(:namespace) } + + it 'updates namespace' do + controller.instance_variable_set(:@project, project) + sign_in(admin) + + put :transfer, + namespace_id: project.namespace.id, + new_namespace_id: new_namespace.id, + id: project.id, + format: :js + + project.reload + + expect(project.namespace.id).to eq(new_namespace.id) + expect(response).to have_http_status(200) + end + + context 'when new namespace is empty' do + it 'project namespace is not changed' do + controller.instance_variable_set(:@project, project) + sign_in(admin) + + old_namespace_id = project.namespace.id + + put :transfer, + namespace_id: old_namespace_id, + new_namespace_id: nil, + id: project.id, + format: :js + + project.reload + + expect(project.namespace.id).to eq(old_namespace_id) + expect(response).to have_http_status(200) + expect(flash[:alert]).to eq 'Please select a namespace to transfer the project to' + end + end + end + describe "#destroy" do let(:admin) { create(:admin) } diff --git a/spec/services/projects/transfer_service_spec.rb b/spec/services/projects/transfer_service_spec.rb index 29ccce59c53..5c872047bdf 100644 --- a/spec/services/projects/transfer_service_spec.rb +++ b/spec/services/projects/transfer_service_spec.rb @@ -26,6 +26,7 @@ describe Projects::TransferService, services: true do it { expect(@result).to eq false } it { expect(project.namespace).to eq(user.namespace) } + it { expect(project.errors.messages[:new_namespace][0]).to eq 'Please select a namespace to transfer the project to' } end context 'disallow transfering of project with tags' do |