Commit 89fb1215 authored by Vijay Hawoldar's avatar Vijay Hawoldar

Adjust specs for member scope

parent 0f117a67
...@@ -253,33 +253,43 @@ RSpec.describe Member, type: :model do ...@@ -253,33 +253,43 @@ RSpec.describe Member, type: :model do
let_it_be(:awaiting_project_member) { create(:project_member, :awaiting, project: project) } let_it_be(:awaiting_project_member) { create(:project_member, :awaiting, project: project) }
let_it_be(:awaiting_invited_member) { create(:group_member, :awaiting, :invited, group: group) } let_it_be(:awaiting_invited_member) { create(:group_member, :awaiting, :invited, group: group) }
let_it_be(:active_invited_member) { create(:group_member, :invited, group: group) } let_it_be(:active_invited_member) { create(:group_member, :invited, group: group) }
let_it_be(:awaiting_previously_invited_member) do
member = create(:group_member, :awaiting, :invited, group: group)
user = create(:user)
member.accept_invite!(user)
member
end
subject(:results) { described_class.distinct_awaiting_or_invited_for_group(group) } subject(:results) { described_class.distinct_awaiting_or_invited_for_group(group) }
it 'returns the correct members' do it 'returns the correct members' do
expect(results.size).to eq 5 expect(results).to contain_exactly(
expect(results).to match_array [
awaiting_group_member, awaiting_group_member,
awaiting_subgroup_member, awaiting_subgroup_member,
awaiting_project_member, awaiting_project_member,
awaiting_invited_member, awaiting_invited_member,
awaiting_previously_invited_member,
active_invited_member active_invited_member
] )
end end
it 'does not return additional results for duplicates' do it 'does not return additional results for duplicates' do
create(:group_member, :awaiting, group: sub_group, user: awaiting_group_member.user) create(:group_member, :awaiting, group: sub_group, user: awaiting_group_member.user)
create(:group_member, :invited, group: sub_group, invite_email: awaiting_invited_member.invite_email) create(:group_member, :invited, group: sub_group, invite_email: awaiting_invited_member.invite_email)
create(:group_member, :awaiting, group: sub_group, invite_email: awaiting_previously_invited_member.invite_email, user: awaiting_previously_invited_member.user)
expect(results.size).to eq 5
expect(results.map(&:user_id).compact).to contain_exactly( expect(results.map(&:user_id).compact).to contain_exactly(
awaiting_group_member.user_id, awaiting_group_member.user_id,
awaiting_subgroup_member.user_id, awaiting_subgroup_member.user_id,
awaiting_project_member.user_id awaiting_project_member.user_id,
awaiting_previously_invited_member.user_id
) )
expect(results.map(&:invite_email).compact).to contain_exactly( expect(results.map(&:invite_email).compact).to contain_exactly(
awaiting_invited_member.invite_email, awaiting_invited_member.invite_email,
active_invited_member.invite_email active_invited_member.invite_email,
awaiting_previously_invited_member.invite_email
) )
end 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