2013-03-12 06:37:53 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe ProjectTransferService do
|
2013-04-10 16:48:40 -04:00
|
|
|
before(:each) { enable_observers }
|
2013-04-25 10:15:33 -04:00
|
|
|
after(:each) {disable_observers}
|
2013-04-10 16:48:40 -04:00
|
|
|
|
2013-03-12 06:37:53 -04:00
|
|
|
context 'namespace -> namespace' do
|
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:group) { create(:group) }
|
|
|
|
let(:project) { create(:project, namespace: user.namespace) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
@result = service.transfer(project, group)
|
|
|
|
end
|
|
|
|
|
|
|
|
it { @result.should be_true }
|
|
|
|
it { project.namespace.should == group }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'namespace -> no namespace' do
|
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:project) { create(:project, namespace: user.namespace) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
@result = service.transfer(project, nil)
|
|
|
|
end
|
|
|
|
|
2013-04-25 10:15:33 -04:00
|
|
|
|
2013-03-12 06:37:53 -04:00
|
|
|
it { @result.should be_true }
|
|
|
|
it { project.namespace.should == nil }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'no namespace -> namespace' do
|
|
|
|
let(:project) { create(:project) }
|
|
|
|
let(:user) { create(:user) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
@result = service.transfer(project, user.namespace)
|
|
|
|
end
|
|
|
|
|
|
|
|
it { @result.should be_true }
|
|
|
|
it { project.namespace.should == user.namespace }
|
|
|
|
end
|
|
|
|
|
|
|
|
def service
|
|
|
|
service = ProjectTransferService.new
|
|
|
|
service.gitlab_shell.stub(mv_repository: true)
|
|
|
|
service
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|