debian-mirror-gitlab/spec/services/projects/transfer_service_spec.rb

75 lines
2.2 KiB
Ruby
Raw Normal View History

2014-09-02 18:07:02 +05:30
require 'spec_helper'
2015-12-23 02:04:40 +05:30
describe Projects::TransferService, services: true do
2014-09-02 18:07:02 +05:30
let(:user) { create(:user) }
let(:group) { create(:group) }
let(:project) { create(:project, namespace: user.namespace) }
context 'namespace -> namespace' do
before do
2015-10-24 18:46:33 +05:30
allow_any_instance_of(Gitlab::UploadsTransfer).
to receive(:move_project).and_return(true)
2014-09-02 18:07:02 +05:30
group.add_owner(user)
2015-09-11 14:41:01 +05:30
@result = transfer_project(project, user, group)
2014-09-02 18:07:02 +05:30
end
2015-04-26 12:48:37 +05:30
it { expect(@result).to be_truthy }
it { expect(project.namespace).to eq(group) }
2014-09-02 18:07:02 +05:30
end
context 'namespace -> no namespace' do
before do
2015-09-11 14:41:01 +05:30
@result = transfer_project(project, user, nil)
2014-09-02 18:07:02 +05:30
end
2015-09-11 14:41:01 +05:30
it { expect(@result).to eq false }
2015-04-26 12:48:37 +05:30
it { expect(project.namespace).to eq(user.namespace) }
2014-09-02 18:07:02 +05:30
end
2016-06-02 11:05:42 +05:30
context 'disallow transfering of project with tags' do
before do
stub_container_registry_config(enabled: true)
stub_container_registry_tags('tag')
end
subject { transfer_project(project, user, group) }
it { is_expected.to be_falsey }
end
2014-09-02 18:07:02 +05:30
context 'namespace -> not allowed namespace' do
before do
2015-09-11 14:41:01 +05:30
@result = transfer_project(project, user, group)
2014-09-02 18:07:02 +05:30
end
2015-09-11 14:41:01 +05:30
it { expect(@result).to eq false }
2015-04-26 12:48:37 +05:30
it { expect(project.namespace).to eq(user.namespace) }
end
2015-09-11 14:41:01 +05:30
def transfer_project(project, user, new_namespace)
Projects::TransferService.new(project, user).execute(new_namespace)
2014-09-02 18:07:02 +05:30
end
2016-06-02 11:05:42 +05:30
context 'visibility level' do
let(:internal_group) { create(:group, :internal) }
before { internal_group.add_owner(user) }
context 'when namespace visibility level < project visibility level' do
let(:public_project) { create(:project, :public, namespace: user.namespace) }
before { transfer_project(public_project, user, internal_group) }
it { expect(public_project.visibility_level).to eq(internal_group.visibility_level) }
end
context 'when namespace visibility level > project visibility level' do
let(:private_project) { create(:project, :private, namespace: user.namespace) }
before { transfer_project(private_project, user, internal_group) }
it { expect(private_project.visibility_level).to eq(Gitlab::VisibilityLevel::PRIVATE) }
end
end
2014-09-02 18:07:02 +05:30
end