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/controllers | |
parent | 18a6d9c5326bc2b90a1f0cc8664d638a39885924 (diff) | |
download | gitlab-ce-42604d4c33e6098ba696d464c9a7b3d16656bf54.tar.gz |
Prevent project transfer if a new group is not selected
Diffstat (limited to 'spec/controllers')
-rw-r--r-- | spec/controllers/projects_controller_spec.rb | 45 |
1 files changed, 45 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) } |