summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGo MAEDA <maeda@farend.jp>2019-02-28 08:23:17 +0000
committerGo MAEDA <maeda@farend.jp>2019-02-28 08:23:17 +0000
commit8af0990073dee50e0983aae35c52463ee72e4f6c (patch)
tree8c9eb4877d53085eeebd1199abe8e95a6dd002ab
parent0a23eabdce9cff8f7744097a068d9531c6144b1b (diff)
downloadredmine-8af0990073dee50e0983aae35c52463ee72e4f6c.tar.gz
redmine-8af0990073dee50e0983aae35c52463ee72e4f6c.zip
New setting to include the status changes in issue mail notifications subject (#13111).
Patch by Marius BALTEANU. git-svn-id: http://svn.redmine.org/redmine/trunk@17907 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--app/models/mailer.rb7
-rw-r--r--app/views/settings/_notifications.html.erb2
-rw-r--r--config/locales/en.yml1
-rw-r--r--config/settings.yml2
-rw-r--r--test/unit/mailer_test.rb44
5 files changed, 54 insertions, 2 deletions
diff --git a/app/models/mailer.rb b/app/models/mailer.rb
index 2364774fb..01ab60efd 100644
--- a/app/models/mailer.rb
+++ b/app/models/mailer.rb
@@ -77,8 +77,11 @@ class Mailer < ActionMailer::Base
@issue = issue
@user = user
@issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue)
+ subject = "[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}]"
+ subject << " (#{issue.status.name})" if Setting.show_status_changes_in_mail_subject?
+ subject << " #{issue.subject}"
mail :to => user,
- :subject => "[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}] (#{issue.status.name}) #{issue.subject}"
+ :subject => subject
end
# Notifies users about a new issue.
@@ -103,7 +106,7 @@ class Mailer < ActionMailer::Base
references issue
@author = journal.user
s = "[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}] "
- s << "(#{issue.status.name}) " if journal.new_value_for('status_id')
+ s << "(#{issue.status.name}) " if journal.new_value_for('status_id') && Setting.show_status_changes_in_mail_subject?
s << issue.subject
@issue = issue
@user = user
diff --git a/app/views/settings/_notifications.html.erb b/app/views/settings/_notifications.html.erb
index 0f5051404..f50bd33cb 100644
--- a/app/views/settings/_notifications.html.erb
+++ b/app/views/settings/_notifications.html.erb
@@ -7,6 +7,8 @@
<p><%= setting_check_box :bcc_recipients %></p>
<p><%= setting_check_box :plain_text_mail %></p>
+
+<p><%= setting_check_box :show_status_changes_in_mail_subject %></p>
</div>
<fieldset class="box" id="notified_events"><legend><%=l(:text_select_mail_notifications)%></legend>
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 43d3524ee..38447e067 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -472,6 +472,7 @@ en:
setting_timelog_accept_0_hours: Accept time logs with 0 hours
setting_timelog_max_hours_per_day: Maximum hours that can be logged per day and user
setting_timelog_accept_future_dates: Accept time logs on future dates
+ setting_show_status_changes_in_mail_subject: Show status changes in issue mail notifications subject
permission_add_project: Create project
permission_add_subprojects: Create subprojects
diff --git a/config/settings.yml b/config/settings.yml
index b6c026104..e0f49ea2b 100644
--- a/config/settings.yml
+++ b/config/settings.yml
@@ -310,3 +310,5 @@ timelog_max_hours_per_day:
default: 999
timelog_accept_future_dates:
default: 1
+show_status_changes_in_mail_subject:
+ default: 1 \ No newline at end of file
diff --git a/test/unit/mailer_test.rb b/test/unit/mailer_test.rb
index d3ff87418..f2deedab5 100644
--- a/test/unit/mailer_test.rb
+++ b/test/unit/mailer_test.rb
@@ -422,6 +422,50 @@ class MailerTest < ActiveSupport::TestCase
end
end
+ def test_issue_add_subject_should_include_status_if_setting_is_enabled
+ with_settings :show_status_changes_in_mail_subject => 1 do
+ issue = Issue.find(2)
+ Mailer.deliver_issue_add(issue)
+
+ mail = last_email
+ assert_equal "[eCookbook - Feature request #2] (Assigned) Add ingredients categories", mail.subject
+ end
+ end
+
+ def test_issue_add_subject_should_not_include_status_if_setting_is_disabled
+ with_settings :show_status_changes_in_mail_subject => 0 do
+ issue = Issue.find(2)
+ Mailer.deliver_issue_add(issue)
+
+ mail = last_email
+ assert_equal "[eCookbook - Feature request #2] Add ingredients categories", mail.subject
+ end
+ end
+
+ def test_issue_edit_subject_should_include_status_changes_if_setting_is_enabled
+ with_settings :show_status_changes_in_mail_subject => 1 do
+ issue = Issue.find(2)
+ issue.status_id = 4
+ issue.save!
+ Mailer.deliver_issue_add(issue)
+
+ mail = last_email
+ assert_equal "[eCookbook - Feature request #2] (Feedback) Add ingredients categories", mail.subject
+ end
+ end
+
+ def test_issue_edit_subject_should_not_include_status_changes_if_setting_is_disabled
+ with_settings :show_status_changes_in_mail_subject => 0 do
+ issue = Issue.find(2)
+ issue.status_id = 4
+ issue.save!
+ Mailer.deliver_issue_add(issue)
+
+ mail = last_email
+ assert_equal "[eCookbook - Feature request #2] Add ingredients categories", mail.subject
+ end
+ end
+
def test_issue_edit_should_send_private_notes_to_users_with_permission_only
journal = Journal.find(1)
journal.private_notes = true