From 032d045383bcd25cbb042bfb92ea3abf44486a8a Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Wed, 13 Mar 2013 16:03:53 +0400 Subject: [PATCH 1/3] #15: update subjects for new Issues/PullRequests/Comments --- app/mailers/user_mailer.rb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb index 057c735cc..45797d8b8 100644 --- a/app/mailers/user_mailer.rb +++ b/app/mailers/user_mailer.rb @@ -16,7 +16,10 @@ class UserMailer < ActionMailer::Base def new_comment_notification(comment, user) @user = user @comment = comment - mail(:to => user.email, :subject => I18n.t("notifications.subjects.new_#{comment.commit_comment? ? 'commit_' : ''}comment_notification")) do |format| + issue = @comment.commentable if @comment.issue_comment? + subject = issue ? "Re: [#{issue.project.name}] #{issue.title} (##{issue.serial_id})" : + I18n.t('notifications.subjects.new_commit_comment_notification') + mail(:to => user.email, :subject => subject) do |format| format.html end end @@ -24,7 +27,8 @@ class UserMailer < ActionMailer::Base def new_issue_notification(issue, user) @user = user @issue = issue - mail(:to => user.email, :subject => I18n.t("notifications.subjects.new_issue_notification")) do |format| + subject = "[#{issue.project.name}] #{issue.title} (##{issue.serial_id})" + mail(:to => user.email, :subject => subject) do |format| format.html end end @@ -32,7 +36,8 @@ class UserMailer < ActionMailer::Base def issue_assign_notification(issue, user) @user = user @issue = issue - mail(:to => user.email, :subject => I18n.t("notifications.subjects.issue_assign_notification")) do |format| + subject = "Re: [#{issue.project.name}] #{issue.title} (##{issue.serial_id})" + mail(:to => user.email, :subject => subject) do |format| format.html end end From 7986f4198695822193530881fe6ebc144cfc4c6e Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Wed, 13 Mar 2013 16:11:42 +0400 Subject: [PATCH 2/3] #15: some refactoring --- app/mailers/user_mailer.rb | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb index 45797d8b8..1df8fa215 100644 --- a/app/mailers/user_mailer.rb +++ b/app/mailers/user_mailer.rb @@ -16,9 +16,8 @@ class UserMailer < ActionMailer::Base def new_comment_notification(comment, user) @user = user @comment = comment - issue = @comment.commentable if @comment.issue_comment? - subject = issue ? "Re: [#{issue.project.name}] #{issue.title} (##{issue.serial_id})" : - I18n.t('notifications.subjects.new_commit_comment_notification') + 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 end @@ -27,8 +26,7 @@ class UserMailer < ActionMailer::Base def new_issue_notification(issue, user) @user = user @issue = issue - subject = "[#{issue.project.name}] #{issue.title} (##{issue.serial_id})" - mail(:to => user.email, :subject => subject) do |format| + mail(:to => user.email, :subject => subject_for_issue(@issue, true)) do |format| format.html end end @@ -36,8 +34,7 @@ class UserMailer < ActionMailer::Base def issue_assign_notification(issue, user) @user = user @issue = issue - subject = "Re: [#{issue.project.name}] #{issue.title} (##{issue.serial_id})" - mail(:to => user.email, :subject => subject) do |format| + mail(:to => user.email, :subject => subject_for_issue(@issue)) do |format| format.html end end @@ -62,4 +59,11 @@ class UserMailer < ActionMailer::Base format.html end end + + protected + + def subject_for_issue(issue, create = false) + subject = create ? '' : 'Re: ' + subject << "[#{issue.project.name}] #{issue.title} (##{issue.serial_id})" + end end From 30712be4cc7f0cf5aa9a10777b00fa80dc3e2b86 Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Wed, 13 Mar 2013 16:14:24 +0400 Subject: [PATCH 3/3] #15: hot fix --- app/mailers/user_mailer.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb index 1df8fa215..4164b66c9 100644 --- a/app/mailers/user_mailer.rb +++ b/app/mailers/user_mailer.rb @@ -62,8 +62,8 @@ class UserMailer < ActionMailer::Base protected - def subject_for_issue(issue, create = false) - subject = create ? '' : 'Re: ' + def subject_for_issue(issue, new_issue = false) + subject = new_issue ? '' : 'Re: ' subject << "[#{issue.project.name}] #{issue.title} (##{issue.serial_id})" end end