diff options
author | Bernhard Kaindl <bkl@use.startmail.com> | 2014-10-04 13:44:20 +0400 |
---|---|---|
committer | Bernhard Kaindl <bkl@use.startmail.com> | 2014-10-04 14:29:24 +0400 |
commit | 84fbd2935197c545703541e24d453f6e723293bf (patch) | |
tree | c054a9f90a7fa0963b338f8c85fd963f0fec9a3e /spec/services/projects | |
parent | ac71c386f98fa9b88381abbf9d20e79f57bd7957 (diff) |
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)
Diffstat (limited to 'spec/services/projects')
-rw-r--r-- | spec/services/projects/transfer_service_spec.rb | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/spec/services/projects/transfer_service_spec.rb b/spec/services/projects/transfer_service_spec.rb index 2508dfc4565..79d0526ff89 100644 --- a/spec/services/projects/transfer_service_spec.rb +++ b/spec/services/projects/transfer_service_spec.rb @@ -3,15 +3,12 @@ require 'spec_helper' 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 @@ describe Projects::TransferService do 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 |