Commit 5443021a0e16887d14189f4203aea7f9282a1853

Authored by Riyad Preukschas
1 parent 9a0b763e

Update notifications mails and notify specs for GFM

app/mailers/notify.rb
... ... @@ -17,22 +17,23 @@ class Notify < ActionMailer::Base
17 17 def new_issue_email(issue_id)
18 18 @issue = Issue.find(issue_id)
19 19 @project = @issue.project
20   - mail(:to => @issue.assignee_email, :subject => "gitlab | New Issue was created")
  20 + mail(:to => @issue.assignee_email, :subject => "gitlab | new issue ##{@issue.id} | #{@issue.title} | #{@project.name}")
21 21 end
22 22  
23 23 def note_wall_email(recipient_id, note_id)
24 24 recipient = User.find(recipient_id)
25 25 @note = Note.find(note_id)
26 26 @project = @note.project
27   - mail(:to => recipient.email, :subject => "gitlab | #{@note.project_name} ")
  27 + mail(:to => recipient.email, :subject => "gitlab | #{@project.name}")
28 28 end
29 29  
30 30 def note_commit_email(recipient_id, note_id)
31 31 recipient = User.find(recipient_id)
32 32 @note = Note.find(note_id)
33 33 @commit = @note.target
  34 + @commit = CommitDecorator.decorate(@commit)
34 35 @project = @note.project
35   - mail(:to => recipient.email, :subject => "gitlab | note for commit | #{@note.project_name} ")
  36 + mail(:to => recipient.email, :subject => "gitlab | note for commit #{@commit.short_id} | #{@commit.title} | #{@project.name}")
36 37 end
37 38  
38 39 def note_merge_request_email(recipient_id, note_id)
... ... @@ -40,7 +41,7 @@ class Notify < ActionMailer::Base
40 41 @note = Note.find(note_id)
41 42 @merge_request = @note.noteable
42 43 @project = @note.project
43   - mail(:to => recipient.email, :subject => "gitlab | note for merge request | #{@note.project_name} ")
  44 + mail(:to => recipient.email, :subject => "gitlab | note for merge request !#{@merge_request.id} | #{@project.name}")
44 45 end
45 46  
46 47 def note_issue_email(recipient_id, note_id)
... ... @@ -48,7 +49,7 @@ class Notify < ActionMailer::Base
48 49 @note = Note.find(note_id)
49 50 @issue = @note.noteable
50 51 @project = @note.project
51   - mail(:to => recipient.email, :subject => "gitlab | note for issue #{@issue.id} | #{@note.project_name} ")
  52 + mail(:to => recipient.email, :subject => "gitlab | note for issue ##{@issue.id} | #{@project.name}")
52 53 end
53 54  
54 55 def note_wiki_email(recipient_id, note_id)
... ... @@ -56,13 +57,13 @@ class Notify < ActionMailer::Base
56 57 @note = Note.find(note_id)
57 58 @wiki = @note.noteable
58 59 @project = @note.project
59   - mail(:to => recipient.email, :subject => "gitlab | note for wiki | #{@note.project_name}")
  60 + mail(:to => recipient.email, :subject => "gitlab | note for wiki | #{@project.name}")
60 61 end
61 62  
62 63 def new_merge_request_email(merge_request_id)
63 64 @merge_request = MergeRequest.find(merge_request_id)
64 65 @project = @merge_request.project
65   - mail(:to => @merge_request.assignee_email, :subject => "gitlab | new merge request | #{@merge_request.title} ")
  66 + mail(:to => @merge_request.assignee_email, :subject => "gitlab | new merge request !#{@merge_request.id} | #{@merge_request.title} | #{@project.name}")
