Commit 84fbd293 authored by Bernhard Kaindl's avatar Bernhard Kaindl
Browse files

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)
parent 926c8c3a3146
......@@ -3,15 +3,12 @@
describe Projects::TransferService do
let(:user) { create(:user) }
let(:group) { create(:group) }
let(:group2) { create(:group) }
let(:project) { create(:project, namespace: user.namespace) }
context 'namespace -> namespace' do
before do
group.add_owner(user)
@service = Projects::TransferService.new(project, user, namespace_id: group.id)
@service.gitlab_shell.stub(mv_repository: true)
@result = @service.execute
@result = transfer_project(project, user, namespace_id: group.id)
end
it { @result.should be_true }
......@@ -20,24 +17,25 @@
context 'namespace -> no namespace' do
before do
group.add_owner(user)
@service = Projects::TransferService.new(project, user, namespace_id: nil)
@service.gitlab_shell.stub(mv_repository: true)
@result = @service.execute
@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
@service = Projects::TransferService.new(project, user, namespace_id: group2.id)
@service.gitlab_shell.stub(mv_repository: true)
@result = @service.execute
@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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment