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:
parent
435fd8f087
commit
0a9a2c2a0b
|
@ -28,12 +28,11 @@ class Notify < ActionMailer::Base
|
||||||
mail(:to => @user['email'], :subject => "gitlab | #{@note.project.name} ")
|
mail(:to => @user['email'], :subject => "gitlab | #{@note.project.name} ")
|
||||||
end
|
end
|
||||||
|
|
||||||
def note_commit_email(user, note)
|
def note_commit_email(recipient_id, note_id)
|
||||||
@user = user
|
recipient = User.find(recipient_id)
|
||||||
@note = Note.find(note['id'])
|
@note = Note.find(note_id)
|
||||||
@project = @note.project
|
|
||||||
@commit = @note.target
|
@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
|
end
|
||||||
|
|
||||||
def note_merge_request_email(recipient_id, note_id)
|
def note_merge_request_email(recipient_id, note_id)
|
||||||
|
|
|
@ -5,13 +5,13 @@
|
||||||
%td{:align => "left", :style => "padding: 20px 0 0;"}
|
%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; "}
|
%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
|
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"}
|
%td{:style => "font-size: 1px; line-height: 1px;", :width => "21"}
|
||||||
%tr
|
%tr
|
||||||
%td{:style => "font-size: 1px; line-height: 1px;", :width => "21"}
|
%td{:style => "font-size: 1px; line-height: 1px;", :width => "21"}
|
||||||
%td{:style => "padding: 15px 0 15px;", :valign => "top"}
|
%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; "}
|
%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:
|
left next message:
|
||||||
%br
|
%br
|
||||||
%table{:border => "0", :cellpadding => "0", :cellspacing => "0", :width => "558"}
|
%table{:border => "0", :cellpadding => "0", :cellspacing => "0", :width => "558"}
|
||||||
|
|
|
@ -190,7 +190,8 @@ describe Notify do
|
||||||
describe 'on a commit' do
|
describe 'on a commit' do
|
||||||
let(:commit) do
|
let(:commit) do
|
||||||
mock(:commit).tap do |commit|
|
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
|
||||||
end
|
end
|
||||||
before(:each) { note.stub(:target).and_return(commit) }
|
before(:each) { note.stub(:target).and_return(commit) }
|
||||||
|
@ -204,7 +205,7 @@ describe Notify do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'contains a link to the commit' do
|
it 'contains a link to the commit' do
|
||||||
should have_body_text /faux_sha_1/
|
should have_body_text /fauxsha1/
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue