Files
gitlabhq/spec/services/projects/transfer_service_spec.rb
T
Bernhard Kaindl 84fbd29351 transfer_service_spec: cleanup, merge common code, check against nil
- replace creation of group2 with the use of group without add_owner(user)
- fold TransferService calls into new test function transfer_project
  - remove currently not used (and not working) gitlab_shell stub
    (will submit testcase simulating failure in gitlab_shell separately)
- add checks against not be_nil (result.should be_false passes even if nil)
2014-10-04 12:29:24 +02:00

42 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, namespace_id: group.id)
end
it { @result.should be_true }
it { project.namespace.should == group }
end
context 'namespace -> no namespace' do
before do
@result = transfer_project(project, user, namespace_id: nil)
end
it { @result.should_not be_nil } # { result.should be_false } passes on nil
it { @result.should be_false }
it { project.namespace.should == user.namespace }
end
context 'namespace -> not allowed namespace' do
before do
@result = transfer_project(project, user, namespace_id: group.id)
end
it { @result.should_not be_nil } # { result.should be_false } passes on nil
it { @result.should be_false }
it { project.namespace.should == user.namespace }
end
def transfer_project(project, user, params)
Projects::TransferService.new(project, user, params).execute
end
end