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
98a06985
Commit
98a06985
authored
Sep 16, 2021
by
Magdalena Frankiewicz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Skip commit email validation if it is private token
Add test
parent
5b2f000e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
3 deletions
+12
-3
app/models/user.rb
app/models/user.rb
+3
-3
spec/models/user_spec.rb
spec/models/user_spec.rb
+9
-0
No files found.
app/models/user.rb
View file @
98a06985
...
...
@@ -231,7 +231,7 @@ class User < ApplicationRecord
validates
:email
,
confirmation:
true
validates
:notification_email
,
devise_email:
true
,
allow_blank:
true
,
if:
->
(
user
)
{
user
.
notification_email
!=
user
.
email
}
validates
:public_email
,
uniqueness:
true
,
devise_email:
true
,
allow_blank:
true
validates
:commit_email
,
devise_email:
true
,
allow_blank:
true
,
if:
->
(
user
)
{
user
.
commit_email
!=
user
.
email
}
validates
:commit_email
,
devise_email:
true
,
allow_blank:
true
,
if:
->
(
user
)
{
user
.
commit_email
!=
user
.
email
&&
user
.
commit_email
!=
Gitlab
::
PrivateCommitEmail
::
TOKEN
}
validates
:projects_limit
,
presence:
true
,
numericality:
{
greater_than_or_equal_to:
0
,
less_than_or_equal_to:
Gitlab
::
Database
::
MAX_INT_VALUE
}
...
...
@@ -2005,7 +2005,7 @@ class User < ApplicationRecord
def
notification_email_verified
return
if
notification_email
.
blank?
||
temp_oauth_email?
errors
.
add
(
:notification_email
,
_
(
"must be an email you have verified"
))
unless
verified_emails
.
include?
(
notification_email
)
errors
.
add
(
:notification_email
,
_
(
"must be an email you have verified"
))
unless
verified_emails
.
include?
(
notification_email
_or_default
)
end
def
public_email_verified
...
...
@@ -2017,7 +2017,7 @@ class User < ApplicationRecord
def
commit_email_verified
return
if
commit_email
.
blank?
errors
.
add
(
:commit_email
,
_
(
"must be an email you have verified"
))
unless
verified_emails
.
include?
(
commit_email
)
errors
.
add
(
:commit_email
,
_
(
"must be an email you have verified"
))
unless
verified_emails
.
include?
(
commit_email
_or_default
)
end
def
callout_dismissed?
(
callout
,
ignore_dismissal_earlier_than
)
...
...
spec/models/user_spec.rb
View file @
98a06985
...
...
@@ -703,6 +703,15 @@ RSpec.describe User do
expect
(
user
).
to
be_valid
end
end
context
'when commit_email is changed to _private'
do
it
'passes user validations'
do
user
=
create
(
:user
)
user
.
commit_email
=
'_private'
expect
(
user
).
to
be_valid
end
end
end
end
...
...
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