OSDN Git Service

Make Notify#note_issue_email resque friendly
authorRobb Kidd <robb@thekidds.org>
Tue, 15 May 2012 22:50:36 +0000 (18:50 -0400)
committerRobb Kidd <robb@thekidds.org>
Wed, 16 May 2012 02:37:34 +0000 (22:37 -0400)
Update method to take ids and then perform #finds itself during mailer
queue worker kick-off.

app/mailers/notify.rb
app/views/notify/note_issue_email.html.haml
spec/mailers/notify_spec.rb

index dc6ef15..328825d 100644 (file)
@@ -43,14 +43,13 @@ class Notify < ActionMailer::Base
     mail(:to => recipient.email, :subject => "gitlab | note for merge request | #{@note.project.name} ")
   end
 
-  def note_issue_email(user, note)
-    @user = user
-    @note = Note.find(note['id'])
-    @project = @note.project
+  def note_issue_email(recipient_id, note_id)
+    recipient = User.find(recipient_id)
+    @note = Note.find(note_id)
     @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
-  
+
   def new_merge_request_email(merge_request)
     @merge_request = MergeRequest.find(merge_request['id'])
     @user = @merge_request.assignee
index eb2cbc0..17d58bd 100644 (file)
@@ -5,7 +5,7 @@
       %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; "}
           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}"
             = truncate(@issue.title, :length => 35)
       %td{:style => "font-size: 1px; line-height: 1px;", :width => "21"}
@@ -13,7 +13,7 @@
       %td{:style => "font-size: 1px; line-height: 1px;", :width => "21"}
       %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; "}
-          %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:
         %br
           %table{:border => "0", :cellpadding => "0", :cellspacing => "0", :width => "558"}
index 0528409..e9c87b9 100644 (file)
@@ -230,7 +230,8 @@ describe Notify 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, note) }
+
+        subject { Notify.note_issue_email(recipient.id, note.id) }
 
         it_behaves_like 'a note email'