0001-New-setting-to-include-the-status-changes-in-issue-m.patch

Marius BALTEANU, 2019-02-19 23:00

Download (4.86 KB)

View differences:

app/models/mailer.rb
77 77
    @issue = issue
78 78
    @user = user
79 79
    @issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue)
80
    subject = "[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}]"
81
    subject << " (#{issue.status.name})" if Setting.show_status_changes_in_mail_subject?
82
    subject << " #{issue.subject}"
80 83
    mail :to => user,
81
      :subject => "[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}] (#{issue.status.name}) #{issue.subject}"
84
      :subject => subject
82 85
  end
83 86

  
84 87
  # Notifies users about a new issue.
......
103 106
    references issue
104 107
    @author = journal.user
105 108
    s = "[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}] "
106
    s << "(#{issue.status.name}) " if journal.new_value_for('status_id')
109
    s << "(#{issue.status.name}) " if journal.new_value_for('status_id') && Setting.show_status_changes_in_mail_subject?
107 110
    s << issue.subject
108 111
    @issue = issue
109 112
    @user = user
app/views/settings/_notifications.html.erb
7 7
<p><%= setting_check_box :bcc_recipients %></p>
8 8

  
9 9
<p><%= setting_check_box :plain_text_mail %></p>
10

  
11
<p><%= setting_check_box :show_status_changes_in_mail_subject %></p>
10 12
</div>
11 13

  
12 14
<fieldset class="box" id="notified_events"><legend><%=l(:text_select_mail_notifications)%></legend>
config/locales/en.yml
472 472
  setting_timelog_accept_0_hours: Accept time logs with 0 hours
473 473
  setting_timelog_max_hours_per_day: Maximum hours that can be logged per day and user
474 474
  setting_timelog_accept_future_dates: Accept time logs on future dates
475
  setting_show_status_changes_in_mail_subject: Show status changes in issue mail notifications subject
475 476

  
476 477
  permission_add_project: Create project
477 478
  permission_add_subprojects: Create subprojects
config/settings.yml
310 310
  default: 999
311 311
timelog_accept_future_dates:
312 312
  default: 1
313
show_status_changes_in_mail_subject:
314
  default: 1
test/unit/mailer_test.rb
422 422
    end
423 423
  end
424 424

  
425
  def test_issue_add_subject_should_include_status_if_setting_is_enabled
426
    with_settings :show_status_changes_in_mail_subject => 1 do
427
      issue = Issue.find(2)
428
      Mailer.deliver_issue_add(issue)
429

  
430
      mail = last_email
431
      assert_equal "[eCookbook - Feature request #2] (Assigned) Add ingredients categories", mail.subject
432
    end
433
  end
434

  
435
  def test_issue_add_subject_should_not_include_status_if_setting_is_disabled
436
    with_settings :show_status_changes_in_mail_subject => 0 do
437
      issue = Issue.find(2)
438
      Mailer.deliver_issue_add(issue)
439

  
440
      mail = last_email
441
      assert_equal "[eCookbook - Feature request #2] Add ingredients categories", mail.subject
442
    end
443
  end
444

  
445
  def test_issue_edit_subject_should_include_status_changes_if_setting_is_enabled
446
    with_settings :show_status_changes_in_mail_subject => 1 do
447
      issue = Issue.find(2)
448
      issue.status_id = 4
449
      issue.save!
450
      Mailer.deliver_issue_add(issue)
451

  
452
      mail = last_email
453
      assert_equal "[eCookbook - Feature request #2] (Feedback) Add ingredients categories", mail.subject
454
    end
455
  end
456

  
457
  def test_issue_edit_subject_should_not_include_status_changes_if_setting_is_disabled
458
    with_settings :show_status_changes_in_mail_subject => 0 do
459
      issue = Issue.find(2)
460
      issue.status_id = 4
461
      issue.save!
462
      Mailer.deliver_issue_add(issue)
463

  
464
      mail = last_email
465
      assert_equal "[eCookbook - Feature request #2] Add ingredients categories", mail.subject
466
    end
467
  end
468

  
425 469
  def test_issue_edit_should_send_private_notes_to_users_with_permission_only
426 470
    journal = Journal.find(1)
427 471
    journal.private_notes = true
428
-