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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
b1ce2eb1
Commit
b1ce2eb1
authored
May 23, 2016
by
Semyon Pupkov
Committed by
Semyon Pupkov
Oct 23, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor(email): use setter method instead AR callbacks
parent
a98ad03b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
4 deletions
+8
-4
CHANGELOG.md
CHANGELOG.md
+1
-0
app/models/email.rb
app/models/email.rb
+2
-4
spec/models/email_spec.rb
spec/models/email_spec.rb
+5
-0
No files found.
CHANGELOG.md
View file @
b1ce2eb1
...
...
@@ -10,6 +10,7 @@ Please view this file on the master branch, on stable branches it's out of date.
-
Use MergeRequestsClosingIssues cache data on Issue#closed_by_merge_requests method
-
Fix documents and comments on Build API
`scope`
-
Refactor email, use setter method instead AR callbacks for email attribute (Semyon Pupkov)
## 8.13.1 (unreleased)
-
Fix error in generating labels
...
...
app/models/email.rb
View file @
b1ce2eb1
...
...
@@ -7,10 +7,8 @@ class Email < ActiveRecord::Base
validates
:email
,
presence:
true
,
uniqueness:
true
,
email:
true
validate
:unique_email
,
if:
->
(
email
)
{
email
.
email_changed?
}
before_validation
:cleanup_email
def
cleanup_email
self
.
email
=
self
.
email
.
downcase
.
strip
def
email
=
(
value
)
write_attribute
(
:email
,
value
.
downcase
.
strip
)
end
def
unique_email
...
...
spec/models/email_spec.rb
View file @
b1ce2eb1
...
...
@@ -6,4 +6,9 @@ describe Email, models: true do
subject
{
build
(
:email
)
}
end
end
it
'normalize email value'
do
expect
(
described_class
.
new
(
email:
' inFO@exAMPLe.com '
).
email
)
.
to
eq
'info@example.com'
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