Commit d5886f02 authored by Jackie Fraser's avatar Jackie Fraser

Fix invite banner display for subgroups

Makes the "Invite your colleagues" banner display for a subgroup
with the same member count rules as a parent group.

Changelog: fixed
parent adac6df7
...@@ -230,7 +230,7 @@ module GroupsHelper ...@@ -230,7 +230,7 @@ module GroupsHelper
end end
def multiple_members?(group) def multiple_members?(group)
group.member_count > 1 group.member_count > 1 || group.members_with_parents.count > 1
end end
def get_group_sidebar_links def get_group_sidebar_links
......
---
title: 'Fix invite banner display member count for subgroups page'
merge_request: 59948
author:
type: fixed
...@@ -420,13 +420,13 @@ RSpec.describe GroupsHelper do ...@@ -420,13 +420,13 @@ RSpec.describe GroupsHelper do
describe '#show_invite_banner?' do describe '#show_invite_banner?' do
let_it_be(:current_user) { create(:user) } let_it_be(:current_user) { create(:user) }
let_it_be_with_refind(:group) { create(:group) } let_it_be_with_refind(:group) { create(:group) }
let_it_be(:subgroup) { create(:group, parent: group) }
let_it_be(:users) { [current_user, create(:user)] } let_it_be(:users) { [current_user, create(:user)] }
subject { helper.show_invite_banner?(group) }
before do before do
allow(helper).to receive(:current_user) { current_user } allow(helper).to receive(:current_user) { current_user }
allow(helper).to receive(:can?).with(current_user, :admin_group, group).and_return(can_admin_group) allow(helper).to receive(:can?).with(current_user, :admin_group, group).and_return(can_admin_group)
allow(helper).to receive(:can?).with(current_user, :admin_group, subgroup).and_return(can_admin_group)
users.take(group_members_count).each { |user| group.add_guest(user) } users.take(group_members_count).each { |user| group.add_guest(user) }
end end
...@@ -440,17 +440,39 @@ RSpec.describe GroupsHelper do ...@@ -440,17 +440,39 @@ RSpec.describe GroupsHelper do
end end
with_them do with_them do
context 'when the group was just created' do context 'for a parent group' do
before do subject { helper.show_invite_banner?(group) }
flash[:notice] = "Group #{group.name} was successfully created"
context 'when the group was just created' do
before do
flash[:notice] = "Group #{group.name} was successfully created"
end
it { is_expected.to be_falsey }
end end
it { is_expected.to be_falsey } context 'when no flash message' do
it 'returns the expected result' do
expect(subject).to eq(expected_result)
end
end
end end
context 'when no flash message' do context 'for a subgroup' do
it 'returns the expected result' do subject { helper.show_invite_banner?(subgroup) }
expect(subject).to eq(expected_result)
context 'when the subgroup was just created' do
before do
flash[:notice] = "Group #{subgroup.name} was successfully created"
end
it { is_expected.to be_falsey }
end
context 'when no flash message' do
it 'returns the expected result' do
expect(subject).to eq(expected_result)
end
end end
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment