Commit 5dc6b976 authored by Robert Speicher's avatar Robert Speicher

Merge branch 'mmj-correct-invitation-spec' into 'master'

Correct the `blocked` scope in `Member` class

See merge request gitlab-org/gitlab!61108
parents 5ae87f35 e6219d2b
...@@ -84,10 +84,9 @@ class Member < ApplicationRecord ...@@ -84,10 +84,9 @@ class Member < ApplicationRecord
is_external_invite = arel_table[:user_id].eq(nil).and(arel_table[:invite_token].not_eq(nil)) is_external_invite = arel_table[:user_id].eq(nil).and(arel_table[:invite_token].not_eq(nil))
user_is_blocked = User.arel_table[:state].eq(:blocked) user_is_blocked = User.arel_table[:state].eq(:blocked)
user_ok = Arel::Nodes::Grouping.new(is_external_invite).or(user_is_blocked)
left_join_users left_join_users
.where(user_ok) .where(user_is_blocked)
.where.not(is_external_invite)
.non_request .non_request
.non_minimal_access .non_minimal_access
.reorder(nil) .reorder(nil)
......
---
title: Correct the 'blocked' scope in 'Member' class
merge_request: 61108
author:
type: fixed
...@@ -143,16 +143,10 @@ RSpec.describe Member do ...@@ -143,16 +143,10 @@ RSpec.describe Member do
@blocked_maintainer = project.members.find_by(user_id: @blocked_maintainer_user.id, access_level: Gitlab::Access::MAINTAINER) @blocked_maintainer = project.members.find_by(user_id: @blocked_maintainer_user.id, access_level: Gitlab::Access::MAINTAINER)
@blocked_developer = project.members.find_by(user_id: @blocked_developer_user.id, access_level: Gitlab::Access::DEVELOPER) @blocked_developer = project.members.find_by(user_id: @blocked_developer_user.id, access_level: Gitlab::Access::DEVELOPER)
@invited_member = create(:project_member, :developer, @invited_member = create(:project_member, :invited, :developer, project: project)
project: project,
invite_token: '1234',
invite_email: 'toto1@example.com')
accepted_invite_user = build(:user, state: :active) accepted_invite_user = build(:user, state: :active)
@accepted_invite_member = create(:project_member, :developer, @accepted_invite_member = create(:project_member, :invited, :developer, project: project)
project: project,
invite_token: '1234',
invite_email: 'toto2@example.com')
.tap { |u| u.accept_invite!(accepted_invite_user) } .tap { |u| u.accept_invite!(accepted_invite_user) }
requested_user = create(:user).tap { |u| project.request_access(u) } requested_user = create(:user).tap { |u| project.request_access(u) }
...@@ -325,12 +319,12 @@ RSpec.describe Member do ...@@ -325,12 +319,12 @@ RSpec.describe Member do
describe '.search_invite_email' do describe '.search_invite_email' do
it 'returns only members the matching e-mail' do it 'returns only members the matching e-mail' do
create(:group_member, :invited) invited_member = create(:group_member, :invited, invite_email: 'invited@example.com')
invited = described_class.search_invite_email(@invited_member.invite_email) invited = described_class.search_invite_email(invited_member.invite_email)
expect(invited.count).to eq(1) expect(invited.count).to eq(1)
expect(invited.first).to eq(@invited_member) expect(invited.first).to eq(invited_member)
expect(described_class.search_invite_email('bad-email@example.com').count).to eq(0) expect(described_class.search_invite_email('bad-email@example.com').count).to eq(0)
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