Merge pull request #20 from abf/rosa-build:15-notification-emails

#15: Informative subject in notification emails about new Issue/PullRequest and comment for it
This commit is contained in:
warpc 2013-03-14 00:41:58 +04:00
commit 5971ecb354
1 changed files with 12 additions and 3 deletions

View File

@ -16,7 +16,9 @@ class UserMailer < ActionMailer::Base
def new_comment_notification(comment, user) def new_comment_notification(comment, user)
@user = user @user = user
@comment = comment @comment = comment
mail(:to => user.email, :subject => I18n.t("notifications.subjects.new_#{comment.commit_comment? ? 'commit_' : ''}comment_notification")) do |format| subject = @comment.issue_comment? ? subject_for_issue(@comment.commentable) :
I18n.t('notifications.subjects.new_commit_comment_notification')
mail(:to => user.email, :subject => subject) do |format|
format.html format.html
end end
end end
@ -24,7 +26,7 @@ class UserMailer < ActionMailer::Base
def new_issue_notification(issue, user) def new_issue_notification(issue, user)
@user = user @user = user
@issue = issue @issue = issue
mail(:to => user.email, :subject => I18n.t("notifications.subjects.new_issue_notification")) do |format| mail(:to => user.email, :subject => subject_for_issue(@issue, true)) do |format|
format.html format.html
end end
end end
@ -32,7 +34,7 @@ class UserMailer < ActionMailer::Base
def issue_assign_notification(issue, user) def issue_assign_notification(issue, user)
@user = user @user = user
@issue = issue @issue = issue
mail(:to => user.email, :subject => I18n.t("notifications.subjects.issue_assign_notification")) do |format| mail(:to => user.email, :subject => subject_for_issue(@issue)) do |format|
format.html format.html
end end
end end
@ -57,4 +59,11 @@ class UserMailer < ActionMailer::Base
format.html format.html
end end
end end
protected
def subject_for_issue(issue, new_issue = false)
subject = new_issue ? '' : 'Re: '
subject << "[#{issue.project.name}] #{issue.title} (##{issue.serial_id})"
end
end end