2019-04-11 08:17:24 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-08-29 03:56:52 -04:00
|
|
|
require 'spec_helper'
|
2018-02-05 19:10:58 -05:00
|
|
|
|
2019-07-24 05:20:54 -04:00
|
|
|
describe Groups::TransferService do
|
2018-02-05 19:10:58 -05:00
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:new_parent_group) { create(:group, :public) }
|
|
|
|
let!(:group_member) { create(:group_member, :owner, group: group, user: user) }
|
|
|
|
let(:transfer_service) { described_class.new(group, user) }
|
|
|
|
|
|
|
|
shared_examples 'ensuring allowed transfer for a group' do
|
2018-09-21 08:05:37 -04:00
|
|
|
context "when there's an exception on GitLab shell directories" do
|
2018-02-05 19:10:58 -05:00
|
|
|
let(:new_parent_group) { create(:group, :public) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
allow_any_instance_of(described_class).to receive(:update_group_attributes).and_raise(Gitlab::UpdatePathError, 'namespace directory cannot be moved')
|
|
|
|
create(:group_member, :owner, group: new_parent_group, user: user)
|
|
|
|
end
|
|
|
|
|
2019-04-05 04:43:27 -04:00
|
|
|
it 'returns false' do
|
2018-02-05 19:10:58 -05:00
|
|
|
expect(transfer_service.execute(new_parent_group)).to be_falsy
|
|
|
|
end
|
|
|
|
|
2019-04-05 04:43:27 -04:00
|
|
|
it 'adds an error on group' do
|
2018-02-05 19:10:58 -05:00
|
|
|
transfer_service.execute(new_parent_group)
|
|
|
|
expect(transfer_service.error).to eq('Transfer failed: namespace directory cannot be moved')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#execute' do
|
|
|
|
context 'when transforming a group into a root group' do
|
|
|
|
let!(:group) { create(:group, :public, :nested) }
|
|
|
|
|
|
|
|
it_behaves_like 'ensuring allowed transfer for a group'
|
|
|
|
|
|
|
|
context 'when the group is already a root group' do
|
|
|
|
let(:group) { create(:group, :public) }
|
|
|
|
|
2019-04-05 04:43:27 -04:00
|
|
|
it 'adds an error on group' do
|
2018-02-05 19:10:58 -05:00
|
|
|
transfer_service.execute(nil)
|
|
|
|
expect(transfer_service.error).to eq('Transfer failed: Group is already a root group.')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when the user does not have the right policies' do
|
|
|
|
let!(:group_member) { create(:group_member, :guest, group: group, user: user) }
|
|
|
|
|
2019-04-05 04:43:27 -04:00
|
|
|
it "returns false" do
|
2018-02-05 19:10:58 -05:00
|
|
|
expect(transfer_service.execute(nil)).to be_falsy
|
|
|
|
end
|
|
|
|
|
2019-04-05 04:43:27 -04:00
|
|
|
it "adds an error on group" do
|
2018-02-05 19:10:58 -05:00
|
|
|
transfer_service.execute(new_parent_group)
|
|
|
|
expect(transfer_service.error).to eq("Transfer failed: You don't have enough permissions.")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when there is a group with the same path' do
|
|
|
|
let!(:group) { create(:group, :public, :nested, path: 'not-unique') }
|
|
|
|
|
|
|
|
before do
|
|
|
|
create(:group, path: 'not-unique')
|
|
|
|
end
|
|
|
|
|
2019-04-05 04:43:27 -04:00
|
|
|
it 'returns false' do
|
2018-02-05 19:10:58 -05:00
|
|
|
expect(transfer_service.execute(nil)).to be_falsy
|
|
|
|
end
|
|
|
|
|
2019-04-05 04:43:27 -04:00
|
|
|
it 'adds an error on group' do
|
2018-02-05 19:10:58 -05:00
|
|
|
transfer_service.execute(nil)
|
|
|
|
expect(transfer_service.error).to eq('Transfer failed: The parent group already has a subgroup with the same path.')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when the group is a subgroup and the transfer is valid' do
|
|
|
|
let!(:subgroup1) { create(:group, :private, parent: group) }
|
|
|
|
let!(:subgroup2) { create(:group, :internal, parent: group) }
|
|
|
|
let!(:project1) { create(:project, :repository, :private, namespace: group) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
transfer_service.execute(nil)
|
|
|
|
group.reload
|
|
|
|
end
|
|
|
|
|
2019-04-05 04:43:27 -04:00
|
|
|
it 'updates group attributes' do
|
2018-02-05 19:10:58 -05:00
|
|
|
expect(group.parent).to be_nil
|
|
|
|
end
|
|
|
|
|
2019-04-05 04:43:27 -04:00
|
|
|
it 'updates group children path' do
|
2018-02-05 19:10:58 -05:00
|
|
|
group.children.each do |subgroup|
|
|
|
|
expect(subgroup.full_path).to eq("#{group.path}/#{subgroup.path}")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-04-05 04:43:27 -04:00
|
|
|
it 'updates group projects path' do
|
2018-02-05 19:10:58 -05:00
|
|
|
group.projects.each do |project|
|
|
|
|
expect(project.full_path).to eq("#{group.path}/#{project.path}")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when transferring a subgroup into another group' do
|
|
|
|
let(:group) { create(:group, :public, :nested) }
|
|
|
|
|
|
|
|
it_behaves_like 'ensuring allowed transfer for a group'
|
|
|
|
|
|
|
|
context 'when the new parent group is the same as the previous parent group' do
|
|
|
|
let(:group) { create(:group, :public, :nested, parent: new_parent_group) }
|
|
|
|
|
2019-04-05 04:43:27 -04:00
|
|
|
it 'returns false' do
|
2018-02-05 19:10:58 -05:00
|
|
|
expect(transfer_service.execute(new_parent_group)).to be_falsy
|
|
|
|
end
|
|
|
|
|
2019-04-05 04:43:27 -04:00
|
|
|
it 'adds an error on group' do
|
2018-02-05 19:10:58 -05:00
|
|
|
transfer_service.execute(new_parent_group)
|
|
|
|
expect(transfer_service.error).to eq('Transfer failed: Group is already associated to the parent group.')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when the user does not have the right policies' do
|
|
|
|
let!(:group_member) { create(:group_member, :guest, group: group, user: user) }
|
|
|
|
|
2019-04-05 04:43:27 -04:00
|
|
|
it "returns false" do
|
2018-02-05 19:10:58 -05:00
|
|
|
expect(transfer_service.execute(new_parent_group)).to be_falsy
|
|
|
|
end
|
|
|
|
|
2019-04-05 04:43:27 -04:00
|
|
|
it "adds an error on group" do
|
2018-02-05 19:10:58 -05:00
|
|
|
transfer_service.execute(new_parent_group)
|
|
|
|
expect(transfer_service.error).to eq("Transfer failed: You don't have enough permissions.")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when the parent has a group with the same path' do
|
|
|
|
before do
|
|
|
|
create(:group_member, :owner, group: new_parent_group, user: user)
|
|
|
|
group.update_attribute(:path, "not-unique")
|
|
|
|
create(:group, path: "not-unique", parent: new_parent_group)
|
|
|
|
end
|
|
|
|
|
2019-04-05 04:43:27 -04:00
|
|
|
it 'returns false' do
|
2018-02-05 19:10:58 -05:00
|
|
|
expect(transfer_service.execute(new_parent_group)).to be_falsy
|
|
|
|
end
|
|
|
|
|
2019-04-05 04:43:27 -04:00
|
|
|
it 'adds an error on group' do
|
2018-02-05 19:10:58 -05:00
|
|
|
transfer_service.execute(new_parent_group)
|
|
|
|
expect(transfer_service.error).to eq('Transfer failed: The parent group already has a subgroup with the same path.')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when the parent group has a project with the same path' do
|
|
|
|
let!(:group) { create(:group, :public, :nested, path: 'foo') }
|
|
|
|
|
|
|
|
before do
|
|
|
|
create(:group_member, :owner, group: new_parent_group, user: user)
|
|
|
|
create(:project, path: 'foo', namespace: new_parent_group)
|
|
|
|
group.update_attribute(:path, 'foo')
|
|
|
|
end
|
|
|
|
|
2019-04-05 04:43:27 -04:00
|
|
|
it 'returns false' do
|
2018-02-05 19:10:58 -05:00
|
|
|
expect(transfer_service.execute(new_parent_group)).to be_falsy
|
|
|
|
end
|
|
|
|
|
2019-04-05 04:43:27 -04:00
|
|
|
it 'adds an error on group' do
|
2018-02-05 19:10:58 -05:00
|
|
|
transfer_service.execute(new_parent_group)
|
2018-10-30 12:23:47 -04:00
|
|
|
expect(transfer_service.error).to eq('Transfer failed: Validation failed: Group URL has already been taken')
|
2018-02-05 19:10:58 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when the group is allowed to be transferred' do
|
|
|
|
before do
|
|
|
|
create(:group_member, :owner, group: new_parent_group, user: user)
|
|
|
|
transfer_service.execute(new_parent_group)
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when the group has a lower visibility than the parent group' do
|
|
|
|
let(:new_parent_group) { create(:group, :public) }
|
|
|
|
let(:group) { create(:group, :private, :nested) }
|
|
|
|
|
2019-04-05 04:43:27 -04:00
|
|
|
it 'does not update the visibility for the group' do
|
2018-02-05 19:10:58 -05:00
|
|
|
group.reload
|
|
|
|
expect(group.private?).to be_truthy
|
|
|
|
expect(group.visibility_level).not_to eq(new_parent_group.visibility_level)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when the group has a higher visibility than the parent group' do
|
|
|
|
let(:new_parent_group) { create(:group, :private) }
|
|
|
|
let(:group) { create(:group, :public, :nested) }
|
|
|
|
|
2019-04-05 04:43:27 -04:00
|
|
|
it 'updates visibility level based on the parent group' do
|
2018-02-05 19:10:58 -05:00
|
|
|
group.reload
|
|
|
|
expect(group.private?).to be_truthy
|
|
|
|
expect(group.visibility_level).to eq(new_parent_group.visibility_level)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-04-05 04:43:27 -04:00
|
|
|
it 'updates visibility for the group based on the parent group' do
|
2018-02-05 19:10:58 -05:00
|
|
|
expect(group.visibility_level).to eq(new_parent_group.visibility_level)
|
|
|
|
end
|
|
|
|
|
2019-04-05 04:43:27 -04:00
|
|
|
it 'updates parent group to the new parent' do
|
2018-02-05 19:10:58 -05:00
|
|
|
expect(group.parent).to eq(new_parent_group)
|
|
|
|
end
|
|
|
|
|
2019-04-05 04:43:27 -04:00
|
|
|
it 'returns the group as children of the new parent' do
|
2018-02-05 19:10:58 -05:00
|
|
|
expect(new_parent_group.children.count).to eq(1)
|
|
|
|
expect(new_parent_group.children.first).to eq(group)
|
|
|
|
end
|
|
|
|
|
2019-04-05 04:43:27 -04:00
|
|
|
it 'creates a redirect for the group' do
|
2018-03-05 07:02:36 -05:00
|
|
|
expect(group.redirect_routes.count).to eq(1)
|
2018-02-05 19:10:58 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when transferring a group with group descendants' do
|
|
|
|
let!(:subgroup1) { create(:group, :private, parent: group) }
|
|
|
|
let!(:subgroup2) { create(:group, :internal, parent: group) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
create(:group_member, :owner, group: new_parent_group, user: user)
|
|
|
|
transfer_service.execute(new_parent_group)
|
|
|
|
end
|
|
|
|
|
2019-04-05 04:43:27 -04:00
|
|
|
it 'updates subgroups path' do
|
2018-02-05 19:10:58 -05:00
|
|
|
new_parent_path = new_parent_group.path
|
|
|
|
group.children.each do |subgroup|
|
|
|
|
expect(subgroup.full_path).to eq("#{new_parent_path}/#{group.path}/#{subgroup.path}")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-04-05 04:43:27 -04:00
|
|
|
it 'creates redirects for the subgroups' do
|
2018-03-05 07:02:36 -05:00
|
|
|
expect(group.redirect_routes.count).to eq(1)
|
|
|
|
expect(subgroup1.redirect_routes.count).to eq(1)
|
|
|
|
expect(subgroup2.redirect_routes.count).to eq(1)
|
2018-02-05 19:10:58 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'when the new parent has a higher visibility than the children' do
|
2019-04-05 04:43:27 -04:00
|
|
|
it 'does not update the children visibility' do
|
2018-02-05 19:10:58 -05:00
|
|
|
expect(subgroup1.private?).to be_truthy
|
|
|
|
expect(subgroup2.internal?).to be_truthy
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when the new parent has a lower visibility than the children' do
|
|
|
|
let!(:subgroup1) { create(:group, :public, parent: group) }
|
|
|
|
let!(:subgroup2) { create(:group, :public, parent: group) }
|
|
|
|
let(:new_parent_group) { create(:group, :private) }
|
|
|
|
|
2019-04-05 04:43:27 -04:00
|
|
|
it 'updates children visibility to match the new parent' do
|
2018-02-05 19:10:58 -05:00
|
|
|
group.children.each do |subgroup|
|
|
|
|
expect(subgroup.private?).to be_truthy
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when transferring a group with project descendants' do
|
|
|
|
let!(:project1) { create(:project, :repository, :private, namespace: group) }
|
|
|
|
let!(:project2) { create(:project, :repository, :internal, namespace: group) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
TestEnv.clean_test_path
|
|
|
|
create(:group_member, :owner, group: new_parent_group, user: user)
|
|
|
|
transfer_service.execute(new_parent_group)
|
|
|
|
end
|
|
|
|
|
2019-04-05 04:43:27 -04:00
|
|
|
it 'updates projects path' do
|
2018-02-05 19:10:58 -05:00
|
|
|
new_parent_path = new_parent_group.path
|
|
|
|
group.projects.each do |project|
|
|
|
|
expect(project.full_path).to eq("#{new_parent_path}/#{group.path}/#{project.name}")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-04-05 04:43:27 -04:00
|
|
|
it 'creates permanent redirects for the projects' do
|
2018-03-05 07:02:36 -05:00
|
|
|
expect(group.redirect_routes.count).to eq(1)
|
|
|
|
expect(project1.redirect_routes.count).to eq(1)
|
|
|
|
expect(project2.redirect_routes.count).to eq(1)
|
2018-02-05 19:10:58 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'when the new parent has a higher visibility than the projects' do
|
2019-04-05 04:43:27 -04:00
|
|
|
it 'does not update projects visibility' do
|
2018-02-05 19:10:58 -05:00
|
|
|
expect(project1.private?).to be_truthy
|
|
|
|
expect(project2.internal?).to be_truthy
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when the new parent has a lower visibility than the projects' do
|
|
|
|
let!(:project1) { create(:project, :repository, :public, namespace: group) }
|
|
|
|
let!(:project2) { create(:project, :repository, :public, namespace: group) }
|
|
|
|
let(:new_parent_group) { create(:group, :private) }
|
|
|
|
|
2019-04-05 04:43:27 -04:00
|
|
|
it 'updates projects visibility to match the new parent' do
|
2018-02-05 19:10:58 -05:00
|
|
|
group.projects.each do |project|
|
|
|
|
expect(project.private?).to be_truthy
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when transferring a group with subgroups & projects descendants' do
|
|
|
|
let!(:project1) { create(:project, :repository, :private, namespace: group) }
|
|
|
|
let!(:project2) { create(:project, :repository, :internal, namespace: group) }
|
|
|
|
let!(:subgroup1) { create(:group, :private, parent: group) }
|
|
|
|
let!(:subgroup2) { create(:group, :internal, parent: group) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
TestEnv.clean_test_path
|
|
|
|
create(:group_member, :owner, group: new_parent_group, user: user)
|
|
|
|
transfer_service.execute(new_parent_group)
|
|
|
|
end
|
|
|
|
|
2019-04-05 04:43:27 -04:00
|
|
|
it 'updates subgroups path' do
|
2018-02-05 19:10:58 -05:00
|
|
|
new_parent_path = new_parent_group.path
|
|
|
|
group.children.each do |subgroup|
|
|
|
|
expect(subgroup.full_path).to eq("#{new_parent_path}/#{group.path}/#{subgroup.path}")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-04-05 04:43:27 -04:00
|
|
|
it 'updates projects path' do
|
2018-02-05 19:10:58 -05:00
|
|
|
new_parent_path = new_parent_group.path
|
|
|
|
group.projects.each do |project|
|
|
|
|
expect(project.full_path).to eq("#{new_parent_path}/#{group.path}/#{project.name}")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-04-05 04:43:27 -04:00
|
|
|
it 'creates redirect for the subgroups and projects' do
|
2018-03-05 07:02:36 -05:00
|
|
|
expect(group.redirect_routes.count).to eq(1)
|
|
|
|
expect(subgroup1.redirect_routes.count).to eq(1)
|
|
|
|
expect(subgroup2.redirect_routes.count).to eq(1)
|
|
|
|
expect(project1.redirect_routes.count).to eq(1)
|
|
|
|
expect(project2.redirect_routes.count).to eq(1)
|
2018-02-05 19:10:58 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-10-30 06:53:01 -04:00
|
|
|
context 'when transferring a group with nested groups and projects' do
|
2018-02-05 19:10:58 -05:00
|
|
|
let!(:group) { create(:group, :public) }
|
|
|
|
let!(:project1) { create(:project, :repository, :private, namespace: group) }
|
|
|
|
let!(:subgroup1) { create(:group, :private, parent: group) }
|
|
|
|
let!(:nested_subgroup) { create(:group, :private, parent: subgroup1) }
|
|
|
|
let!(:nested_project) { create(:project, :repository, :private, namespace: subgroup1) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
TestEnv.clean_test_path
|
|
|
|
create(:group_member, :owner, group: new_parent_group, user: user)
|
|
|
|
transfer_service.execute(new_parent_group)
|
|
|
|
end
|
|
|
|
|
2019-04-05 04:43:27 -04:00
|
|
|
it 'updates subgroups path' do
|
2018-02-05 19:10:58 -05:00
|
|
|
new_base_path = "#{new_parent_group.path}/#{group.path}"
|
|
|
|
group.children.each do |children|
|
|
|
|
expect(children.full_path).to eq("#{new_base_path}/#{children.path}")
|
|
|
|
end
|
|
|
|
|
|
|
|
new_base_path = "#{new_parent_group.path}/#{group.path}/#{subgroup1.path}"
|
|
|
|
subgroup1.children.each do |children|
|
|
|
|
expect(children.full_path).to eq("#{new_base_path}/#{children.path}")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-04-05 04:43:27 -04:00
|
|
|
it 'updates projects path' do
|
2018-02-05 19:10:58 -05:00
|
|
|
new_parent_path = "#{new_parent_group.path}/#{group.path}"
|
|
|
|
subgroup1.projects.each do |project|
|
|
|
|
project_full_path = "#{new_parent_path}/#{project.namespace.path}/#{project.name}"
|
|
|
|
expect(project.full_path).to eq(project_full_path)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-04-05 04:43:27 -04:00
|
|
|
it 'creates redirect for the subgroups and projects' do
|
2018-03-05 07:02:36 -05:00
|
|
|
expect(group.redirect_routes.count).to eq(1)
|
|
|
|
expect(project1.redirect_routes.count).to eq(1)
|
|
|
|
expect(subgroup1.redirect_routes.count).to eq(1)
|
|
|
|
expect(nested_subgroup.redirect_routes.count).to eq(1)
|
|
|
|
expect(nested_project.redirect_routes.count).to eq(1)
|
2018-02-05 19:10:58 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when updating the group goes wrong' do
|
|
|
|
let!(:subgroup1) { create(:group, :public, parent: group) }
|
|
|
|
let!(:subgroup2) { create(:group, :public, parent: group) }
|
|
|
|
let(:new_parent_group) { create(:group, :private) }
|
|
|
|
let!(:project1) { create(:project, :repository, :public, namespace: group) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
allow(group).to receive(:save!).and_raise(ActiveRecord::RecordInvalid.new(group))
|
|
|
|
TestEnv.clean_test_path
|
|
|
|
create(:group_member, :owner, group: new_parent_group, user: user)
|
|
|
|
transfer_service.execute(new_parent_group)
|
|
|
|
end
|
|
|
|
|
2019-04-05 04:43:27 -04:00
|
|
|
it 'restores group and projects visibility' do
|
2018-02-05 19:10:58 -05:00
|
|
|
subgroup1.reload
|
|
|
|
project1.reload
|
|
|
|
expect(subgroup1.public?).to be_truthy
|
|
|
|
expect(project1.public?).to be_truthy
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2019-02-25 18:27:16 -05:00
|
|
|
|
|
|
|
context 'when transferring a subgroup into root group' do
|
|
|
|
let(:group) { create(:group, :public, :nested) }
|
|
|
|
let(:subgroup) { create(:group, :public, parent: group) }
|
|
|
|
let(:transfer_service) { described_class.new(subgroup, user) }
|
|
|
|
|
|
|
|
it 'ensures there is still an owner for the transferred group' do
|
|
|
|
expect(subgroup.owners).to be_empty
|
|
|
|
|
|
|
|
transfer_service.execute(nil)
|
|
|
|
subgroup.reload
|
|
|
|
|
|
|
|
expect(subgroup.owners).to match_array(user)
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when group has explicit owner' do
|
|
|
|
let(:another_owner) { create(:user) }
|
|
|
|
let!(:another_member) { create(:group_member, :owner, group: subgroup, user: another_owner) }
|
|
|
|
|
|
|
|
it 'does not add additional owner' do
|
|
|
|
expect(subgroup.owners).to match_array(another_owner)
|
|
|
|
|
|
|
|
transfer_service.execute(nil)
|
|
|
|
subgroup.reload
|
|
|
|
|
|
|
|
expect(subgroup.owners).to match_array(another_owner)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2019-10-16 05:07:51 -04:00
|
|
|
|
2019-11-08 04:06:07 -05:00
|
|
|
context 'when a project has container images' do
|
2019-10-16 05:07:51 -04:00
|
|
|
let(:group) { create(:group, :public, :nested) }
|
2019-11-08 04:06:07 -05:00
|
|
|
let!(:container_repository) { create(:container_repository, project: project) }
|
|
|
|
|
|
|
|
subject { transfer_service.execute(new_parent_group) }
|
2019-10-16 05:07:51 -04:00
|
|
|
|
|
|
|
before do
|
2019-11-08 04:06:07 -05:00
|
|
|
group.add_owner(user)
|
|
|
|
new_parent_group.add_owner(user)
|
2019-10-16 05:07:51 -04:00
|
|
|
end
|
|
|
|
|
2019-11-08 04:06:07 -05:00
|
|
|
context 'within group' do
|
|
|
|
let(:project) { create(:project, :repository, :public, namespace: group) }
|
|
|
|
|
|
|
|
it 'does not transfer' do
|
|
|
|
expect(subject).to be false
|
|
|
|
expect(transfer_service.error).to match(/Docker images in their Container Registry/)
|
|
|
|
end
|
|
|
|
end
|
2019-10-16 05:07:51 -04:00
|
|
|
|
2019-11-08 04:06:07 -05:00
|
|
|
context 'within subgroup' do
|
|
|
|
let(:subgroup) { create(:group, parent: group) }
|
|
|
|
let(:project) { create(:project, :repository, :public, namespace: subgroup) }
|
|
|
|
|
|
|
|
it 'does not transfer' do
|
|
|
|
expect(subject).to be false
|
|
|
|
expect(transfer_service.error).to match(/Docker images in their Container Registry/)
|
|
|
|
end
|
2019-10-16 05:07:51 -04:00
|
|
|
end
|
|
|
|
end
|
2018-02-05 19:10:58 -05:00
|
|
|
end
|
|
|
|
end
|