2014-09-02 18:07:02 +05:30
|
|
|
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)
|
2015-09-11 14:41:01 +05:30
|
|
|
@result = transfer_project(project, user, group)
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|
|
|
|
|
2015-04-26 12:48:37 +05:30
|
|
|
it { expect(@result).to be_truthy }
|
|
|
|
it { expect(project.namespace).to eq(group) }
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
context 'namespace -> no namespace' do
|
|
|
|
before do
|
2015-09-11 14:41:01 +05:30
|
|
|
@result = transfer_project(project, user, nil)
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|
|
|
|
|
2015-09-11 14:41:01 +05:30
|
|
|
it { expect(@result).to eq false }
|
2015-04-26 12:48:37 +05:30
|
|
|
it { expect(project.namespace).to eq(user.namespace) }
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
context 'namespace -> not allowed namespace' do
|
|
|
|
before do
|
2015-09-11 14:41:01 +05:30
|
|
|
@result = transfer_project(project, user, group)
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|
|
|
|
|
2015-09-11 14:41:01 +05:30
|
|
|
it { expect(@result).to eq false }
|
2015-04-26 12:48:37 +05:30
|
|
|
it { expect(project.namespace).to eq(user.namespace) }
|
|
|
|
end
|
|
|
|
|
2015-09-11 14:41:01 +05:30
|
|
|
def transfer_project(project, user, new_namespace)
|
|
|
|
Projects::TransferService.new(project, user).execute(new_namespace)
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|
|
|
|
end
|