Commit 435fd8f0874450f2da480fa72b0f014d3f1fe271

Authored by Robb Kidd
1 parent bb22360d

Make Notify#note_issue_email resque friendly

Update method to take ids and then perform #finds itself during mailer
queue worker kick-off.
app/mailers/notify.rb
... ... @@ -43,14 +43,13 @@ class Notify < ActionMailer::Base
43 43 mail(:to => recipient.email, :subject => "gitlab | note for merge request | #{@note.project.name} ")
44 44 end
45 45  
46   - def note_issue_email(user, note)
47   - @user = user
48   - @note = Note.find(note['id'])
49   - @project = @note.project
  46 + def note_issue_email(recipient_id, note_id)
  47 + recipient = User.find(recipient_id)
  48 + @note = Note.find(note_id)
50 49 @issue = @note.noteable
51   - mail(:to => @user['email'], :subject => "gitlab | note for issue #{@issue.id} | #{@note.project.name} ")
  50 + mail(:to => recipient.email, :subject => "gitlab | note for issue #{@issue.id} | #{@note.project.name} ")
52 51 end
53   -
  52 +
54 53 def new_merge_request_email(merge_request)
55 54 @merge_request = MergeRequest.find(merge_request['id'])
56 55 @user = @merge_request.assignee
... ...
app/views/notify/note_issue_email.html.haml
... ... @@ -5,7 +5,7 @@
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 7 New comment -
8   - = link_to project_issue_url(@project, @issue, :anchor => "note_#{@note.id}") do
  8 + = link_to project_issue_url(@issue.project, @issue, :anchor => "note_#{@note.id}") do
9 9 = "Issue ##{@issue.id.to_s}"
10 10 = truncate(@issue.title, :length => 35)
11 11 %td{:style => "font-size: 1px; line-height: 1px;", :width => "21"}
... ... @@ -13,7 +13,7 @@
13 13 %td{:style => "font-size: 1px; line-height: 1px;", :width => "21"}
14 14 %td{:style => "padding: 15px 0 15px;", :valign => "top"}
15 15 %p{:style => "color:#767676; font-weight: normal; margin: 0; padding: 0; line-height: 20px; font-size: 12px;font-family: Helvetica, Arial, sans-serif; "}
16   - %a{:href => "#", :style => "color: #0eb6ce; text-decoration: none;"} #{@note.author.name}
  16 + %a{:href => "#", :style => "color: #0eb6ce; text-decoration: none;"} #{@note.author_name}
17 17 left next message:
18 18 %br
19 19 %table{:border => "0", :cellpadding => "0", :cellspacing => "0", :width => "558"}
... ...
spec/mailers/notify_spec.rb
... ... @@ -230,7 +230,8 @@ describe Notify do
230 230 let(:issue) { Factory.create(:issue, :project => project) }
231 231 let(:note_on_issue_url) { project_issue_url(project, issue, :anchor => "note_#{note.id}") }
232 232 before(:each) { note.stub(:noteable).and_return(issue) }
233   - subject { Notify.note_issue_email(recipient, note) }
  233 +
  234 + subject { Notify.note_issue_email(recipient.id, note.id) }
234 235  
235 236 it_behaves_like 'a note email'
236 237  
... ...