gitlab-org--gitlab-foss/spec/services/projects/transfer_service_spec.rb

42 lines
1.1 KiB
Ruby
Raw Normal View History

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
allow_any_instance_of(Gitlab::UploadsTransfer).
to receive(:move_project).and_return(true)
group.add_owner(user)
2015-07-02 10:47:15 -04:00
@result = transfer_project(project, user, group)
end
it { expect(@result).to be_truthy }
it { expect(project.namespace).to eq(group) }
end
context 'namespace -> no namespace' do
before do
2015-07-02 10:47:15 -04:00
@result = transfer_project(project, user, nil)
end
it { expect(@result).to eq false }
it { expect(project.namespace).to eq(user.namespace) }
end
context 'namespace -> not allowed namespace' do
before do
2015-07-02 10:47:15 -04:00
@result = transfer_project(project, user, group)
end
it { expect(@result).to eq false }
it { expect(project.namespace).to eq(user.namespace) }
end
2015-07-02 10:47:15 -04:00
def transfer_project(project, user, new_namespace)
Projects::TransferService.new(project, user).execute(new_namespace)
end
end