66 67 end
67 68  
68 69 def reassigned_merge_request_email(recipient_id, merge_request_id, previous_assignee_id)
... ... @@ -70,7 +71,7 @@ class Notify < ActionMailer::Base
70 71 @merge_request = MergeRequest.find(merge_request_id)
71 72 @previous_assignee ||= User.find(previous_assignee_id)
72 73 @project = @merge_request.project
73   - mail(:to => recipient.email, :subject => "gitlab | merge request changed | #{@merge_request.title} ")
  74 + mail(:to => recipient.email, :subject => "gitlab | changed merge request !#{@merge_request.id} | #{@merge_request.title} | #{@project.name}")
74 75 end
75 76  
76 77 def reassigned_issue_email(recipient_id, issue_id, previous_assignee_id)
... ... @@ -78,6 +79,6 @@ class Notify < ActionMailer::Base
78 79 @issue = Issue.find(issue_id)
79 80 @previous_assignee ||= User.find(previous_assignee_id)
80 81 @project = @issue.project
81   - mail(:to => recipient.email, :subject => "gitlab | changed issue | #{@issue.title} ")
  82 + mail(:to => recipient.email, :subject => "gitlab | changed issue ##{@issue.id} | #{@issue.title} | #{@project.name}")
82 83 end
83 84 end
... ...
app/views/notify/new_issue_email.html.haml
... ... @@ -10,7 +10,6 @@
10 10 %td{:style => "font-size: 1px; line-height: 1px;", :width => "21"}
11 11 %td{:align => "left", :style => "padding: 20px 0 0;"}
12 12 %h2{:style => "color:#646464 !important; font-weight: bold; margin: 0; padding: 0; line-height: 26px; font-size: 18px; font-family: Helvetica, Arial, sans-serif; "}
13   - = link_to project_issue_url(@issue.project, @issue), :title => @issue.title do
14   - = "Issue ##{@issue.id.to_s}"
15   - = truncate(@issue.title, :length => 45)
  13 + = "Issue ##{@issue.id}"
  14 + = link_to_gfm truncate(@issue.title, :length => 45), project_issue_url(@issue.project, @issue), :title => @issue.title
16 15 %br
... ...
app/views/notify/new_merge_request_email.html.haml
... ... @@ -4,8 +4,8 @@
4 4 %td{:style => "font-size: 1px; line-height: 1px;", :width => "21"}
5 5 %td{:align => "left", :style => "padding: 20px 0 0;"}
6 6 %h2{:style => "color:#646464; font-weight: bold; margin: 0; padding: 0; line-height: 26px; font-size: 18px; font-family: Helvetica, Arial, sans-serif; "}
7   - New Merge Request
8   - = link_to truncate(@merge_request.title, :length => 16), project_merge_request_url(@merge_request.project, @merge_request)
  7 + = "New Merge Request !#{@merge_request.id}"
  8 + = link_to_gfm truncate(@merge_request.title, :length => 16), project_merge_request_url(@merge_request.project, @merge_request)
9 9 %td{:style => "font-size: 1px; line-height: 1px;", :width => "21"}
10 10 %tr
11 11 %td{:style => "font-size: 1px; line-height: 1px;", :width => "21"}
... ...
app/views/notify/note_commit_email.html.haml
... ... @@ -4,8 +4,8 @@
4 4 %td{:style => "font-size: 1px; line-height: 1px;", :width => "21"}
5 5 %td{:align => "left", :style => "padding: 20px 0 0;"}
6 6 %h2{:style => "color:#646464; font-weight: bold; margin: 0; padding: 0; line-height: 26px; font-size: 18px; font-family: Helvetica, Arial, sans-serif; "}
7   - New comment for commit
8   - = link_to truncate(@commit.id.to_s, :length => 16), project_commit_url(@note.project, :id => @commit.id, :anchor => "note_#{@note.id}")
  7 + = "New comment for Commit #{@commit.short_id}"
  8 + = link_to_gfm truncate(@commit.title, :length => 16), project_commit_url(@note.project, :id => @commit.id, :anchor => "note_#{@note.id}")
