Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
5520516a
Commit
5520516a
authored
Mar 31, 2020
by
Lee Tickett
Committed by
Thong Kuah
Mar 31, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check if user is an int before passing to find_by_id
parent
a6b7f91b
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
1 deletion
+19
-1
app/models/member.rb
app/models/member.rb
+3
-1
changelogs/unreleased/handle_inviting_members_whose_emails_start_with_numbers.yml
...ndle_inviting_members_whose_emails_start_with_numbers.yml
+5
-0
spec/models/member_spec.rb
spec/models/member_spec.rb
+11
-0
No files found.
app/models/member.rb
View file @
5520516a
...
@@ -257,7 +257,9 @@ class Member < ApplicationRecord
...
@@ -257,7 +257,9 @@ class Member < ApplicationRecord
def
retrieve_user
(
user
)
def
retrieve_user
(
user
)
return
user
if
user
.
is_a?
(
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
end
def
retrieve_member
(
source
,
user
,
existing_members
)
def
retrieve_member
(
source
,
user
,
existing_members
)
...
...
changelogs/unreleased/handle_inviting_members_whose_emails_start_with_numbers.yml
0 → 100644
View file @
5520516a
---
title
:
Fix bug inviting members whose emails start with numbers
merge_request
:
27848
author
:
Lee Tickett
type
:
fixed
spec/models/member_spec.rb
View file @
5520516a
...
@@ -342,6 +342,17 @@ describe Member do
...
@@ -342,6 +342,17 @@ describe Member do
expect
(
source
.
members
.
invite
.
pluck
(
:invite_email
)).
to
include
(
'user@example.com'
)
expect
(
source
.
members
.
invite
.
pluck
(
:invite_email
)).
to
include
(
'user@example.com'
)
end
end
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
end
context
'when current_user can update member'
do
context
'when current_user can update member'
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment