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
Tatuya Kamada
gitlab-ce
Commits
26cedc7e
Commit
26cedc7e
authored
Jan 09, 2016
by
Zeger-Jan van de Weg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor improvements, unsubscribe from email footer
parent
36d858bc
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
23 deletions
+23
-23
app/controllers/sent_notifications_controller.rb
app/controllers/sent_notifications_controller.rb
+2
-2
app/mailers/emails/notes.rb
app/mailers/emails/notes.rb
+4
-4
config/routes.rb
config/routes.rb
+1
-1
spec/mailers/notify_spec.rb
spec/mailers/notify_spec.rb
+16
-16
No files found.
app/controllers/sent_notifications_controller.rb
View file @
26cedc7e
...
@@ -3,14 +3,14 @@ class SentNotificationsController < ApplicationController
...
@@ -3,14 +3,14 @@ class SentNotificationsController < ApplicationController
def
unsubscribe
def
unsubscribe
@sent_notification
=
SentNotification
.
for
(
params
[
:id
])
@sent_notification
=
SentNotification
.
for
(
params
[
:id
])
return
render_404
unless
@sent_notification
&&
!
@sent_notification
.
for_commit
?
return
render_404
unless
@sent_notification
&&
@sent_notification
.
can_unsubscribe
?
noteable
=
@sent_notification
.
noteable
noteable
=
@sent_notification
.
noteable
noteable
.
unsubscribe
(
@sent_notification
.
recipient
)
noteable
.
unsubscribe
(
@sent_notification
.
recipient
)
flash
[
:notice
]
=
"You have been unsubscribed from this thread."
flash
[
:notice
]
=
"You have been unsubscribed from this thread."
if
current_user
if
current_user
case
@sent_notification
.
noteable
case
noteable
when
Issue
when
Issue
redirect_to
issue_path
(
noteable
)
redirect_to
issue_path
(
noteable
)
when
MergeRequest
when
MergeRequest
...
...
app/mailers/emails/notes.rb
View file @
26cedc7e
module
Emails
module
Emails
module
Notes
module
Notes
def
note_commit_email
(
recipient_id
,
note_id
)
def
note_commit_email
(
recipient_id
,
note_id
)
note_mail_with_notification
(
note_id
,
recipient_id
)
setup_note_mail
(
note_id
,
recipient_id
)
@commit
=
@note
.
noteable
@commit
=
@note
.
noteable
@target_url
=
namespace_project_commit_url
(
*
note_target_url_options
)
@target_url
=
namespace_project_commit_url
(
*
note_target_url_options
)
...
@@ -13,7 +13,7 @@ module Emails
...
@@ -13,7 +13,7 @@ module Emails
end
end
def
note_issue_email
(
recipient_id
,
note_id
)
def
note_issue_email
(
recipient_id
,
note_id
)
note_mail_with_notification
(
note_id
,
recipient_id
)
setup_note_mail
(
note_id
,
recipient_id
)
@issue
=
@note
.
noteable
@issue
=
@note
.
noteable
@target_url
=
namespace_project_issue_url
(
*
note_target_url_options
)
@target_url
=
namespace_project_issue_url
(
*
note_target_url_options
)
...
@@ -21,7 +21,7 @@ module Emails
...
@@ -21,7 +21,7 @@ module Emails
end
end
def
note_merge_request_email
(
recipient_id
,
note_id
)
def
note_merge_request_email
(
recipient_id
,
note_id
)
note_mail_with_notification
(
note_id
,
recipient_id
)
setup_note_mail
(
note_id
,
recipient_id
)
@merge_request
=
@note
.
noteable
@merge_request
=
@note
.
noteable
@target_url
=
namespace_project_merge_request_url
(
*
note_target_url_options
)
@target_url
=
namespace_project_merge_request_url
(
*
note_target_url_options
)
...
@@ -42,7 +42,7 @@ module Emails
...
@@ -42,7 +42,7 @@ module Emails
}
}
end
end
def
note_mail_with_notification
(
note_id
,
recipient_id
)
def
setup_note_mail
(
note_id
,
recipient_id
)
@note
=
Note
.
find
(
note_id
)
@note
=
Note
.
find
(
note_id
)
@project
=
@note
.
project
@project
=
@note
.
project
...
...
config/routes.rb
View file @
26cedc7e
...
@@ -88,7 +88,7 @@ Rails.application.routes.draw do
...
@@ -88,7 +88,7 @@ Rails.application.routes.draw do
end
end
end
end
resources
:sent_notifications
,
only:
[],
constraints:
{
id:
/
[0-9a-f]
{32}/
}
do
resources
:sent_notifications
,
only:
[],
constraints:
{
id:
/
\h
{32}/
}
do
member
do
member
do
get
:unsubscribe
get
:unsubscribe
end
end
...
...
spec/mailers/notify_spec.rb
View file @
26cedc7e
...
@@ -108,7 +108,7 @@ describe Notify do
...
@@ -108,7 +108,7 @@ describe Notify do
it
{
is_expected
.
to
have_body_text
/unsubscribe/
}
it
{
is_expected
.
to
have_body_text
/unsubscribe/
}
end
end
shared_examples
"a user can
not unsubscribe through footer link"
do
shared_examples
"a user cannot unsubscribe through footer link"
do
it
{
is_expected
.
not_to
have_body_text
/unsubscribe/
}
it
{
is_expected
.
not_to
have_body_text
/unsubscribe/
}
end
end
...
@@ -123,7 +123,7 @@ describe Notify do
...
@@ -123,7 +123,7 @@ describe Notify do
it_behaves_like
'an email sent from GitLab'
it_behaves_like
'an email sent from GitLab'
it_behaves_like
'a new user email'
,
new_user_address
it_behaves_like
'a new user email'
,
new_user_address
it_behaves_like
'it should not have Gmail Actions links'
it_behaves_like
'it should not have Gmail Actions links'
it_behaves_like
'a user can
not unsubscribe through footer link'
it_behaves_like
'a user cannot unsubscribe through footer link'
it
'contains the password text'
do
it
'contains the password text'
do
is_expected
.
to
have_body_text
/Click here to set your password/
is_expected
.
to
have_body_text
/Click here to set your password/
...
@@ -152,7 +152,7 @@ describe Notify do
...
@@ -152,7 +152,7 @@ describe Notify do
it_behaves_like
'an email sent from GitLab'
it_behaves_like
'an email sent from GitLab'
it_behaves_like
'a new user email'
,
new_user_address
it_behaves_like
'a new user email'
,
new_user_address
it_behaves_like
'it should not have Gmail Actions links'
it_behaves_like
'it should not have Gmail Actions links'
it_behaves_like
'a user can
not unsubscribe through footer link'
it_behaves_like
'a user cannot unsubscribe through footer link'
it
'should not contain the new user\'s password'
do
it
'should not contain the new user\'s password'
do
is_expected
.
not_to
have_body_text
/password/
is_expected
.
not_to
have_body_text
/password/
...
@@ -166,7 +166,7 @@ describe Notify do
...
@@ -166,7 +166,7 @@ describe Notify do
it_behaves_like
'an email sent from GitLab'
it_behaves_like
'an email sent from GitLab'
it_behaves_like
'it should not have Gmail Actions links'
it_behaves_like
'it should not have Gmail Actions links'
it_behaves_like
'a user can
not unsubscribe through footer link'
it_behaves_like
'a user cannot unsubscribe through footer link'
it
'is sent to the new user'
do
it
'is sent to the new user'
do
is_expected
.
to
deliver_to
key
.
user
.
email
is_expected
.
to
deliver_to
key
.
user
.
email
...
@@ -191,7 +191,7 @@ describe Notify do
...
@@ -191,7 +191,7 @@ describe Notify do
subject
{
Notify
.
new_email_email
(
email
.
id
)
}
subject
{
Notify
.
new_email_email
(
email
.
id
)
}
it_behaves_like
'it should not have Gmail Actions links'
it_behaves_like
'it should not have Gmail Actions links'
it_behaves_like
'a user can
not unsubscribe through footer link'
it_behaves_like
'a user cannot unsubscribe through footer link'
it
'is sent to the new user'
do
it
'is sent to the new user'
do
is_expected
.
to
deliver_to
email
.
user
.
email
is_expected
.
to
deliver_to
email
.
user
.
email
...
@@ -465,7 +465,7 @@ describe Notify do
...
@@ -465,7 +465,7 @@ describe Notify do
it_behaves_like
'an email sent from GitLab'
it_behaves_like
'an email sent from GitLab'
it_behaves_like
'it should not have Gmail Actions links'
it_behaves_like
'it should not have Gmail Actions links'
it_behaves_like
"a user can
not unsubscribe through footer link"
it_behaves_like
"a user cannot unsubscribe through footer link"
it
'has the correct subject'
do
it
'has the correct subject'
do
is_expected
.
to
have_subject
/Project was moved/
is_expected
.
to
have_subject
/Project was moved/
...
@@ -488,7 +488,7 @@ describe Notify do
...
@@ -488,7 +488,7 @@ describe Notify do
it_behaves_like
'an email sent from GitLab'
it_behaves_like
'an email sent from GitLab'
it_behaves_like
'it should not have Gmail Actions links'
it_behaves_like
'it should not have Gmail Actions links'
it_behaves_like
"a user can
not unsubscribe through footer link"
it_behaves_like
"a user cannot unsubscribe through footer link"
it
'has the correct subject'
do
it
'has the correct subject'
do
is_expected
.
to
have_subject
/Access to project was granted/
is_expected
.
to
have_subject
/Access to project was granted/
...
@@ -539,7 +539,7 @@ describe Notify do
...
@@ -539,7 +539,7 @@ describe Notify do
it_behaves_like
'a note email'
it_behaves_like
'a note email'
it_behaves_like
'an answer to an existing thread'
,
'commit'
it_behaves_like
'an answer to an existing thread'
,
'commit'
it_behaves_like
'it should show Gmail Actions View Commit link'
it_behaves_like
'it should show Gmail Actions View Commit link'
it_behaves_like
"a user can
not unsubscribe through footer link"
it_behaves_like
"a user cannot unsubscribe through footer link"
it
'has the correct subject'
do
it
'has the correct subject'
do
is_expected
.
to
have_subject
/
#{
commit
.
title
}
\(
#{
commit
.
short_id
}
\)/
is_expected
.
to
have_subject
/
#{
commit
.
title
}
\(
#{
commit
.
short_id
}
\)/
...
@@ -603,7 +603,7 @@ describe Notify do
...
@@ -603,7 +603,7 @@ describe Notify do
it_behaves_like
'an email sent from GitLab'
it_behaves_like
'an email sent from GitLab'
it_behaves_like
'it should not have Gmail Actions links'
it_behaves_like
'it should not have Gmail Actions links'
it_behaves_like
"a user can
not unsubscribe through footer link"
it_behaves_like
"a user cannot unsubscribe through footer link"
it
'has the correct subject'
do
it
'has the correct subject'
do
is_expected
.
to
have_subject
/Access to group was granted/
is_expected
.
to
have_subject
/Access to group was granted/
...
@@ -632,7 +632,7 @@ describe Notify do
...
@@ -632,7 +632,7 @@ describe Notify do
subject
{
ActionMailer
::
Base
.
deliveries
.
last
}
subject
{
ActionMailer
::
Base
.
deliveries
.
last
}
it_behaves_like
'an email sent from GitLab'
it_behaves_like
'an email sent from GitLab'
it_behaves_like
"a user can
not unsubscribe through footer link"
it_behaves_like
"a user cannot unsubscribe through footer link"
it
'is sent to the new user'
do
it
'is sent to the new user'
do
is_expected
.
to
deliver_to
'new-email@mail.com'
is_expected
.
to
deliver_to
'new-email@mail.com'
...
@@ -655,7 +655,7 @@ describe Notify do
...
@@ -655,7 +655,7 @@ describe Notify do
subject
{
Notify
.
repository_push_email
(
project
.
id
,
'devs@company.name'
,
author_id:
user
.
id
,
ref:
'refs/heads/master'
,
action: :create
)
}
subject
{
Notify
.
repository_push_email
(
project
.
id
,
'devs@company.name'
,
author_id:
user
.
id
,
ref:
'refs/heads/master'
,
action: :create
)
}
it_behaves_like
'it should not have Gmail Actions links'
it_behaves_like
'it should not have Gmail Actions links'
it_behaves_like
"a user can
not unsubscribe through footer link"
it_behaves_like
"a user cannot unsubscribe through footer link"
it
'is sent as the author'
do
it
'is sent as the author'
do
sender
=
subject
.
header
[
:from
].
addrs
[
0
]
sender
=
subject
.
header
[
:from
].
addrs
[
0
]
...
@@ -684,7 +684,7 @@ describe Notify do
...
@@ -684,7 +684,7 @@ describe Notify do
subject
{
Notify
.
repository_push_email
(
project
.
id
,
'devs@company.name'
,
author_id:
user
.
id
,
ref:
'refs/tags/v1.0'
,
action: :create
)
}
subject
{
Notify
.
repository_push_email
(
project
.
id
,
'devs@company.name'
,
author_id:
user
.
id
,
ref:
'refs/tags/v1.0'
,
action: :create
)
}
it_behaves_like
'it should not have Gmail Actions links'
it_behaves_like
'it should not have Gmail Actions links'
it_behaves_like
"a user can
not unsubscribe through footer link"
it_behaves_like
"a user cannot unsubscribe through footer link"
it
'is sent as the author'
do
it
'is sent as the author'
do
sender
=
subject
.
header
[
:from
].
addrs
[
0
]
sender
=
subject
.
header
[
:from
].
addrs
[
0
]
...
@@ -712,7 +712,7 @@ describe Notify do
...
@@ -712,7 +712,7 @@ describe Notify do
subject
{
Notify
.
repository_push_email
(
project
.
id
,
'devs@company.name'
,
author_id:
user
.
id
,
ref:
'refs/heads/master'
,
action: :delete
)
}
subject
{
Notify
.
repository_push_email
(
project
.
id
,
'devs@company.name'
,
author_id:
user
.
id
,
ref:
'refs/heads/master'
,
action: :delete
)
}
it_behaves_like
'it should not have Gmail Actions links'
it_behaves_like
'it should not have Gmail Actions links'
it_behaves_like
"a user can
not unsubscribe through footer link"
it_behaves_like
"a user cannot unsubscribe through footer link"
it
'is sent as the author'
do
it
'is sent as the author'
do
sender
=
subject
.
header
[
:from
].
addrs
[
0
]
sender
=
subject
.
header
[
:from
].
addrs
[
0
]
...
@@ -736,7 +736,7 @@ describe Notify do
...
@@ -736,7 +736,7 @@ describe Notify do
subject
{
Notify
.
repository_push_email
(
project
.
id
,
'devs@company.name'
,
author_id:
user
.
id
,
ref:
'refs/tags/v1.0'
,
action: :delete
)
}
subject
{
Notify
.
repository_push_email
(
project
.
id
,
'devs@company.name'
,
author_id:
user
.
id
,
ref:
'refs/tags/v1.0'
,
action: :delete
)
}
it_behaves_like
'it should not have Gmail Actions links'
it_behaves_like
'it should not have Gmail Actions links'
it_behaves_like
"a user can
not unsubscribe through footer link"
it_behaves_like
"a user cannot unsubscribe through footer link"
it
'is sent as the author'
do
it
'is sent as the author'
do
sender
=
subject
.
header
[
:from
].
addrs
[
0
]
sender
=
subject
.
header
[
:from
].
addrs
[
0
]
...
@@ -764,7 +764,7 @@ describe Notify do
...
@@ -764,7 +764,7 @@ describe Notify do
subject
{
Notify
.
repository_push_email
(
project
.
id
,
'devs@company.name'
,
author_id:
user
.
id
,
ref:
'refs/heads/master'
,
action: :push
,
compare:
compare
,
reverse_compare:
false
,
send_from_committer_email:
send_from_committer_email
)
}
subject
{
Notify
.
repository_push_email
(
project
.
id
,
'devs@company.name'
,
author_id:
user
.
id
,
ref:
'refs/heads/master'
,
action: :push
,
compare:
compare
,
reverse_compare:
false
,
send_from_committer_email:
send_from_committer_email
)
}
it_behaves_like
'it should not have Gmail Actions links'
it_behaves_like
'it should not have Gmail Actions links'
it_behaves_like
"a user can
not unsubscribe through footer link"
it_behaves_like
"a user cannot unsubscribe through footer link"
it
'is sent as the author'
do
it
'is sent as the author'
do
sender
=
subject
.
header
[
:from
].
addrs
[
0
]
sender
=
subject
.
header
[
:from
].
addrs
[
0
]
...
@@ -870,7 +870,7 @@ describe Notify do
...
@@ -870,7 +870,7 @@ describe Notify do
subject
{
Notify
.
repository_push_email
(
project
.
id
,
'devs@company.name'
,
author_id:
user
.
id
,
ref:
'refs/heads/master'
,
action: :push
,
compare:
compare
)
}
subject
{
Notify
.
repository_push_email
(
project
.
id
,
'devs@company.name'
,
author_id:
user
.
id
,
ref:
'refs/heads/master'
,
action: :push
,
compare:
compare
)
}
it_behaves_like
'it should show Gmail Actions View Commit link'
it_behaves_like
'it should show Gmail Actions View Commit link'
it_behaves_like
"a user can
not unsubscribe through footer link"
it_behaves_like
"a user cannot unsubscribe through footer link"
it
'is sent as the author'
do
it
'is sent as the author'
do
sender
=
subject
.
header
[
:from
].
addrs
[
0
]
sender
=
subject
.
header
[
:from
].
addrs
[
0
]
...
...
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