mirror of
https://github.com/redmine/redmine.git
synced 2025-11-15 09:46:02 +01:00
Don't show empty fields in email notifications (#10378).
Patch by Yuichi HARADA. git-svn-id: http://svn.redmine.org/redmine/trunk@18280 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -326,18 +326,22 @@ module IssuesHelper
|
|||||||
items = []
|
items = []
|
||||||
%w(author status priority assigned_to category fixed_version start_date due_date).each do |attribute|
|
%w(author status priority assigned_to category fixed_version start_date due_date).each do |attribute|
|
||||||
if issue.disabled_core_fields.grep(/^#{attribute}(_id)?$/).empty?
|
if issue.disabled_core_fields.grep(/^#{attribute}(_id)?$/).empty?
|
||||||
|
attr_value = "#{issue.send attribute}"
|
||||||
|
next if attr_value.blank?
|
||||||
if html
|
if html
|
||||||
items << content_tag('strong', "#{l("field_#{attribute}")}: ") + (issue.send attribute)
|
items << content_tag('strong', "#{l("field_#{attribute}")}: ") + attr_value
|
||||||
else
|
else
|
||||||
items << "#{l("field_#{attribute}")}: #{issue.send attribute}"
|
items << "#{l("field_#{attribute}")}: #{attr_value}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
issue.visible_custom_field_values(user).each do |value|
|
issue.visible_custom_field_values(user).each do |value|
|
||||||
|
cf_value = show_value(value, false)
|
||||||
|
next if cf_value.blank?
|
||||||
if html
|
if html
|
||||||
items << content_tag('strong', "#{value.custom_field.name}: ") + show_value(value, false)
|
items << content_tag('strong', "#{value.custom_field.name}: ") + cf_value
|
||||||
else
|
else
|
||||||
items << "#{value.custom_field.name}: #{show_value(value, false)}"
|
items << "#{value.custom_field.name}: #{cf_value}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
items
|
items
|
||||||
|
|||||||
@@ -550,6 +550,27 @@ class MailerTest < ActiveSupport::TestCase
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_issue_should_send_email_notification_with_suppress_empty_fields
|
||||||
|
ActionMailer::Base.deliveries.clear
|
||||||
|
with_settings :notified_events => %w(issue_added) do
|
||||||
|
cf = IssueCustomField.generate!
|
||||||
|
issue = Issue.generate!
|
||||||
|
Mailer.deliver_issue_add(issue)
|
||||||
|
|
||||||
|
assert_not_equal 0, ActionMailer::Base.deliveries.size
|
||||||
|
|
||||||
|
mail = last_email
|
||||||
|
assert_mail_body_match /^\* Author: /, mail
|
||||||
|
assert_mail_body_match /^\* Status: /, mail
|
||||||
|
assert_mail_body_match /^\* Priority: /, mail
|
||||||
|
|
||||||
|
assert_mail_body_no_match /^\* Assignee: /, mail
|
||||||
|
assert_mail_body_no_match /^\* Category: /, mail
|
||||||
|
assert_mail_body_no_match /^\* Target version: /, mail
|
||||||
|
assert_mail_body_no_match /^\* #{cf.name}: /, mail
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def test_version_file_added
|
def test_version_file_added
|
||||||
attachements = [ Attachment.find_by_container_type('Version') ]
|
attachements = [ Attachment.find_by_container_type('Version') ]
|
||||||
assert Mailer.deliver_attachments_added(attachements)
|
assert Mailer.deliver_attachments_added(attachements)
|
||||||
|
|||||||
Reference in New Issue
Block a user