Commit 1ad78be9 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'transfer-service-spec-cleanups' into 'master'

Transfer service spec cleanups

Simplify the current tests for Projects::TransferService

See merge request !208
parents c71792d9 84fbd293
...@@ -3,15 +3,12 @@ require 'spec_helper' ...@@ -3,15 +3,12 @@ require 'spec_helper'
describe Projects::TransferService do describe Projects::TransferService do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:group) { create(:group) } let(:group) { create(:group) }
let(:group2) { create(:group) }
let(:project) { create(:project, namespace: user.namespace) } let(:project) { create(:project, namespace: user.namespace) }
context 'namespace -> namespace' do context 'namespace -> namespace' do
before do before do
group.add_owner(user) group.add_owner(user)
@service = Projects::TransferService.new(project, user, namespace_id: group.id) @result = transfer_project(project, user, namespace_id: group.id)
@service.gitlab_shell.stub(mv_repository: true)
@result = @service.execute
end end
it { @result.should be_true } it { @result.should be_true }
...@@ -20,24 +17,25 @@ describe Projects::TransferService do ...@@ -20,24 +17,25 @@ describe Projects::TransferService do
context 'namespace -> no namespace' do context 'namespace -> no namespace' do
before do before do
group.add_owner(user) @result = transfer_project(project, user, namespace_id: nil)
@service = Projects::TransferService.new(project, user, namespace_id: nil)
@service.gitlab_shell.stub(mv_repository: true)
@result = @service.execute
end end
it { @result.should_not be_nil } # { result.should be_false } passes on nil
it { @result.should be_false } it { @result.should be_false }
it { project.namespace.should == user.namespace } it { project.namespace.should == user.namespace }
end end
context 'namespace -> not allowed namespace' do context 'namespace -> not allowed namespace' do
before do before do
@service = Projects::TransferService.new(project, user, namespace_id: group2.id) @result = transfer_project(project, user, namespace_id: group.id)
@service.gitlab_shell.stub(mv_repository: true)
@result = @service.execute
end end
it { @result.should_not be_nil } # { result.should be_false } passes on nil
it { @result.should be_false } it { @result.should be_false }
it { project.namespace.should == user.namespace } it { project.namespace.should == user.namespace }
end end
def transfer_project(project, user, params)
Projects::TransferService.new(project, user, params).execute
end
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