Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/models/group_spec.rb')
-rw-r--r--spec/models/group_spec.rb45
1 files changed, 45 insertions, 0 deletions
diff --git a/spec/models/group_spec.rb b/spec/models/group_spec.rb
index 4184f2d07cc..3eb74da09e1 100644
--- a/spec/models/group_spec.rb
+++ b/spec/models/group_spec.rb
@@ -26,6 +26,7 @@ RSpec.describe Group do
it { is_expected.to have_many(:container_repositories) }
it { is_expected.to have_many(:milestones) }
it { is_expected.to have_many(:iterations) }
+ it { is_expected.to have_many(:group_deploy_keys) }
describe '#members & #requesters' do
let(:requester) { create(:user) }
@@ -1540,4 +1541,48 @@ RSpec.describe Group do
end
end
end
+
+ describe '#default_owner' do
+ let(:group) { build(:group) }
+
+ context 'the group has owners' do
+ before do
+ group.add_owner(create(:user))
+ group.add_owner(create(:user))
+ end
+
+ it 'is the first owner' do
+ expect(group.default_owner)
+ .to eq(group.owners.first)
+ .and be_a(User)
+ end
+ end
+
+ context 'the group has a parent' do
+ let(:parent) { build(:group) }
+
+ before do
+ group.parent = parent
+ parent.add_owner(create(:user))
+ end
+
+ it 'is the first owner of the parent' do
+ expect(group.default_owner)
+ .to eq(parent.default_owner)
+ .and be_a(User)
+ end
+ end
+
+ context 'we fallback to group.owner' do
+ before do
+ group.owner = build(:user)
+ end
+
+ it 'is the group.owner' do
+ expect(group.default_owner)
+ .to eq(group.owner)
+ .and be_a(User)
+ end
+ end
+ end
end