Project

General

Profile

Feature #39723 ยป add-assigned_to_you-tag-in-email-subjects .patch

Takenori TAKAKI, 2023-11-24 10:47

View differences:

app/models/mailer.rb
85 85
    @issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue)
86 86
    subject = "[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}]"
87 87
    subject += " (#{issue.status.name})" if Setting.show_status_changes_in_mail_subject?
88
    subject += " (#{I18n.t('label_assigned_to_you')})" if issue.assigned_to == user && Setting.show_assigned_to_you_in_mail_subject?
88 89
    subject += " #{issue.subject}"
89 90
    mail :to => user,
90 91
      :subject => subject
......
115 116
    @author = journal.user
116 117
    s = "[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}] "
117 118
    s += "(#{issue.status.name}) " if journal.new_value_for('status_id') && Setting.show_status_changes_in_mail_subject?
119
    s += "(#{I18n.t('label_assigned_to_you')}) " if issue.assigned_to == user && Setting.show_assigned_to_you_in_mail_subject?
118 120
    s += issue.subject
119 121
    @issue = issue
120 122
    @user = user
app/views/settings/_notifications.html.erb
7 7
<p><%= setting_check_box :plain_text_mail %></p>
8 8

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

  
11
<p><%= setting_check_box :show_assigned_to_you_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
514 514
  setting_timelog_max_hours_per_day: Maximum hours that can be logged per day and user
515 515
  setting_timelog_accept_future_dates: Accept time logs on future dates
516 516
  setting_show_status_changes_in_mail_subject: Show status changes in issue mail notifications subject
517
  setting_show_assigned_to_you_in_mail_subject: Show issue assigned to you in issue mail notifications subject
517 518
  setting_project_list_defaults: Projects list defaults
518 519
  setting_twofa: Two-factor authentication
519 520

  
......
1135 1136
  label_display_type_board: Board
1136 1137
  label_my_bookmarks: My bookmarks
1137 1138
  label_assign_to_me: Assign to me
1139
  label_assigned_to_you: Assigned to you
1138 1140
  label_default_query: Default query
1139 1141
  label_edited: Edited
1140 1142
  label_time_by_author: "%{time} by %{author}"
config/settings.yml
341 341
  default: 1
342 342
show_status_changes_in_mail_subject:
343 343
  default: 1
344
show_assigned_to_you_in_mail_subject:
345
  default: ''
test/unit/mailer_test.rb
533 533
    end
534 534
  end
535 535

  
536
  def test_issue_add_subject_should_include_assigned_to_you_if_setting_show_assigned_to_you_in_mail_subject_is_enabled
537
    with_settings :show_assigned_to_you_in_mail_subject => 1 do
538
      issue = Issue.find(2)
539
      assert assignee = issue.assigned_to
540
      Mailer.deliver_issue_add(issue)
541
      assert mail = ActionMailer::Base.deliveries.find {|m| m.to.include?(assignee.mail)}
542
      assert_equal "[eCookbook - Feature request #2] (Assigned) (Assigned to you) Add ingredients categories", mail.subject
543
    end
544
  end
545

  
546
  def test_issue_add_subject_should_not_include_assigned_to_you_if_setting_show_assigned_to_you_in_mail_subject_is_disabled
547
    with_settings :show_assigned_to_you_in_mail_subject => 0 do
548
      issue = Issue.find(2)
549
      assert assignee = issue.assigned_to
550
      Mailer.deliver_issue_add(issue)
551
      assert mail = ActionMailer::Base.deliveries.find {|m| m.to.include?(assignee.mail)}
552
      assert_equal "[eCookbook - Feature request #2] (Assigned) Add ingredients categories", mail.subject
553
    end
554
  end
555

  
536 556
  def test_issue_add_should_include_issue_status_type_badge
537 557
    issue = Issue.find(1)
538 558
    Mailer.deliver_issue_add(issue)
    (1-1/1)