Project

General

Profile

Feature #10378 ยป 10378-suppress-empty-fields.patch

Yuichi HARADA, 2018-11-14 09:00

View differences:

app/helpers/issues_helper.rb
82 82
    s << '<div>'
83 83
    subject = h(issue.subject)
84 84
    if issue.is_private?
85
      subject = subject + ' ' + content_tag('span', l(:field_is_private), :class => 'private') 
85
      subject = subject + ' ' + content_tag('span', l(:field_is_private), :class => 'private')
86 86
    end
87 87
    s << content_tag('h3', subject)
88 88
    s << '</div>' * (ancestors.size + 1)
......
309 309
    items = []
310 310
    %w(author status priority assigned_to category fixed_version).each do |attribute|
311 311
      unless issue.disabled_core_fields.include?(attribute+"_id")
312
        attr_value = "#{issue.send attribute}"
313
        next if attr_value.blank?
312 314
        if html
313
          items << content_tag('strong', "#{l("field_#{attribute}")}: ") + (issue.send attribute)
315
          items << content_tag('strong', "#{l("field_#{attribute}")}: ") + attr_value
314 316
        else
315
          items << "#{l("field_#{attribute}")}: #{issue.send attribute}"
317
          items << "#{l("field_#{attribute}")}: #{attr_value}"
316 318
        end
317 319
      end
318 320
    end
319 321
    issue.visible_custom_field_values(user).each do |value|
322
      cf_value = show_value(value, false)
323
      next if cf_value.blank?
320 324
      if html
321
        items << content_tag('strong', "#{value.custom_field.name}: ") + show_value(value, false)
325
        items << content_tag('strong', "#{value.custom_field.name}: ") + cf_value
322 326
      else
323
        items << "#{value.custom_field.name}: #{show_value(value, false)}"
327
        items << "#{value.custom_field.name}: #{cf_value}"
324 328
      end
325 329
    end
326 330
    items
test/unit/mailer_test.rb
450 450
    end
451 451
  end
452 452

  
453
  def test_issue_should_send_email_notification_with_suppress_empty_fields
454
    ActionMailer::Base.deliveries.clear
455
    with_settings :notified_events => %w(issue_added) do
456
      cf = IssueCustomField.generate!
457
      issue = Issue.generate!
458

  
459
      assert_not_equal 0, ActionMailer::Base.deliveries.size
460

  
461
      mail = last_email
462
      assert_mail_body_match /^\* Author: /, mail
463
      assert_mail_body_match /^\* Status: /, mail
464
      assert_mail_body_match /^\* Priority: /, mail
465

  
466
      assert_mail_body_no_match /^\* Assignee: /, mail
467
      assert_mail_body_no_match /^\* Category: /, mail
468
      assert_mail_body_no_match /^\* Target version: /, mail
469
      assert_mail_body_no_match /^\* #{cf.name}: /, mail
470
    end
471
  end
472

  
453 473
  def test_version_file_added
454 474
    attachements = [ Attachment.find_by_container_type('Version') ]
455 475
    assert Mailer.deliver_attachments_added(attachements)
    (1-1/1)