Commit 5428e3ab authored by Małgorzata Ksionek's avatar Małgorzata Ksionek Committed by Jan Provaznik

Do not show unassigned members on admin group page

Update admin views

Add specs for group

Fix little things

Fix

Fix
parent b04dd44f
......@@ -19,7 +19,7 @@ class Admin::GroupsController < Admin::ApplicationController
# the Group with statistics).
@group = Group.with_statistics.find(group&.id)
@members = present_members(
@group.members.order("access_level DESC").page(params[:members_page]))
group_members.order("access_level DESC").page(params[:members_page]))
@requesters = present_members(
AccessRequestsFinder.new(@group).execute(current_user))
@projects = @group.projects.with_statistics.page(params[:projects_page])
......@@ -82,6 +82,10 @@ class Admin::GroupsController < Admin::ApplicationController
@group ||= Group.find_by_full_path(params[:id])
end
def group_members
@group.members.non_unassigned
end
def group_params
params.require(:group).permit(allowed_group_params)
end
......
......@@ -397,6 +397,10 @@ class Group < Namespace
])
end
def users_count
members.non_unassigned.count
end
# Returns all users that are members of projects
# belonging to the current group or sub-groups
def project_users_with_descendants
......
......@@ -27,7 +27,7 @@
%span.gl-ml-5
= sprite_icon('users', css_class: 'gl-vertical-align-text-bottom')
= number_with_delimiter(group.users.count)
= number_with_delimiter(group.users_count)
%span.gl-ml-5.visibility-icon.has-tooltip{ data: { container: 'body', placement: 'left' }, title: visibility_icon_description(group) }
= visibility_level_icon(group.visibility_level)
......
......@@ -3,7 +3,6 @@
module EE
module GroupMember
extend ActiveSupport::Concern
extend ::Gitlab::Utils::Override
prepended do
extend ::Gitlab::Utils::Override
......@@ -27,8 +26,6 @@ module EE
end
class_methods do
extend ::Gitlab::Utils::Override
def member_of_group?(group, user)
exists?(group: group, user: user)
end
......
......@@ -13,13 +13,6 @@ module EE
can?(current_user, override_member_permission, member)
end
override :valid_level_roles
def valid_level_roles
return super if member.source.is_a?(Project)
super.except("Unassigned")
end
private
def override_member_permission
......
......@@ -668,6 +668,34 @@ RSpec.describe Group do
end
end
describe '#unassigned_role_allowed?' do
subject { group.unassigned_role_allowed? }
context 'licensed' do
before do
stub_licensed_features(unassigned_role: true)
end
it 'returns true for licensed instance' do
is_expected.to be true
end
it 'returns false for subgroup in licensed instance' do
expect(create(:group, parent: group).unassigned_role_allowed?).to be false
end
end
context 'unlicensed' do
before do
stub_licensed_features(unassigned_role: false)
end
it 'returns false unlicensed instance' do
is_expected.to be false
end
end
end
describe '#saml_discovery_token' do
it 'returns existing tokens' do
group = create(:group, saml_discovery_token: 'existing')
......
......@@ -41,10 +41,10 @@ module Gitlab
def options
{
"Guest" => GUEST,
"Reporter" => REPORTER,
"Developer" => DEVELOPER,
"Maintainer" => MAINTAINER
"Guest" => GUEST,
"Reporter" => REPORTER,
"Developer" => DEVELOPER,
"Maintainer" => MAINTAINER
}
end
......
......@@ -112,7 +112,7 @@ RSpec.describe AuthorizedProjectUpdate::ProjectGroupLinkCreateService do
end
end
context 'unapproved access requests' do
context 'unassigned member' do
before do
create(:group_member, :unassigned, user: group_user, group: group)
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