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
cf8a5bca
Commit
cf8a5bca
authored
Sep 09, 2017
by
Brett Walker
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add verified/unverified labels to profile emails.
added "Resend confirmation email" for unverified emails
parent
c56208f9
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
83 additions
and
10 deletions
+83
-10
app/controllers/profiles/emails_controller.rb
app/controllers/profiles/emails_controller.rb
+10
-0
app/services/emails/confirm_service.rb
app/services/emails/confirm_service.rb
+7
-0
app/views/profiles/emails/index.html.haml
app/views/profiles/emails/index.html.haml
+9
-4
config/routes/profile.rb
config/routes/profile.rb
+5
-1
spec/controllers/profiles/emails_controller_spec.rb
spec/controllers/profiles/emails_controller_spec.rb
+15
-0
spec/features/profiles/emails_spec.rb
spec/features/profiles/emails_spec.rb
+21
-5
spec/services/emails/confirm_service_spec.rb
spec/services/emails/confirm_service_spec.rb
+16
-0
No files found.
app/controllers/profiles/emails_controller.rb
View file @
cf8a5bca
...
@@ -24,6 +24,16 @@ class Profiles::EmailsController < Profiles::ApplicationController
...
@@ -24,6 +24,16 @@ class Profiles::EmailsController < Profiles::ApplicationController
end
end
end
end
def
resend_confirmation_instructions
@email
=
current_user
.
emails
.
find
(
params
[
:id
])
if
@email
&&
Emails
::
ConfirmService
.
new
(
current_user
,
email:
@email
.
email
).
execute
flash
[
:notice
]
=
"Confirmation email sent to
#{
@email
.
email
}
"
else
flash
[
:alert
]
=
"There was a problem sending the confirmation email"
end
redirect_to
profile_emails_url
end
private
private
def
email_params
def
email_params
...
...
app/services/emails/confirm_service.rb
0 → 100644
View file @
cf8a5bca
module
Emails
class
ConfirmService
<
::
Emails
::
BaseService
def
execute
Email
.
find_by_email!
(
@email
).
resend_confirmation_instructions
end
end
end
app/views/profiles/emails/index.html.haml
View file @
cf8a5bca
...
@@ -32,7 +32,7 @@
...
@@ -32,7 +32,7 @@
All email addresses will be used to identify your commits.
All email addresses will be used to identify your commits.
%ul
.well-list
%ul
.well-list
%li
%li
=
@primary
=
render
partial:
'shared/email_with_badge'
,
locals:
{
email:
@primary
,
verified:
current_user
.
confirmed?
}
%span
.pull-right
%span
.pull-right
%span
.label.label-success
Primary email
%span
.label.label-success
Primary email
-
if
@primary
===
current_user
.
public_email
-
if
@primary
===
current_user
.
public_email
...
@@ -41,12 +41,17 @@
...
@@ -41,12 +41,17 @@
%span
.label.label-info
Notification email
%span
.label.label-info
Notification email
-
@emails
.
each
do
|
email
|
-
@emails
.
each
do
|
email
|
%li
%li
=
email
.
email
=
render
partial:
'shared/email_with_badge'
,
locals:
{
email:
email
.
email
,
verified:
email
.
confirmed?
}
%span
.pull-right
%span
.pull-right
-
if
email
.
email
===
current_user
.
public_email
-
if
email
.
email
===
current_user
.
public_email
%span
.label.label-info
Public email
%span
.label.label-info
Public email
-
if
email
.
email
===
current_user
.
notification_email
-
if
email
.
email
===
current_user
.
notification_email
%span
.label.label-info
Notification email
%span
.label.label-info
Notification email
-
unless
email
.
confirmed?
-
unless
email
.
confirmed?
%span
.label.label-warning
Unconfirmed
-
confirm_title
=
"
#{
email
.
confirmation_sent_at
?
'Resend'
:
'Send'
}
confirmation email"
=
link_to
'Remove'
,
profile_email_path
(
email
),
data:
{
confirm:
'Are you sure?'
},
method: :delete
,
class:
'btn btn-sm btn-warning prepend-left-10'
=
link_to
confirm_title
,
resend_confirmation_instructions_profile_email_path
(
email
),
method: :put
,
class:
'btn btn-sm btn-warning prepend-left-10'
=
link_to
profile_email_path
(
email
),
data:
{
confirm:
'Are you sure?'
},
method: :delete
,
class:
'btn btn-sm btn-danger prepend-left-10'
do
%span
.sr-only
Remove
=
icon
(
'trash'
)
config/routes/profile.rb
View file @
cf8a5bca
...
@@ -28,7 +28,11 @@ resource :profile, only: [:show, :update] do
...
@@ -28,7 +28,11 @@ resource :profile, only: [:show, :update] do
put
:revoke
put
:revoke
end
end
end
end
resources
:emails
,
only:
[
:index
,
:create
,
:destroy
]
resources
:emails
,
only:
[
:index
,
:create
,
:destroy
]
do
member
do
put
:resend_confirmation_instructions
end
end
resources
:chat_names
,
only:
[
:index
,
:new
,
:create
,
:destroy
]
do
resources
:chat_names
,
only:
[
:index
,
:new
,
:create
,
:destroy
]
do
collection
do
collection
do
delete
:deny
delete
:deny
...
...
spec/controllers/profiles/emails_controller_spec.rb
View file @
cf8a5bca
...
@@ -17,4 +17,19 @@ describe Profiles::EmailsController do
...
@@ -17,4 +17,19 @@ describe Profiles::EmailsController do
expect
(
ActionMailer
::
Base
.
deliveries
.
last
.
subject
).
to
match
"Confirmation instructions"
expect
(
ActionMailer
::
Base
.
deliveries
.
last
.
subject
).
to
match
"Confirmation instructions"
end
end
end
end
describe
'#resend_confirmation_instructions'
do
let
(
:email_params
)
{
{
email:
"add_email@example.com"
}
}
it
'resends an email confirmation'
do
email
=
user
.
emails
.
create
(
email:
'add_email@example.com'
)
expect
{
put
(
:resend_confirmation_instructions
,
{
id:
email
})}.
to
change
{
ActionMailer
::
Base
.
deliveries
.
size
}
expect
(
ActionMailer
::
Base
.
deliveries
.
last
.
to
).
to
eq
[
email_params
[
:email
]]
expect
(
ActionMailer
::
Base
.
deliveries
.
last
.
subject
).
to
match
"Confirmation instructions"
end
it
'unable to resend an email confirmation'
do
expect
{
put
(
:resend_confirmation_instructions
,
{
id:
1
})}.
to_not
change
{
ActionMailer
::
Base
.
deliveries
.
size
}
end
end
end
end
spec/features/profiles/emails_spec.rb
View file @
cf8a5bca
...
@@ -17,8 +17,8 @@ feature 'Profile > Emails' do
...
@@ -17,8 +17,8 @@ feature 'Profile > Emails' do
click_button
(
'Add email address'
)
click_button
(
'Add email address'
)
expect
(
page
).
to
have_content
(
'my@email.com Unverified'
)
expect
(
page
).
to
have_content
(
'my@email.com Unverified'
)
expect
(
page
).
to
have_content
(
'user1@example.org Verified'
)
expect
(
page
).
to
have_content
(
"
#{
user
.
email
}
Verified"
)
expect
(
page
).
to
have_content
(
'Resend
Confirmation E
mail'
)
expect
(
page
).
to
have_content
(
'Resend
confirmation e
mail'
)
end
end
scenario
'does not add a duplicate email'
do
scenario
'does not add a duplicate email'
do
...
@@ -43,14 +43,30 @@ feature 'Profile > Emails' do
...
@@ -43,14 +43,30 @@ feature 'Profile > Emails' do
scenario
'User confirms email'
do
scenario
'User confirms email'
do
email
=
user
.
emails
.
create
(
email:
'my@email.com'
)
email
=
user
.
emails
.
create
(
email:
'my@email.com'
)
visit
profile_emails_path
visit
profile_emails_path
expect
(
page
).
to
have_content
(
"
my@email.com
Unverified"
)
expect
(
page
).
to
have_content
(
"
#{
email
.
email
}
Unverified"
)
email
.
confirm
email
.
confirm
expect
(
email
.
confirmed?
).
to
be_truthy
expect
(
email
.
confirmed?
).
to
be_truthy
visit
profile_emails_path
visit
profile_emails_path
expect
(
page
).
to
have_content
(
"my@email.com Verified"
)
expect
(
page
).
to
have_content
(
"
#{
email
.
email
}
Verified"
)
end
scenario
'User re-sends confirmation email'
do
email
=
user
.
emails
.
create
(
email:
'my@email.com'
)
visit
profile_emails_path
expect
{
click_link
(
"Resend confirmation email"
)
}.
to
change
{
ActionMailer
::
Base
.
deliveries
.
size
}
expect
(
page
).
to
have_content
(
"Confirmation email sent to
#{
email
.
email
}
"
)
end
scenario
'old unconfirmed emails show Send Confirmation button'
do
email
=
user
.
emails
.
create
(
email:
'my@email.com'
)
email
.
update_attribute
(
:confirmation_sent_at
,
nil
)
visit
profile_emails_path
expect
(
page
).
to_not
have_content
(
'Resend confirmation email'
)
expect
(
page
).
to
have_content
(
'Send confirmation email'
)
end
end
scenario
''
end
end
spec/services/emails/confirm_service_spec.rb
0 → 100644
View file @
cf8a5bca
require
'spec_helper'
describe
Emails
::
ConfirmService
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:opts
)
{
{
email:
'new@email.com'
}
}
subject
(
:service
)
{
described_class
.
new
(
user
,
opts
)
}
describe
'#execute'
do
it
'sends a confirmation email again'
do
email
=
user
.
emails
.
create
(
email:
opts
[
:email
])
mail
=
service
.
execute
expect
(
mail
.
subject
).
to
eq
(
'Confirmation instructions'
)
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