Commit acd573f1 authored by Jose Ivan Vargas's avatar Jose Ivan Vargas

minor adjustments to the specs

parent fbde5e33
...@@ -12,7 +12,7 @@ module Projects ...@@ -12,7 +12,7 @@ module Projects
TransferError = Class.new(StandardError) TransferError = Class.new(StandardError)
def execute(new_namespace) def execute(new_namespace)
if allowed_transfer?(current_user, project, new_namespace) if !new_namespace.blank? && allowed_transfer?(current_user, project, new_namespace)
transfer(project, new_namespace) transfer(project, new_namespace)
else else
error_message = if new_namespace.blank? error_message = if new_namespace.blank?
......
...@@ -229,23 +229,22 @@ describe ProjectsController do ...@@ -229,23 +229,22 @@ describe ProjectsController do
describe '#transfer' do describe '#transfer' do
render_views render_views
subject(:project) { create(:project) } let(:project) { create(:project) }
let(:admin) { create(:admin) } let(:admin) { create(:admin) }
let(:new_namespace) { create(:namespace) } let(:new_namespace) { create(:namespace) }
it 'updates namespace' do it 'updates namespace' do
controller.instance_variable_set(:@project, project)
sign_in(admin) sign_in(admin)
put :transfer, put :transfer,
namespace_id: project.namespace.id, namespace_id: project.namespace.path,
new_namespace_id: new_namespace.id, new_namespace_id: new_namespace.id,
id: project.id, id: project.path,
format: :js format: :js
project.reload project.reload
expect(project.namespace.id).to eq(new_namespace.id) expect(project.namespace).to eq(new_namespace)
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
end end
...@@ -254,18 +253,18 @@ describe ProjectsController do ...@@ -254,18 +253,18 @@ describe ProjectsController do
controller.instance_variable_set(:@project, project) controller.instance_variable_set(:@project, project)
sign_in(admin) sign_in(admin)
old_namespace_id = project.namespace.id old_namespace = project.namespace
put :transfer, put :transfer,
namespace_id: old_namespace_id, namespace_id: old_namespace.path,
new_namespace_id: nil, new_namespace_id: nil,
id: project.id, id: project.path,
format: :js format: :js
project.reload project.reload
expect(project.namespace.id).to eq(old_namespace_id) expect(project.namespace).to eq(old_namespace)
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(flash[:alert]).to eq 'Please select a new namespace for your project.' expect(flash[:alert]).to eq 'Please select a new namespace for your project.'
end end
end end
......
...@@ -26,7 +26,7 @@ describe Projects::TransferService, services: true do ...@@ -26,7 +26,7 @@ describe Projects::TransferService, services: true do
it { expect(@result).to eq false } it { expect(@result).to eq false }
it { expect(project.namespace).to eq(user.namespace) } it { expect(project.namespace).to eq(user.namespace) }
it { expect(project.errors.messages[:new_namespace][0]).to eq 'Please select a new namespace for your project.' } it { expect(project.errors.messages[:new_namespace].first).to eq 'Please select a new namespace for your project.' }
end end
context 'disallow transfering of project with tags' do context 'disallow transfering of project with tags' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment