Commit 60ecf83a authored by Małgorzata Ksionek's avatar Małgorzata Ksionek Committed by Jan Provaznik

Modify member method

Fix groups sharing method

Update scope

Fix wording
parent a4a823ab
......@@ -347,7 +347,6 @@ class Group < Namespace
end
group_hierarchy_members = GroupMember.active_without_invites_and_requests
.non_minimal_access
.where(source_id: source_ids)
GroupMember.from_union([group_hierarchy_members,
......@@ -637,6 +636,7 @@ class Group < Namespace
.where(group_member_table[:requested_at].eq(nil))
.where(group_member_table[:source_id].eq(group_group_link_table[:shared_with_group_id]))
.where(group_member_table[:source_type].eq('Namespace'))
.non_minimal_access
end
def smallest_value_arel(args, column_alias)
......
......@@ -59,6 +59,7 @@ class Member < ApplicationRecord
left_join_users
.where(user_ok)
.where(requested_at: nil)
.non_minimal_access
.reorder(nil)
end
......@@ -67,6 +68,8 @@ class Member < ApplicationRecord
left_join_users
.where(users: { state: 'active' })
.non_request
.non_invite
.non_minimal_access
.reorder(nil)
end
......
......@@ -407,8 +407,12 @@ module EE
override :member?
def member?(user, min_access_level = minimal_member_access_level)
if min_access_level == ::Gitlab::Access::MINIMAL_ACCESS && minimal_access_role_allowed?
all_group_members.find_by(user_id: user.id).present?
else
super
end
end
def minimal_member_access_level
minimal_access_role_allowed? ? ::Gitlab::Access::MINIMAL_ACCESS : ::Gitlab::Access::GUEST
......
......@@ -106,14 +106,6 @@ RSpec.describe GroupsFinder do
parent_group.update_attribute(:visibility_level, Gitlab::VisibilityLevel::PRIVATE)
end
context 'being limited access member of parent group' do
it 'do not return group with minimal_access access' do
create(:group_member, :minimal_access, user: user, group: parent_group)
is_expected.to contain_exactly(public_subgroup, internal_subgroup)
end
end
context 'being member of parent group' do
it 'returns all subgroups' do
parent_group.add_guest(user)
......@@ -158,6 +150,14 @@ RSpec.describe GroupsFinder do
end
end
end
context 'being minimal access member of parent group' do
it 'do not return group with minimal_access access' do
create(:group_member, :minimal_access, user: user, group: parent_group)
is_expected.to contain_exactly(public_subgroup, internal_subgroup)
end
end
end
end
end
......
......@@ -266,6 +266,34 @@ RSpec.describe Member do
it { is_expected.not_to include @blocked_maintainer }
it { is_expected.not_to include @blocked_developer }
end
describe '.active' do
subject { described_class.active.to_a }
it { is_expected.to include @owner }
it { is_expected.to include @maintainer }
it { is_expected.to include @invited_member }
it { is_expected.to include @accepted_invite_member }
it { is_expected.not_to include @requested_member }
it { is_expected.to include @accepted_request_member }
it { is_expected.not_to include @blocked_maintainer }
it { is_expected.not_to include @blocked_developer }
it { is_expected.not_to include @member_with_minimal_access }
end
describe '.active_without_invites_and_requests' do
subject { described_class.active_without_invites_and_requests.to_a }
it { is_expected.to include @owner }
it { is_expected.to include @maintainer }
it { is_expected.not_to include @invited_member }
it { is_expected.to include @accepted_invite_member }
it { is_expected.not_to include @requested_member }
it { is_expected.to include @accepted_request_member }
it { is_expected.not_to include @blocked_maintainer }
it { is_expected.not_to include @blocked_developer }
it { is_expected.not_to include @member_with_minimal_access }
end
end
describe "Delegate methods" 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