gitlab-org--gitlab-foss/spec/services/projects/transfer_service_spec.rb
Vinnie Okada 76aad9b76e Upgrade to Rails 4.1.9
Make the following changes to deal with new behavior in Rails 4.1.2:

* Use nested resources to avoid slashes in arguments to path helpers.
2015-02-14 11:09:23 -07:00

41 lines
1.2 KiB
Ruby

require 'spec_helper'
describe Projects::TransferService do
let(:user) { create(:user) }
let(:group) { create(:group) }
let(:project) { create(:project, namespace: user.namespace) }
context 'namespace -> namespace' do
before do
group.add_owner(user)
@result = transfer_project(project, user, new_namespace_id: group.id)
end
it { expect(@result).to be_truthy }
it { expect(project.namespace).to eq(group) }
end
context 'namespace -> no namespace' do
before do
@result = transfer_project(project, user, new_namespace_id: nil)
end
it { expect(@result).not_to be_nil } # { result.should be_false } passes on nil
it { expect(@result).to be_falsey }
it { expect(project.namespace).to eq(user.namespace) }
end
context 'namespace -> not allowed namespace' do
before do
@result = transfer_project(project, user, new_namespace_id: group.id)
end
it { expect(@result).not_to be_nil } # { result.should be_false } passes on nil
it { expect(@result).to be_falsey }
it { expect(project.namespace).to eq(user.namespace) }
end
def transfer_project(project, user, params)
Projects::TransferService.new(project, user, params).execute
end
end