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.
This commit is contained in:
Robb Kidd 2012-05-15 19:20:15 -04:00
parent 435fd8f087
commit 0a9a2c2a0b
3 changed files with 9 additions and 9 deletions

View file

@ -28,12 +28,11 @@ class Notify < ActionMailer::Base
mail(:to => @user['email'], :subject => "gitlab | #{@note.project.name} ")
end
def note_commit_email(user, note)
@user = user
@note = Note.find(note['id'])
@project = @note.project
def note_commit_email(recipient_id, note_id)
recipient = User.find(recipient_id)
@note = Note.find(note_id)
@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
def note_merge_request_email(recipient_id, note_id)

View file

@ -5,13 +5,13 @@
%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; "}
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"}
%tr
%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"}

View file

@ -190,7 +190,8 @@ describe Notify do
describe 'on a commit' do
let(:commit) do
mock(:commit).tap do |commit|
commit.stub(:id).and_return('faux_sha_1')
commit.stub(:id).and_return('fauxsha1')
commit.stub(:project).and_return(project)
end
end
before(:each) { note.stub(:target).and_return(commit) }
@ -204,7 +205,7 @@ describe Notify do
end
it 'contains a link to the commit' do
should have_body_text /faux_sha_1/
should have_body_text /fauxsha1/
end
end