Commit b4a50142 authored by Robert Speicher's avatar Robert Speicher

Merge branch 'fix-invite-banner-for-subgroups' into 'master'

Fix invite banner display for subgroups [RUN ALL RSPEC] [RUN AS-IF-FOSS]

See merge request gitlab-org/gitlab!59948
parents 3aa50e54 d5886f02
...@@ -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,6 +440,9 @@ RSpec.describe GroupsHelper do ...@@ -440,6 +440,9 @@ RSpec.describe GroupsHelper do
end end
with_them do with_them do
context 'for a parent group' do
subject { helper.show_invite_banner?(group) }
context 'when the group was just created' do context 'when the group was just created' do
before do before do
flash[:notice] = "Group #{group.name} was successfully created" flash[:notice] = "Group #{group.name} was successfully created"
...@@ -454,6 +457,25 @@ RSpec.describe GroupsHelper do ...@@ -454,6 +457,25 @@ RSpec.describe GroupsHelper do
end end
end end
end end
context 'for a subgroup' do
subject { helper.show_invite_banner?(subgroup) }
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
describe '#render_setting_to_allow_project_access_token_creation?' do describe '#render_setting_to_allow_project_access_token_creation?' do
......
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