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
Kazuhiko Shiozaki
gitlab-ce
Commits
1b85cbc6
Commit
1b85cbc6
authored
May 15, 2012
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #824 from robbkidd/test_the_mailers
Spec Notify mailers
parents
be79c9de
991d23e2
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
324 additions
and
78 deletions
+324
-78
Gemfile
Gemfile
+1
-0
Gemfile.lock
Gemfile.lock
+4
-0
app/mailers/notify.rb
app/mailers/notify.rb
+39
-50
app/models/mailer_observer.rb
app/models/mailer_observer.rb
+11
-11
app/models/note.rb
app/models/note.rb
+4
-0
app/views/notify/new_issue_email.html.haml
app/views/notify/new_issue_email.html.haml
+1
-1
app/views/notify/new_merge_request_email.html.haml
app/views/notify/new_merge_request_email.html.haml
+2
-4
app/views/notify/note_commit_email.html.haml
app/views/notify/note_commit_email.html.haml
+2
-2
app/views/notify/note_issue_email.html.haml
app/views/notify/note_issue_email.html.haml
+2
-2
app/views/notify/note_merge_request_email.html.haml
app/views/notify/note_merge_request_email.html.haml
+2
-2
app/views/notify/note_wall_email.html.haml
app/views/notify/note_wall_email.html.haml
+2
-2
app/views/notify/reassigned_issue_email.html.haml
app/views/notify/reassigned_issue_email.html.haml
+2
-2
app/views/notify/reassigned_merge_request_email.html.haml
app/views/notify/reassigned_merge_request_email.html.haml
+2
-2
spec/mailers/notify_spec.rb
spec/mailers/notify_spec.rb
+249
-0
spec/spec_helper.rb
spec/spec_helper.rb
+1
-0
No files found.
Gemfile
View file @
1b85cbc6
...
@@ -66,4 +66,5 @@ group :test do
...
@@ -66,4 +66,5 @@ group :test do
gem
"
turn
"
,
:require
=>
false
gem
"
turn
"
,
:require
=>
false
gem
"
simplecov
"
,
:require
=>
false
gem
"
simplecov
"
,
:require
=>
false
gem
"
shoulda
"
,
"3.0.1"
gem
"
shoulda
"
,
"3.0.1"
gem
'
email_spec
'
end
end
Gemfile.lock
View file @
1b85cbc6
...
@@ -114,6 +114,9 @@ GEM
...
@@ -114,6 +114,9 @@ GEM
warden (~> 1.1)
warden (~> 1.1)
diff-lcs (1.1.3)
diff-lcs (1.1.3)
drapper (0.8.4)
drapper (0.8.4)
email_spec (1.2.1)
mail (~> 2.2)
rspec (~> 2.0)
erubis (2.7.0)
erubis (2.7.0)
escape_utils (0.2.4)
escape_utils (0.2.4)
eventmachine (0.12.10)
eventmachine (0.12.10)
...
@@ -330,6 +333,7 @@ DEPENDENCIES
...
@@ -330,6 +333,7 @@ DEPENDENCIES
database_cleaner
database_cleaner
devise (~> 1.5)
devise (~> 1.5)
drapper
drapper
email_spec
faker
faker
foreman
foreman
git
git
...
...
app/mailers/notify.rb
View file @
1b85cbc6
...
@@ -7,71 +7,60 @@ class Notify < ActionMailer::Base
...
@@ -7,71 +7,60 @@ class Notify < ActionMailer::Base
default
from:
EMAIL_OPTS
[
"from"
]
default
from:
EMAIL_OPTS
[
"from"
]
def
new_user_email
(
user
,
password
)
def
new_user_email
(
user
_id
,
password
)
@user
=
user
@user
=
User
.
find
(
user_id
)
@password
=
password
@password
=
password
mail
(
:to
=>
@user
[
'email'
]
,
:subject
=>
"gitlab | Account was created for you"
)
mail
(
:to
=>
@user
.
email
,
:subject
=>
"gitlab | Account was created for you"
)
end
end
def
new_issue_email
(
issue
)
def
new_issue_email
(
issue_id
)
@issue
=
Issue
.
find
(
issue
[
'id'
])
@issue
=
Issue
.
find
(
issue_id
)
@user
=
@issue
.
assignee
mail
(
:to
=>
@issue
.
assignee_email
,
:subject
=>
"gitlab | New Issue was created"
)
@project
=
@issue
.
project
mail
(
:to
=>
@user
.
email
,
:subject
=>
"gitlab | New Issue was created"
)
end
end
def
note_wall_email
(
user
,
note
)
def
note_wall_email
(
recipient_id
,
note_id
)
@user
=
user
recipient
=
User
.
find
(
recipient_id
)
@note
=
Note
.
find
(
note
[
'id'
])
@note
=
Note
.
find
(
note_id
)
@project
=
@note
.
project
mail
(
:to
=>
recipient
.
email
,
:subject
=>
"gitlab |
#{
@note
.
project_name
}
"
)
mail
(
:to
=>
@user
[
'email'
],
:subject
=>
"gitlab |
#{
@note
.
project
.
name
}
"
)
end
end
def
note_commit_email
(
user
,
note
)
def
note_commit_email
(
recipient_id
,
note_id
)
@user
=
user
recipient
=
User
.
find
(
recipient_id
)
@note
=
Note
.
find
(
note
[
'id'
])
@note
=
Note
.
find
(
note_id
)
@project
=
@note
.
project
@commit
=
@note
.
target
@commit
=
@note
.
target
mail
(
:to
=>
@user
[
'email'
],
:subject
=>
"gitlab | note for commit |
#{
@note
.
project
.
name
}
"
)
mail
(
:to
=>
recipient
.
email
,
:subject
=>
"gitlab | note for commit |
#{
@note
.
project_
name
}
"
)
end
end
def
note_merge_request_email
(
user
,
note
)
def
note_merge_request_email
(
recipient_id
,
note_id
)
@user
=
user
recipient
=
User
.
find
(
recipient_id
)
@note
=
Note
.
find
(
note
[
'id'
])
@note
=
Note
.
find
(
note_id
)
@project
=
@note
.
project
@merge_request
=
@note
.
noteable
@merge_request
=
@note
.
noteable
mail
(
:to
=>
@user
[
'email'
],
:subject
=>
"gitlab | note for merge request |
#{
@note
.
project
.
name
}
"
)
mail
(
:to
=>
recipient
.
email
,
:subject
=>
"gitlab | note for merge request |
#{
@note
.
project_
name
}
"
)
end
end
def
note_issue_email
(
user
,
note
)
def
note_issue_email
(
recipient_id
,
note_id
)
@user
=
user
recipient
=
User
.
find
(
recipient_id
)
@note
=
Note
.
find
(
note
[
'id'
])
@note
=
Note
.
find
(
note_id
)
@project
=
@note
.
project
@issue
=
@note
.
noteable
@issue
=
@note
.
noteable
mail
(
:to
=>
@user
[
'email'
],
:subject
=>
"gitlab | note for issue
#{
@issue
.
id
}
|
#{
@note
.
project
.
name
}
"
)
mail
(
:to
=>
recipient
.
email
,
:subject
=>
"gitlab | note for issue
#{
@issue
.
id
}
|
#{
@note
.
project_
name
}
"
)
end
end
def
new_merge_request_email
(
merge_request
)
def
new_merge_request_email
(
merge_request_id
)
@merge_request
=
MergeRequest
.
find
(
merge_request
[
'id'
])
@merge_request
=
MergeRequest
.
find
(
merge_request_id
)
@user
=
@merge_request
.
assignee
mail
(
:to
=>
@merge_request
.
assignee_email
,
:subject
=>
"gitlab | new merge request |
#{
@merge_request
.
title
}
"
)
@project
=
@merge_request
.
project
mail
(
:to
=>
@user
.
email
,
:subject
=>
"gitlab | new merge request |
#{
@merge_request
.
title
}
"
)
end
end
def
changed_merge_request_email
(
user
,
merge_request
)
def
reassigned_merge_request_email
(
recipient_id
,
merge_request_id
,
previous_assignee_id
)
@user
=
user
recipient
=
User
.
find
(
recipient_id
)
@merge_request
=
MergeRequest
.
find
(
merge_request
.
id
)
@merge_request
=
MergeRequest
.
find
(
merge_request_id
)
@assignee_was
||=
User
.
find
(
@merge_request
.
assignee_id_was
)
@previous_assignee
||=
User
.
find
(
previous_assignee_id
)
@project
=
@merge_request
.
project
mail
(
:to
=>
recipient
.
email
,
:subject
=>
"gitlab | merge request changed |
#{
@merge_request
.
title
}
"
)
mail
(
:to
=>
@user
[
'email'
],
:subject
=>
"gitlab | merge request changed |
#{
@merge_request
.
title
}
"
)
end
end
def
changed_issue_email
(
user
,
issue
)
def
reassigned_issue_email
(
recipient_id
,
issue_id
,
previous_assignee_id
)
@issue
=
Issue
.
find
(
issue
[
'id'
])
recipient
=
User
.
find
(
recipient_id
)
@user
=
user
@issue
=
Issue
.
find
(
issue_id
)
@assignee_was
||=
User
.
find
(
@issue
.
assignee_id_was
)
@previous_assignee
||=
User
.
find
(
previous_assignee_id
)
@project
=
@issue
.
project
mail
(
:to
=>
recipient
.
email
,
:subject
=>
"gitlab | changed issue |
#{
@issue
.
title
}
"
)
mail
(
:to
=>
@user
[
'email'
],
:subject
=>
"gitlab | changed issue |
#{
@issue
.
title
}
"
)
end
end
end
end
app/models/mailer_observer.rb
View file @
1b85cbc6
...
@@ -18,12 +18,12 @@ class MailerObserver < ActiveRecord::Observer
...
@@ -18,12 +18,12 @@ class MailerObserver < ActiveRecord::Observer
def
new_issue
(
issue
)
def
new_issue
(
issue
)
if
issue
.
assignee
!=
current_user
if
issue
.
assignee
!=
current_user
Notify
.
new_issue_email
(
issue
).
deliver
Notify
.
new_issue_email
(
issue
.
id
).
deliver
end
end
end
end
def
new_user
(
user
)
def
new_user
(
user
)
Notify
.
new_user_email
(
user
,
user
.
password
).
deliver
Notify
.
new_user_email
(
user
.
id
,
user
.
password
).
deliver
end
end
def
new_note
(
note
)
def
new_note
(
note
)
...
@@ -32,26 +32,26 @@ class MailerObserver < ActiveRecord::Observer
...
@@ -32,26 +32,26 @@ class MailerObserver < ActiveRecord::Observer
note
.
project
.
users
.
reject
{
|
u
|
u
.
id
==
current_user
.
id
}
.
each
do
|
u
|
note
.
project
.
users
.
reject
{
|
u
|
u
.
id
==
current_user
.
id
}
.
each
do
|
u
|
case
note
.
noteable_type
case
note
.
noteable_type
when
"Commit"
then
when
"Commit"
then
Notify
.
note_commit_email
(
u
,
note
).
deliver
Notify
.
note_commit_email
(
u
.
id
,
note
.
id
).
deliver
when
"Issue"
then
when
"Issue"
then
Notify
.
note_issue_email
(
u
,
note
).
deliver
Notify
.
note_issue_email
(
u
.
id
,
note
.
id
).
deliver
when
"MergeRequest"
then
when
"MergeRequest"
then
Notify
.
note_merge_request_email
(
u
,
note
).
deliver
Notify
.
note_merge_request_email
(
u
.
id
,
note
.
id
).
deliver
when
"Snippet"
when
"Snippet"
true
true
else
else
Notify
.
note_wall_email
(
u
,
note
).
deliver
Notify
.
note_wall_email
(
u
.
id
,
note
.
id
).
deliver
end
end
end
end
# Notify only author of resource
# Notify only author of resource
elsif
note
.
notify_author
elsif
note
.
notify_author
Notify
.
note_commit_email
(
note
.
commit_author
,
note
).
deliver
Notify
.
note_commit_email
(
note
.
commit_author
.
id
,
note
.
id
).
deliver
end
end
end
end
def
new_merge_request
(
merge_request
)
def
new_merge_request
(
merge_request
)
if
merge_request
.
assignee
!=
current_user
if
merge_request
.
assignee
!=
current_user
Notify
.
new_merge_request_email
(
merge_request
).
deliver
Notify
.
new_merge_request_email
(
merge_request
.
id
).
deliver
end
end
end
end
...
@@ -61,7 +61,7 @@ class MailerObserver < ActiveRecord::Observer
...
@@ -61,7 +61,7 @@ class MailerObserver < ActiveRecord::Observer
recipients_ids
.
delete
current_user
.
id
recipients_ids
.
delete
current_user
.
id
User
.
find
(
recipients_ids
).
each
do
|
user
|
User
.
find
(
recipients_ids
).
each
do
|
user
|
Notify
.
changed_merge_request_email
(
user
,
merge_request
).
deliver
Notify
.
reassigned_merge_request_email
(
user
.
id
,
merge_request
.
id
,
merge_request
.
assignee_id_was
).
deliver
end
end
end
end
...
@@ -78,8 +78,8 @@ class MailerObserver < ActiveRecord::Observer
...
@@ -78,8 +78,8 @@ class MailerObserver < ActiveRecord::Observer
recipients_ids
=
issue
.
assignee_id_was
,
issue
.
assignee_id
recipients_ids
=
issue
.
assignee_id_was
,
issue
.
assignee_id
recipients_ids
.
delete
current_user
.
id
recipients_ids
.
delete
current_user
.
id
User
.
find
(
recipients_ids
).
each
do
|
user
|
recipients_ids
.
each
do
|
recipient_id
|
Notify
.
changed_issue_email
(
user
,
issue
).
deliver
Notify
.
reassigned_issue_email
(
recipient_id
,
issue
.
id
,
issue
.
assignee_id_was
).
deliver
end
end
end
end
...
...
app/models/note.rb
View file @
1b85cbc6
...
@@ -7,6 +7,10 @@ class Note < ActiveRecord::Base
...
@@ -7,6 +7,10 @@ class Note < ActiveRecord::Base
belongs_to
:author
,
belongs_to
:author
,
:class_name
=>
"User"
:class_name
=>
"User"
delegate
:name
,
:to
=>
:project
,
:prefix
=>
true
delegate
:name
,
delegate
:name
,
:email
,
:email
,
:to
=>
:author
,
:to
=>
:author
,
...
...
app/views/notify/new_issue_email.html.haml
View file @
1b85cbc6
...
@@ -10,7 +10,7 @@
...
@@ -10,7 +10,7 @@
%td
{
:style
=>
"font-size: 1px; line-height: 1px;"
,
:width
=>
"21"
}
%td
{
:style
=>
"font-size: 1px; line-height: 1px;"
,
:width
=>
"21"
}
%td
{
:align
=>
"left"
,
:style
=>
"padding: 20px 0 0;"
}
%td
{
:align
=>
"left"
,
:style
=>
"padding: 20px 0 0;"
}
%h2
{
:style
=>
"color:#646464 !important; font-weight: bold; margin: 0; padding: 0; line-height: 26px; font-size: 18px; font-family: Helvetica, Arial, sans-serif; "
}
%h2
{
:style
=>
"color:#646464 !important; font-weight: bold; margin: 0; padding: 0; line-height: 26px; font-size: 18px; font-family: Helvetica, Arial, sans-serif; "
}
=
link_to
project_issue_url
(
@project
,
@issue
),
:title
=>
@issue
.
title
do
=
link_to
project_issue_url
(
@
issue
.
project
,
@issue
),
:title
=>
@issue
.
title
do
=
"Issue #
#{
@issue
.
id
.
to_s
}
"
=
"Issue #
#{
@issue
.
id
.
to_s
}
"
=
truncate
(
@issue
.
title
,
:length
=>
45
)
=
truncate
(
@issue
.
title
,
:length
=>
45
)
%br
%br
app/views/notify/new_merge_request_email.html.haml
View file @
1b85cbc6
...
@@ -5,16 +5,14 @@
...
@@ -5,16 +5,14 @@
%td
{
:align
=>
"left"
,
:style
=>
"padding: 20px 0 0;"
}
%td
{
:align
=>
"left"
,
:style
=>
"padding: 20px 0 0;"
}
%h2
{
:style
=>
"color:#646464; font-weight: bold; margin: 0; padding: 0; line-height: 26px; font-size: 18px; font-family: Helvetica, Arial, sans-serif; "
}
%h2
{
:style
=>
"color:#646464; font-weight: bold; margin: 0; padding: 0; line-height: 26px; font-size: 18px; font-family: Helvetica, Arial, sans-serif; "
}
New Merge Request
New Merge Request
=
link_to
truncate
(
@merge_request
.
title
,
:length
=>
16
),
project_merge_request_url
(
@project
,
@merge_request
)
=
link_to
truncate
(
@merge_request
.
title
,
:length
=>
16
),
project_merge_request_url
(
@
merge_request
.
project
,
@merge_request
)
%td
{
:style
=>
"font-size: 1px; line-height: 1px;"
,
:width
=>
"21"
}
%td
{
:style
=>
"font-size: 1px; line-height: 1px;"
,
:width
=>
"21"
}
%tr
%tr
%td
{
:style
=>
"font-size: 1px; line-height: 1px;"
,
:width
=>
"21"
}
%td
{
:style
=>
"font-size: 1px; line-height: 1px;"
,
:width
=>
"21"
}
%td
{
:style
=>
"padding: 15px 0 15px;"
,
:valign
=>
"top"
}
%td
{
:style
=>
"padding: 15px 0 15px;"
,
:valign
=>
"top"
}
%p
{
:style
=>
"color:#767676; font-weight: normal; margin: 0; padding: 0; line-height: 20px; font-size: 12px;font-family: Helvetica, Arial, sans-serif; "
}
%p
{
:style
=>
"color:#767676; font-weight: normal; margin: 0; padding: 0; line-height: 20px; font-size: 12px;font-family: Helvetica, Arial, sans-serif; "
}
Branches:
#{
@merge_request
.
source_branch
}
→
#{
@merge_request
.
target_branch
}
Branches:
#{
@merge_request
.
source_branch
}
→
#{
@merge_request
.
target_branch
}
%p
{
:style
=>
"color:#767676; font-weight: normal; margin: 0; padding: 0; line-height: 20px; font-size: 12px;font-family: Helvetica, Arial, sans-serif; "
}
%p
{
:style
=>
"color:#767676; font-weight: normal; margin: 0; padding: 0; line-height: 20px; font-size: 12px;font-family: Helvetica, Arial, sans-serif; "
}
Asignee:
#{
@merge_request
.
author
.
name
}
→
#{
@merge_request
.
assignee
.
name
}
Asignee:
#{
@merge_request
.
author_name
}
→
#{
@merge_request
.
assignee_name
}
%td
%td
app/views/notify/note_commit_email.html.haml
View file @
1b85cbc6
...
@@ -5,13 +5,13 @@
...
@@ -5,13 +5,13 @@
%td
{
:align
=>
"left"
,
:style
=>
"padding: 20px 0 0;"
}
%td
{
:align
=>
"left"
,
:style
=>
"padding: 20px 0 0;"
}
%h2
{
:style
=>
"color:#646464; font-weight: bold; margin: 0; padding: 0; line-height: 26px; font-size: 18px; font-family: Helvetica, Arial, sans-serif; "
}
%h2
{
:style
=>
"color:#646464; font-weight: bold; margin: 0; padding: 0; line-height: 26px; font-size: 18px; font-family: Helvetica, Arial, sans-serif; "
}
New comment for commit
New comment for commit
=
link_to
truncate
(
@commit
.
id
.
to_s
,
:length
=>
16
),
project_commit_url
(
@project
,
:id
=>
@commit
.
id
,
:anchor
=>
"note_
#{
@note
.
id
}
"
)
=
link_to
truncate
(
@commit
.
id
.
to_s
,
:length
=>
16
),
project_commit_url
(
@
commit
.
project
,
:id
=>
@commit
.
id
,
:anchor
=>
"note_
#{
@note
.
id
}
"
)
%td
{
:style
=>
"font-size: 1px; line-height: 1px;"
,
:width
=>
"21"
}
%td
{
:style
=>
"font-size: 1px; line-height: 1px;"
,
:width
=>
"21"
}
%tr
%tr
%td
{
:style
=>
"font-size: 1px; line-height: 1px;"
,
:width
=>
"21"
}
%td
{
:style
=>
"font-size: 1px; line-height: 1px;"
,
:width
=>
"21"
}
%td
{
:style
=>
"padding: 15px 0 15px;"
,
:valign
=>
"top"
}
%td
{
:style
=>
"padding: 15px 0 15px;"
,
:valign
=>
"top"
}
%p
{
:style
=>
"color:#767676; font-weight: normal; margin: 0; padding: 0; line-height: 20px; font-size: 12px;font-family: Helvetica, Arial, sans-serif; "
}
%p
{
:style
=>
"color:#767676; font-weight: normal; margin: 0; padding: 0; line-height: 20px; font-size: 12px;font-family: Helvetica, Arial, sans-serif; "
}
%a
{
:href
=>
"#"
,
:style
=>
"color: #0eb6ce; text-decoration: none;"
}
#{
@note
.
author
.
name
}
%a
{
:href
=>
"#"
,
:style
=>
"color: #0eb6ce; text-decoration: none;"
}
#{
@note
.
author
_
name
}
left next message:
left next message:
%br
%br
%table
{
:border
=>
"0"
,
:cellpadding
=>
"0"
,
:cellspacing
=>
"0"
,
:width
=>
"558"
}
%table
{
:border
=>
"0"
,
:cellpadding
=>
"0"
,
:cellspacing
=>
"0"
,
:width
=>
"558"
}
...
...
app/views/notify/note_issue_email.html.haml
View file @
1b85cbc6
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
%td
{
:align
=>
"left"
,
:style
=>
"padding: 20px 0 0;"
}
%td
{
:align
=>
"left"
,
:style
=>
"padding: 20px 0 0;"
}
%h2
{
:style
=>
"color:#646464 !important; font-weight: bold; margin: 0; padding: 0; line-height: 26px; font-size: 18px; font-family: Helvetica, Arial, sans-serif; "
}
%h2
{
:style
=>
"color:#646464 !important; font-weight: bold; margin: 0; padding: 0; line-height: 26px; font-size: 18px; font-family: Helvetica, Arial, sans-serif; "
}
New comment -
New comment -
=
link_to
project_issue_url
(
@project
,
@issue
,
:anchor
=>
"note_
#{
@note
.
id
}
"
)
do
=
link_to
project_issue_url
(
@
issue
.
project
,
@issue
,
:anchor
=>
"note_
#{
@note
.
id
}
"
)
do
=
"Issue #
#{
@issue
.
id
.
to_s
}
"
=
"Issue #
#{
@issue
.
id
.
to_s
}
"
=
truncate
(
@issue
.
title
,
:length
=>
35
)
=
truncate
(
@issue
.
title
,
:length
=>
35
)
%td
{
:style
=>
"font-size: 1px; line-height: 1px;"
,
:width
=>
"21"
}
%td
{
:style
=>
"font-size: 1px; line-height: 1px;"
,
:width
=>
"21"
}
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
%td
{
:style
=>
"font-size: 1px; line-height: 1px;"
,
:width
=>
"21"
}
%td
{
:style
=>
"font-size: 1px; line-height: 1px;"
,
:width
=>
"21"
}
%td
{
:style
=>
"padding: 15px 0 15px;"
,
:valign
=>
"top"
}
%td
{
:style
=>
"padding: 15px 0 15px;"
,
:valign
=>
"top"
}
%p
{
:style
=>
"color:#767676; font-weight: normal; margin: 0; padding: 0; line-height: 20px; font-size: 12px;font-family: Helvetica, Arial, sans-serif; "
}
%p
{
:style
=>
"color:#767676; font-weight: normal; margin: 0; padding: 0; line-height: 20px; font-size: 12px;font-family: Helvetica, Arial, sans-serif; "
}
%a
{
:href
=>
"#"
,
:style
=>
"color: #0eb6ce; text-decoration: none;"
}
#{
@note
.
author
.
name
}
%a
{
:href
=>
"#"
,
:style
=>
"color: #0eb6ce; text-decoration: none;"
}
#{
@note
.
author
_
name
}
left next message:
left next message:
%br
%br
%table
{
:border
=>
"0"
,
:cellpadding
=>
"0"
,
:cellspacing
=>
"0"
,
:width
=>
"558"
}
%table
{
:border
=>
"0"
,
:cellpadding
=>
"0"
,
:cellspacing
=>
"0"
,
:width
=>
"558"
}
...
...
app/views/notify/note_merge_request_email.html.haml
View file @
1b85cbc6
...
@@ -5,13 +5,13 @@
...
@@ -5,13 +5,13 @@
%td
{
:align
=>
"left"
,
:style
=>
"padding: 20px 0 0;"
}
%td
{
:align
=>
"left"
,
:style
=>
"padding: 20px 0 0;"
}
%h2
{
:style
=>
"color:#646464; font-weight: bold; margin: 0; padding: 0; line-height: 26px; font-size: 18px; font-family: Helvetica, Arial, sans-serif; "
}
%h2
{
:style
=>
"color:#646464; font-weight: bold; margin: 0; padding: 0; line-height: 26px; font-size: 18px; font-family: Helvetica, Arial, sans-serif; "
}
New comment for Merge Request
New comment for Merge Request
=
link_to
truncate
(
@merge_request
.
title
,
:length
=>
16
),
project_merge_request_url
(
@project
,
@merge_request
,
:anchor
=>
"note_
#{
@note
.
id
}
"
)
=
link_to
truncate
(
@merge_request
.
title
,
:length
=>
16
),
project_merge_request_url
(
@
merge_request
.
project
,
@merge_request
,
:anchor
=>
"note_
#{
@note
.
id
}
"
)
%td
{
:style
=>
"font-size: 1px; line-height: 1px;"
,
:width
=>
"21"
}
%td
{
:style
=>
"font-size: 1px; line-height: 1px;"
,
:width
=>
"21"
}
%tr
%tr
%td
{
:style
=>
"font-size: 1px; line-height: 1px;"
,
:width
=>
"21"
}
%td
{
:style
=>
"font-size: 1px; line-height: 1px;"
,
:width
=>
"21"
}
%td
{
:style
=>
"padding: 15px 0 15px;"
,
:valign
=>
"top"
}
%td
{
:style
=>
"padding: 15px 0 15px;"
,
:valign
=>
"top"
}
%p
{
:style
=>
"color:#767676; font-weight: normal; margin: 0; padding: 0; line-height: 20px; font-size: 12px;font-family: Helvetica, Arial, sans-serif; "
}
%p
{
:style
=>
"color:#767676; font-weight: normal; margin: 0; padding: 0; line-height: 20px; font-size: 12px;font-family: Helvetica, Arial, sans-serif; "
}
%a
{
:href
=>
"#"
,
:style
=>
"color: #0eb6ce; text-decoration: none;"
}
#{
@note
.
author
.
name
}
%a
{
:href
=>
"#"
,
:style
=>
"color: #0eb6ce; text-decoration: none;"
}
#{
@note
.
author
_
name
}
left next message:
left next message:
%br
%br
%table
{
:border
=>
"0"
,
:cellpadding
=>
"0"
,
:cellspacing
=>
"0"
,
:width
=>
"558"
}
%table
{
:border
=>
"0"
,
:cellpadding
=>
"0"
,
:cellspacing
=>
"0"
,
:width
=>
"558"
}
...
...
app/views/notify/note_wall_email.html.haml
View file @
1b85cbc6
...
@@ -5,13 +5,13 @@
...
@@ -5,13 +5,13 @@
%td
{
:align
=>
"left"
,
:style
=>
"padding: 20px 0 0;"
}
%td
{
:align
=>
"left"
,
:style
=>
"padding: 20px 0 0;"
}
%h2
{
:style
=>
"color:#646464; font-weight: bold; margin: 0; padding: 0; line-height: 26px; font-size: 18px; font-family: Helvetica, Arial, sans-serif; "
}
%h2
{
:style
=>
"color:#646464; font-weight: bold; margin: 0; padding: 0; line-height: 26px; font-size: 18px; font-family: Helvetica, Arial, sans-serif; "
}
New message on
New message on
=
link_to
"Project Wall"
,
wall_project_url
(
@project
,
:anchor
=>
"note_
#{
@note
.
id
}
"
)
=
link_to
"Project Wall"
,
wall_project_url
(
@
note
.
project
,
:anchor
=>
"note_
#{
@note
.
id
}
"
)
%td
{
:style
=>
"font-size: 1px; line-height: 1px;"
,
:width
=>
"21"
}
%td
{
:style
=>
"font-size: 1px; line-height: 1px;"
,
:width
=>
"21"
}
%tr
%tr
%td
{
:style
=>
"font-size: 1px; line-height: 1px;"
,
:width
=>
"21"
}
%td
{
:style
=>
"font-size: 1px; line-height: 1px;"
,
:width
=>
"21"
}
%td
{
:style
=>
"padding: 15px 0 15px;"
,
:valign
=>
"top"
}
%td
{
:style
=>
"padding: 15px 0 15px;"
,
:valign
=>
"top"
}
%p
{
:style
=>
"color:#767676; font-weight: normal; margin: 0; padding: 0; line-height: 20px; font-size: 12px;font-family: Helvetica, Arial, sans-serif; "
}
%p
{
:style
=>
"color:#767676; font-weight: normal; margin: 0; padding: 0; line-height: 20px; font-size: 12px;font-family: Helvetica, Arial, sans-serif; "
}
%a
{
:href
=>
"#"
,
:style
=>
"color: #0eb6ce; text-decoration: none;"
}
#{
@note
.
author
.
name
}
%a
{
:href
=>
"#"
,
:style
=>
"color: #0eb6ce; text-decoration: none;"
}
#{
@note
.
author
_
name
}
left next message:
left next message:
%br
%br
%table
{
:border
=>
"0"
,
:cellpadding
=>
"0"
,
:cellspacing
=>
"0"
,
:width
=>
"558"
}
%table
{
:border
=>
"0"
,
:cellpadding
=>
"0"
,
:cellspacing
=>
"0"
,
:width
=>
"558"
}
...
...
app/views/notify/
chang
ed_issue_email.html.haml
→
app/views/notify/
reassign
ed_issue_email.html.haml
View file @
1b85cbc6
...
@@ -5,12 +5,12 @@
...
@@ -5,12 +5,12 @@
%td
{
:align
=>
"left"
,
:style
=>
"padding: 20px 0 0;"
}
%td
{
:align
=>
"left"
,
:style
=>
"padding: 20px 0 0;"
}
%h2
{
:style
=>
"color:#646464; font-weight: bold; margin: 0; padding: 0; line-height: 26px; font-size: 18px; font-family: Helvetica, Arial, sans-serif; "
}
%h2
{
:style
=>
"color:#646464; font-weight: bold; margin: 0; padding: 0; line-height: 26px; font-size: 18px; font-family: Helvetica, Arial, sans-serif; "
}
Reassigned Issue
Reassigned Issue
=
link_to
truncate
(
@issue
.
title
,
:length
=>
16
),
project_issue_url
(
@project
,
@issue
)
=
link_to
truncate
(
@issue
.
title
,
:length
=>
16
),
project_issue_url
(
@
issue
.
project
,
@issue
)
%td
{
:style
=>
"font-size: 1px; line-height: 1px;"
,
:width
=>
"21"
}
%td
{
:style
=>
"font-size: 1px; line-height: 1px;"
,
:width
=>
"21"
}
%tr
%tr
%td
{
:style
=>
"font-size: 1px; line-height: 1px;"
,
:width
=>
"21"
}
%td
{
:style
=>
"font-size: 1px; line-height: 1px;"
,
:width
=>
"21"
}
%td
{
:style
=>
"padding: 15px 0 15px;"
,
:valign
=>
"top"
}
%td
{
:style
=>
"padding: 15px 0 15px;"
,
:valign
=>
"top"
}
%p
{
:style
=>
"color:#767676; font-weight: normal; margin: 0; padding: 0; line-height: 20px; font-size: 12px;font-family: Helvetica, Arial, sans-serif; "
}
%p
{
:style
=>
"color:#767676; font-weight: normal; margin: 0; padding: 0; line-height: 20px; font-size: 12px;font-family: Helvetica, Arial, sans-serif; "
}
Assignee changed from
#{
@
assignee_was
.
name
}
to
#{
@issue
.
assignee
.
name
}
Assignee changed from
#{
@
previous_assignee
.
name
}
to
#{
@issue
.
assignee_
name
}
%td
%td
app/views/notify/
chang
ed_merge_request_email.html.haml
→
app/views/notify/
reassign
ed_merge_request_email.html.haml
View file @
1b85cbc6
...
@@ -5,12 +5,12 @@
...
@@ -5,12 +5,12 @@
%td
{
:align
=>
"left"
,
:style
=>
"padding: 20px 0 0;"
}
%td
{
:align
=>
"left"
,
:style
=>
"padding: 20px 0 0;"
}
%h2
{
:style
=>
"color:#646464; font-weight: bold; margin: 0; padding: 0; line-height: 26px; font-size: 18px; font-family: Helvetica, Arial, sans-serif; "
}
%h2
{
:style
=>
"color:#646464; font-weight: bold; margin: 0; padding: 0; line-height: 26px; font-size: 18px; font-family: Helvetica, Arial, sans-serif; "
}
Reassigned Merge Request
Reassigned Merge Request
=
link_to
truncate
(
@merge_request
.
title
,
:length
=>
16
),
project_merge_request_url
(
@project
,
@merge_request
)
=
link_to
truncate
(
@merge_request
.
title
,
:length
=>
16
),
project_merge_request_url
(
@
merge_request
.
project
,
@merge_request
)
%td
{
:style
=>
"font-size: 1px; line-height: 1px;"
,
:width
=>
"21"
}
%td
{
:style
=>
"font-size: 1px; line-height: 1px;"
,
:width
=>
"21"
}
%tr
%tr
%td
{
:style
=>
"font-size: 1px; line-height: 1px;"
,
:width
=>
"21"
}
%td
{
:style
=>
"font-size: 1px; line-height: 1px;"
,
:width
=>
"21"
}
%td
{
:style
=>
"padding: 15px 0 15px;"
,
:valign
=>
"top"
}
%td
{
:style
=>
"padding: 15px 0 15px;"
,
:valign
=>
"top"
}
%p
{
:style
=>
"color:#767676; font-weight: normal; margin: 0; padding: 0; line-height: 20px; font-size: 12px;font-family: Helvetica, Arial, sans-serif; "
}
%p
{
:style
=>
"color:#767676; font-weight: normal; margin: 0; padding: 0; line-height: 20px; font-size: 12px;font-family: Helvetica, Arial, sans-serif; "
}
Assignee changed from
#{
@
assignee_was
.
name
}
to
#{
@merge_request
.
assignee
.
name
}
Assignee changed from
#{
@
previous_assignee
.
name
}
to
#{
@merge_request
.
assignee_
name
}
%td
%td
spec/mailers/notify_spec.rb
0 → 100644
View file @
1b85cbc6
require
'spec_helper'
describe
Notify
do
include
EmailSpec
::
Helpers
include
EmailSpec
::
Matchers
before
:all
do
default_url_options
[
:host
]
=
'example.com'
end
let
(
:recipient
)
{
Factory
.
create
(
:user
,
:email
=>
'recipient@example.com'
)
}
let
(
:project
)
{
Factory
.
create
(
:project
)
}
shared_examples
'a multiple recipients email'
do
it
'is sent to the given recipient'
do
should
deliver_to
recipient
.
email
end
end
describe
'for new users, the email'
do
let
(
:example_site_url
)
{
root_url
}
let
(
:new_user
)
{
Factory
.
create
(
:user
,
:email
=>
'newguy@example.com'
)
}
subject
{
Notify
.
new_user_email
(
new_user
.
id
,
new_user
.
password
)
}
it
'is sent to the new user'
do
should
deliver_to
new_user
.
email
end
it
'has the correct subject'
do
should
have_subject
/Account was created for you/
end
it
'contains the new user\'s login name'
do
should
have_body_text
/
#{
new_user
.
email
}
/
end
it
'contains the new user\'s password'
do
should
have_body_text
/
#{
new_user
.
password
}
/
end
it
'includes a link to the site'
do
should
have_body_text
/
#{
example_site_url
}
/
end
end
context
'for a project'
do
describe
'items that are assignable, the email'
do
let
(
:assignee
)
{
Factory
.
create
(
:user
,
:email
=>
'assignee@example.com'
)
}
let
(
:previous_assignee
)
{
Factory
.
create
(
:user
,
:name
=>
'Previous Assignee'
)
}
shared_examples
'an assignee email'
do
it
'is sent to the assignee'
do
should
deliver_to
assignee
.
email
end
end
context
'for issues'
do
let
(
:issue
)
{
Factory
.
create
(
:issue
,
:assignee
=>
assignee
,
:project
=>
project
)
}
describe
'that are new'
do
subject
{
Notify
.
new_issue_email
(
issue
.
id
)
}
it_behaves_like
'an assignee email'
it
'has the correct subject'
do
should
have_subject
/New Issue was created/
end
it
'contains a link to the new issue'
do
should
have_body_text
/
#{
project_issue_url
project
,
issue
}
/
end
end
describe
'that have been reassigned'
do
before
(
:each
)
{
issue
.
stub
(
:assignee_id_was
).
and_return
(
previous_assignee
.
id
)
}
subject
{
Notify
.
reassigned_issue_email
(
recipient
.
id
,
issue
.
id
,
previous_assignee
.
id
)
}
it_behaves_like
'a multiple recipients email'
it
'has the correct subject'
do
should
have_subject
/changed issue/
end
it
'contains the name of the previous assignee'
do
should
have_body_text
/
#{
previous_assignee
.
name
}
/
end
it
'contains the name of the new assignee'
do
should
have_body_text
/
#{
assignee
.
name
}
/
end
it
'contains a link to the issue'
do
should
have_body_text
/
#{
project_issue_url
project
,
issue
}
/
end
end
end
context
'for merge requests'
do
let
(
:merge_request
)
{
Factory
.
create
(
:merge_request
,
:assignee
=>
assignee
,
:project
=>
project
)
}
describe
'that are new'
do
subject
{
Notify
.
new_merge_request_email
(
merge_request
.
id
)
}
it_behaves_like
'an assignee email'
it
'has the correct subject'
do
should
have_subject
/new merge request/
end
it
'contains a link to the new merge request'
do
should
have_body_text
/
#{
project_merge_request_url
(
project
,
merge_request
)
}
/
end
it
'contains the source branch for the merge request'
do
should
have_body_text
/
#{
merge_request
.
source_branch
}
/
end
it
'contains the target branch for the merge request'
do
should
have_body_text
/
#{
merge_request
.
target_branch
}
/
end
end
describe
'that are reassigned'
do
before
(
:each
)
{
merge_request
.
stub
(
:assignee_id_was
).
and_return
(
previous_assignee
.
id
)
}
subject
{
Notify
.
reassigned_merge_request_email
(
recipient
.
id
,
merge_request
.
id
,
previous_assignee
.
id
)
}
it_behaves_like
'a multiple recipients email'
it
'has the correct subject'
do
should
have_subject
/merge request changed/
end
it
'contains the name of the previous assignee'
do
should
have_body_text
/
#{
previous_assignee
.
name
}
/
end
it
'contains the name of the new assignee'
do
should
have_body_text
/
#{
assignee
.
name
}
/
end
it
'contains a link to the merge request'
do
should
have_body_text
/
#{
project_merge_request_url
project
,
merge_request
}
/
end
end
end
end
context
'items that are noteable, the email for a note'
do
let
(
:note_author
)
{
Factory
.
create
(
:user
,
:name
=>
'author_name'
)
}
let
(
:note
)
{
Factory
.
create
(
:note
,
:project
=>
project
,
:author
=>
note_author
)
}
before
:each
do
Note
.
stub
(
:find
).
with
(
note
.
id
).
and_return
(
note
)
end
shared_examples
'a note email'
do
it
'is sent to the given recipient'
do
should
deliver_to
recipient
.
email
end
it
'contains the name of the note\'s author'
do
should
have_body_text
/
#{
note_author
.
name
}
/
end
it
'contains the message from the note'
do
should
have_body_text
/
#{
note
.
note
}
/
end
end
describe
'on a project wall'
do
let
(
:note_on_the_wall_url
)
{
wall_project_url
(
project
,
:anchor
=>
"note_
#{
note
.
id
}
"
)
}
subject
{
Notify
.
note_wall_email
(
recipient
.
id
,
note
.
id
)
}
it_behaves_like
'a note email'
it
'has the correct subject'
do
should
have_subject
/
#{
project
.
name
}
/
end
it
'contains a link to the wall note'
do
should
have_body_text
/
#{
note_on_the_wall_url
}
/
end
end
describe
'on a commit'
do
let
(
:commit
)
do
mock
(
:commit
).
tap
do
|
commit
|
commit
.
stub
(
:id
).
and_return
(
'fauxsha1'
)
commit
.
stub
(
:project
).
and_return
(
project
)
end
end
before
(
:each
)
{
note
.
stub
(
:target
).
and_return
(
commit
)
}
subject
{
Notify
.
note_commit_email
(
recipient
.
id
,
note
.
id
)
}
it_behaves_like
'a note email'
it
'has the correct subject'
do
should
have_subject
/note for commit/
end
it
'contains a link to the commit'
do
should
have_body_text
/fauxsha1/
end
end
describe
'on a merge request'
do
let
(
:merge_request
)
{
Factory
.
create
(
:merge_request
,
:project
=>
project
)
}
let
(
:note_on_merge_request_url
)
{
project_merge_request_url
(
project
,
merge_request
,
:anchor
=>
"note_
#{
note
.
id
}
"
)
}
before
(
:each
)
{
note
.
stub
(
:noteable
).
and_return
(
merge_request
)
}
subject
{
Notify
.
note_merge_request_email
(
recipient
.
id
,
note
.
id
)
}
it_behaves_like
'a note email'
it
'has the correct subject'
do
should
have_subject
/note for merge request/
end
it
'contains a link to the merge request note'
do
should
have_body_text
/
#{
note_on_merge_request_url
}
/
end
end
describe
'on an issue'
do
let
(
:issue
)
{
Factory
.
create
(
:issue
,
:project
=>
project
)
}
let
(
:note_on_issue_url
)
{
project_issue_url
(
project
,
issue
,
:anchor
=>
"note_
#{
note
.
id
}
"
)
}
before
(
:each
)
{
note
.
stub
(
:noteable
).
and_return
(
issue
)
}
subject
{
Notify
.
note_issue_email
(
recipient
.
id
,
note
.
id
)
}
it_behaves_like
'a note email'
it
'has the correct subject'
do
should
have_subject
/note for issue
#{
issue
.
id
}
/
end
it
'contains a link to the issue note'
do
should
have_body_text
/
#{
note_on_issue_url
}
/
end
end
end
end
end
spec/spec_helper.rb
View file @
1b85cbc6
...
@@ -11,6 +11,7 @@ require 'capybara/dsl'
...
@@ -11,6 +11,7 @@ require 'capybara/dsl'
require
'webmock/rspec'
require
'webmock/rspec'
require
'factories'
require
'factories'
require
'monkeypatch'
require
'monkeypatch'
require
'email_spec'
# Requires supporting ruby files with custom matchers and macros, etc,
# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
# in spec/support/ and its subdirectories.
...
...
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