Commit 0a9a2c2a0b75ba617611382b6335bf2b7fc68b9f

Authored by Robb Kidd
1 parent 435fd8f0

Make Notify#note_commit_email resque friendly

Update method to take ids and then perform #finds itself during mailer
queue worker kick-off. Also, the faux SHA1 cannot have underscores or
it will not match the commit pattern defined in the routes.
app/mailers/notify.rb
... ... @@ -28,12 +28,11 @@ class Notify < ActionMailer::Base
28 28 mail(:to => @user['email'], :subject => "gitlab | #{@note.project.name} ")
29 29 end
30 30  
31   - def note_commit_email(user, note)
32   - @user = user
33   - @note = Note.find(note['id'])
34   - @project = @note.project
  31 + def note_commit_email(recipient_id, note_id)
  32 + recipient = User.find(recipient_id)
  33 + @note = Note.find(note_id)
35 34 @commit = @note.target
36   - mail(:to => @user['email'], :subject => "gitlab | note for commit | #{@note.project.name} ")
  35 + mail(:to => recipient.email, :subject => "gitlab | note for commit | #{@note.project.name} ")
37 36 end
38 37  
39 38 def note_merge_request_email(recipient_id, note_id)
... ...
app/views/notify/note_commit_email.html.haml
... ... @@ -5,13 +5,13 @@
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 7 New comment for commit
8   - = link_to truncate(@commit.id.to_s, :length => 16), project_commit_url(@project, :id => @commit.id, :anchor => "note_#{@note.id}")
  8 + = link_to truncate(@commit.id.to_s, :length => 16), project_commit_url(@commit.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"}
12 12 %td{:style => "padding: 15px 0 15px;", :valign => "top"}
13 13 %p{:style => "color:#767676; font-weight: normal; margin: 0; padding: 0; line-height: 20px; font-size: 12px;font-family: Helvetica, Arial, sans-serif; "}
14   - %a{:href => "#", :style => "color: #0eb6ce; text-decoration: none;"} #{@note.author.name}
  14 + %a{:href => "#", :style => "color: #0eb6ce; text-decoration: none;"} #{@note.author_name}
15 15 left next message:
16 16 %br
17 17 %table{:border => "0", :cellpadding => "0", :cellspacing => "0", :width => "558"}
... ...
spec/mailers/notify_spec.rb
... ... @@ -190,7 +190,8 @@ describe Notify do
190 190 describe 'on a commit' do
191 191 let(:commit) do
192 192 mock(:commit).tap do |commit|
193   - commit.stub(:id).and_return('faux_sha_1')
  193 + commit.stub(:id).and_return('fauxsha1')
  194 + commit.stub(:project).and_return(project)
194 195 end
195 196 end
196 197 before(:each) { note.stub(:target).and_return(commit) }
... ... @@ -204,7 +205,7 @@ describe Notify do
204 205 end
205 206  
206 207 it 'contains a link to the commit' do
207   - should have_body_text /faux_sha_1/
  208 + should have_body_text /fauxsha1/
208 209 end
209 210 end
210 211  
... ...