9 9 %td{:style => "font-size: 1px; line-height: 1px;", :width => "21"}
10 10 %tr
11 11 %td{:style => "font-size: 1px; line-height: 1px;", :width => "21"}
... ...
app/views/notify/note_issue_email.html.haml
... ... @@ -4,10 +4,8 @@
4 4 %td{:style => "font-size: 1px; line-height: 1px;", :width => "21"}
5 5 %td{:align => "left", :style => "padding: 20px 0 0;"}
6 6 %h2{:style => "color:#646464 !important; font-weight: bold; margin: 0; padding: 0; line-height: 26px; font-size: 18px; font-family: Helvetica, Arial, sans-serif; "}
7   - New comment -
8   - = link_to project_issue_url(@issue.project, @issue, :anchor => "note_#{@note.id}") do
9   - = "Issue ##{@issue.id.to_s}"
10   - = truncate(@issue.title, :length => 35)
  7 + = "New comment for Issue ##{@issue.id}"
  8 + = link_to_gfm truncate(@issue.title, :length => 35), project_issue_url(@issue.project, @issue, :anchor => "note_#{@note.id}")
11 9 %td{:style => "font-size: 1px; line-height: 1px;", :width => "21"}
12 10 %tr
13 11 %td{:style => "font-size: 1px; line-height: 1px;", :width => "21"}
... ...
app/views/notify/note_merge_request_email.html.haml
... ... @@ -4,8 +4,8 @@
4 4 %td{:style => "font-size: 1px; line-height: 1px;", :width => "21"}
5 5 %td{:align => "left", :style => "padding: 20px 0 0;"}
6 6 %h2{:style => "color:#646464; font-weight: bold; margin: 0; padding: 0; line-height: 26px; font-size: 18px; font-family: Helvetica, Arial, sans-serif; "}
7   - New comment for Merge Request
8   - = link_to truncate(@merge_request.title, :length => 16), project_merge_request_url(@merge_request.project, @merge_request, :anchor => "note_#{@note.id}")
  7 + = "New comment for Merge Request !#{@merge_request.id}"
  8 + = link_to_gfm truncate(@merge_request.title, :length => 16), project_merge_request_url(@merge_request.project, @merge_request, :anchor => "note_#{@note.id}")
9 9 %td{:style => "font-size: 1px; line-height: 1px;", :width => "21"}
10 10 %tr
11 11 %td{:style => "font-size: 1px; line-height: 1px;", :width => "21"}
... ...
app/views/notify/note_wiki_email.html.haml
... ... @@ -4,9 +4,8 @@
4 4 %td{:style => "font-size: 1px; line-height: 1px;", :width => "21"}
5 5 %td{:align => "left", :style => "padding: 20px 0 0;"}
6 6 %h2{:style => "color:#646464 !important; font-weight: bold; margin: 0; padding: 0; line-height: 26px; font-size: 18px; font-family: Helvetica, Arial, sans-serif; "}
7   - New comment -
8   - = link_to project_issue_url(@wiki.project, @wiki, :anchor => "note_#{@note.id}") do
9   - = "Wiki ##{@wiki.title.to_s}"
  7 + New comment for Wiki page
  8 + = link_to_gfm @wiki.title, project_issue_url(@wiki.project, @wiki, :anchor => "note_#{@note.id}")
10 9 %td{:style => "font-size: 1px; line-height: 1px;", :width => "21"}
11 10 %tr
12 11 %td{:style => "font-size: 1px; line-height: 1px;", :width => "21"}
... ...
app/views/notify/reassigned_issue_email.html.haml
... ... @@ -4,8 +4,8 @@
4 4 %td{:style => "font-size: 1px; line-height: 1px;", :width => "21"}
5 5 %td{:align => "left", :style => "padding: 20px 0 0;"}
6 6 %h2{:style => "color:#646464; font-weight: bold; margin: 0; padding: 0; line-height: 26px; font-size: 18px; font-family: Helvetica, Arial, sans-serif; "}
7   - Reassigned Issue
8   - = link_to truncate(@issue.title, :length => 16), project_issue_url(@issue.project, @issue)
  7 + = "Reassigned Issue ##{@issue.id}"
  8 + = link_to_gfm truncate(@issue.title, :length => 16), project_issue_url(@issue.project, @issue)
