diff options
author | Peter Marko <peter.marko@siemens.com> | 2019-02-26 02:27:16 +0300 |
---|---|---|
committer | Peter Marko <peter.marko@siemens.com> | 2019-03-01 22:03:06 +0300 |
commit | dea631545f580d22e63ff09f9d9f194a559d2612 (patch) | |
tree | d2453e0d682b278d57b8f5cc06cb211cd36a7d63 /spec/services/groups | |
parent | d86de642d16e0f7518c7f508b5282c89128e9a58 (diff) |
fix group without owner after transfer
Diffstat (limited to 'spec/services/groups')
-rw-r--r-- | spec/services/groups/transfer_service_spec.rb | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/spec/services/groups/transfer_service_spec.rb b/spec/services/groups/transfer_service_spec.rb index 6b48c993c57..79d504b9b45 100644 --- a/spec/services/groups/transfer_service_spec.rb +++ b/spec/services/groups/transfer_service_spec.rb @@ -410,5 +410,34 @@ describe Groups::TransferService, :postgresql do end end end + + 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 end end |