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 ...@@ -347,7 +347,6 @@ class Group < Namespace
end end
group_hierarchy_members = GroupMember.active_without_invites_and_requests group_hierarchy_members = GroupMember.active_without_invites_and_requests
.non_minimal_access
.where(source_id: source_ids) .where(source_id: source_ids)
GroupMember.from_union([group_hierarchy_members, GroupMember.from_union([group_hierarchy_members,
...@@ -637,6 +636,7 @@ class Group < Namespace ...@@ -637,6 +636,7 @@ class Group < Namespace
.where(group_member_table[:requested_at].eq(nil)) .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_id].eq(group_group_link_table[:shared_with_group_id]))
.where(group_member_table[:source_type].eq('Namespace')) .where(group_member_table[:source_type].eq('Namespace'))
.non_minimal_access
end end
def smallest_value_arel(args, column_alias) def smallest_value_arel(args, column_alias)
......
...@@ -59,6 +59,7 @@ class Member < ApplicationRecord ...@@ -59,6 +59,7 @@ class Member < ApplicationRecord
left_join_users left_join_users
.where(user_ok) .where(user_ok)
.where(requested_at: nil) .where(requested_at: nil)
.non_minimal_access
.reorder(nil) .reorder(nil)
end end
...@@ -67,6 +68,8 @@ class Member < ApplicationRecord ...@@ -67,6 +68,8 @@ class Member < ApplicationRecord
left_join_users left_join_users
.where(users: { state: 'active' }) .where(users: { state: 'active' })
.non_request .non_request
.non_invite
.non_minimal_access
.reorder(nil) .reorder(nil)
end end
......
...@@ -407,7 +407,11 @@ module EE ...@@ -407,7 +407,11 @@ module EE
override :member? override :member?
def member?(user, min_access_level = minimal_member_access_level) def member?(user, min_access_level = minimal_member_access_level)
super 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 end
def minimal_member_access_level def minimal_member_access_level
......
...@@ -106,14 +106,6 @@ RSpec.describe GroupsFinder do ...@@ -106,14 +106,6 @@ RSpec.describe GroupsFinder do
parent_group.update_attribute(:visibility_level, Gitlab::VisibilityLevel::PRIVATE) parent_group.update_attribute(:visibility_level, Gitlab::VisibilityLevel::PRIVATE)
end 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 context 'being member of parent group' do
it 'returns all subgroups' do it 'returns all subgroups' do
parent_group.add_guest(user) parent_group.add_guest(user)
...@@ -158,6 +150,14 @@ RSpec.describe GroupsFinder do ...@@ -158,6 +150,14 @@ RSpec.describe GroupsFinder do
end end
end 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 end
end end
......
...@@ -266,6 +266,34 @@ RSpec.describe Member do ...@@ -266,6 +266,34 @@ RSpec.describe Member do
it { is_expected.not_to include @blocked_maintainer } it { is_expected.not_to include @blocked_maintainer }
it { is_expected.not_to include @blocked_developer } it { is_expected.not_to include @blocked_developer }
end 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 end
describe "Delegate methods" do 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