9 9 %td{:style => "font-size: 1px; line-height: 1px;", :width => "21"}
10 10 %tr
11 11 %td{:style => "font-size: 1px; line-height: 1px;", :width => "21"}
... ...
app/views/notify/reassigned_merge_request_email.html.haml
... ... @@ -4,8 +4,8 @@
4 4 %td{:style => "font-size: 1px; line-height: 1px;", :width => "21"}
5 5 %td{:align => "left", :style => "padding: 20px 0 0;"}
6 6 %h2{:style => "color:#646464; font-weight: bold; margin: 0; padding: 0; line-height: 26px; font-size: 18px; font-family: Helvetica, Arial, sans-serif; "}
7   - Reassigned Merge Request
8   - = link_to truncate(@merge_request.title, :length => 16), project_merge_request_url(@merge_request.project, @merge_request)
  7 + = "Reassigned Merge Request !#{@merge_request.id}"
  8 + = link_to_gfm truncate(@merge_request.title, :length => 16), project_merge_request_url(@merge_request.project, @merge_request)
9 9 %td{:style => "font-size: 1px; line-height: 1px;", :width => "21"}
10 10 %tr
11 11 %td{:style => "font-size: 1px; line-height: 1px;", :width => "21"}
... ...
spec/mailers/notify_spec.rb
... ... @@ -60,7 +60,7 @@ describe Notify do
60 60 it_behaves_like 'an assignee email'
61 61  
62 62 it 'has the correct subject' do
63   - should have_subject /New Issue was created/
  63 + should have_subject /new issue ##{issue.id}/
64 64 end
65 65  
66 66 it 'contains a link to the new issue' do
... ... @@ -102,7 +102,7 @@ describe Notify do
102 102 it_behaves_like 'an assignee email'
103 103  
104 104 it 'has the correct subject' do
105   - should have_subject /new merge request/
  105 + should have_subject /new merge request !#{merge_request.id}/
106 106 end
107 107  
108 108 it 'contains a link to the new merge request' do
... ... @@ -126,7 +126,7 @@ describe Notify do
126 126 it_behaves_like 'a multiple recipients email'
127 127  
128 128 it 'has the correct subject' do
129   - should have_subject /merge request changed/
  129 + should have_subject /changed merge request !#{merge_request.id}/
130 130 end
131 131  
132 132 it 'contains the name of the previous assignee' do
... ... @@ -188,6 +188,8 @@ describe Notify do
188 188 mock(:commit).tap do |commit|
189 189 commit.stub(:id).and_return('fauxsha1')
190 190 commit.stub(:project).and_return(project)
  191 + commit.stub(:short_id).and_return('fauxsha1')
  192 + commit.stub(:safe_message).and_return('some message')
191 193 end
192 194 end
193 195 before(:each) { note.stub(:target).and_return(commit) }
... ... @@ -197,7 +199,7 @@ describe Notify do
197 199 it_behaves_like 'a note email'
198 200  
199 201 it 'has the correct subject' do
200   - should have_subject /note for commit/
  202 + should have_subject /note for commit #{commit.short_id}/
201 203 end
202 204  
203 205 it 'contains a link to the commit' do
... ... @@ -215,7 +217,7 @@ describe Notify do
215 217 it_behaves_like 'a note email'
216 218  
217 219 it 'has the correct subject' do
218   - should have_subject /note for merge request/
  220 + should have_subject /note for merge request !#{merge_request.id}/
219 221 end
220 222  
221 223 it 'contains a link to the merge request note' do
... ... @@ -233,7 +235,7 @@ describe Notify do
233 235 it_behaves_like 'a note email'
234 236  
235 237 it 'has the correct subject' do
236   - should have_subject /note for issue #{issue.id}/
  238 + should have_subject /note for issue ##{issue.id}/
237 239 end
238 240  
239 241 it 'contains a link to the issue note' do
... ...