Commit 420f1907 authored by Thong Kuah's avatar Thong Kuah

Merge branch 'handle_inviting_members_whose_emails_start_with_numbers' into 'master'

Handle inviting members whose emails start with numbers

Closes #212142

See merge request gitlab-org/gitlab!27848
parents 3e965e07 5520516a
......@@ -257,7 +257,9 @@ class Member < ApplicationRecord
def retrieve_user(user)
return user if user.is_a?(User)
User.find_by(id: user) || User.find_by(email: user) || user
return User.find_by(id: user) if user.is_a?(Integer)
User.find_by(email: user) || user
end
def retrieve_member(source, user, existing_members)
......
---
title: Fix bug inviting members whose emails start with numbers
merge_request: 27848
author: Lee Tickett
type: fixed
......@@ -342,6 +342,17 @@ describe Member do
expect(source.members.invite.pluck(:invite_email)).to include('user@example.com')
end
end
context 'when called with an unknown user email starting with a number' do
it 'creates an invited member', :aggregate_failures do
email_starting_with_number = "#{user.id}_email@example.com"
described_class.add_user(source, email_starting_with_number, :maintainer)
expect(source.members.invite.pluck(:invite_email)).to include(email_starting_with_number)
expect(source.users.reload).not_to include(user)
end
end
end
context 'when current_user can update member' 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