Commit bf7b31d8 authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch 'group-members-list' into 'master'

Remove duplicate where condition for distinct_on_user_with_max_access_level

See merge request gitlab-org/gitlab!64214
parents 44288553 f968729a
......@@ -156,7 +156,7 @@ class Member < ApplicationRecord
distinct_members = select('DISTINCT ON (user_id, invite_email) *')
.order('user_id, invite_email, access_level DESC, expires_at DESC, created_at ASC')
from(distinct_members, :members)
unscoped.from(distinct_members, :members)
end
scope :order_name_asc, -> { left_join_users.reorder(Gitlab::Database.nulls_last_order('users.name', 'ASC')) }
......
......@@ -476,6 +476,20 @@ RSpec.describe Member do
it { is_expected.to include @blocked_maintainer }
it { is_expected.to include @blocked_developer }
it { is_expected.to include @member_with_minimal_access }
context 'with where conditions' do
let_it_be(:example_member) { create(:group_member, invite_email: 'user@example.com') }
subject do
described_class
.default_scoped
.where(invite_email: 'user@example.com')
.distinct_on_user_with_max_access_level
.to_a
end
it { is_expected.to eq [example_member] }
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