diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-05-28 19:04:18 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-05-28 19:04:18 +0300 |
commit | 14f78d067d703c20b788498cd90c40903ba9f84e (patch) | |
tree | ce5c66a0862b6f1ed425b183325933d5018c47f3 /spec/services | |
parent | 900d30798b7eef1301978ff6f97b4cee7414b696 (diff) | |
download | gitlab-ce-14f78d067d703c20b788498cd90c40903ba9f84e.tar.gz |
Modify specs for new project transfer code
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'spec/services')
-rw-r--r-- | spec/services/projects/transfer_service_spec.rb | 41 |
1 files changed, 27 insertions, 14 deletions
diff --git a/spec/services/projects/transfer_service_spec.rb b/spec/services/projects/transfer_service_spec.rb index 109b429967e..563a8b0c01c 100644 --- a/spec/services/projects/transfer_service_spec.rb +++ b/spec/services/projects/transfer_service_spec.rb @@ -1,16 +1,20 @@ require 'spec_helper' -describe ProjectTransferService do +describe Projects::TransferService do before(:each) { enable_observers } after(:each) {disable_observers} - context 'namespace -> namespace' do - let(:user) { create(:user) } - let(:group) { create(:group) } - let(:project) { create(:project, namespace: user.namespace) } + 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 - @result = service.transfer(project, group) + group.add_owner(user) + @service = Projects::TransferService.new(project, user, namespace_id: group.id) + @service.gitlab_shell.stub(mv_repository: true) + @result = @service.execute end it { @result.should be_true } @@ -18,16 +22,25 @@ describe ProjectTransferService do end context 'namespace -> no namespace' do - let(:user) { create(:user) } - let(:project) { create(:project, namespace: user.namespace) } + 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 + end - it { lambda{service.transfer(project, nil)}.should raise_error(ActiveRecord::RecordInvalid) } + it { @result.should be_false } + it { project.namespace.should == user.namespace } end - def service - service = ProjectTransferService.new - service.gitlab_shell.stub(mv_repository: true) - service + 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 + end + + it { @result.should be_false } + it { project.namespace.should == user.namespace } end end - |