35017_v1.patch

Akihiro MATOBA, 2021-04-03 12:54

Download (2.97 KB)

View differences:

app/models/mailer.rb
75 75
                    'Issue-Tracker' => issue.tracker.name,
76 76
                    'Issue-Id' => issue.id,
77 77
                    'Issue-Author' => issue.author.login
78
    redmine_headers 'Issue-Assignee' => issue.assigned_to.login if issue.assigned_to
78
    redmine_headers 'Issue-Assignee' => issue.assigned_to.login if issue.assigned_to.is_a?(User)
79
    redmine_headers 'Issue-Assignee' => "Group (#{issue.assigned_to.name})" if issue.assigned_to.is_a?(Group)
79 80
    message_id issue
80 81
    references issue
81 82
    @author = issue.author
......
107 108
                    'Issue-Tracker' => issue.tracker.name,
108 109
                    'Issue-Id' => issue.id,
109 110
                    'Issue-Author' => issue.author.login
110
    redmine_headers 'Issue-Assignee' => issue.assigned_to.login if issue.assigned_to
111
    redmine_headers 'Issue-Assignee' => issue.assigned_to.login if issue.assigned_to.is_a?(User)
112
    redmine_headers 'Issue-Assignee' => "Group (#{issue.assigned_to.name})" if issue.assigned_to.is_a?(Group)
111 113
    message_id journal
112 114
    references issue
113 115
    @author = journal.user
test/unit/mailer_test.rb
219 219
    assert_equal issue.author.login, mail.header['X-Redmine-Sender'].to_s
220 220
  end
221 221

  
222
  def test_email_headers_shouldnt_include_assignee_when_not_assigned
223
    issue = Issue.find(6)
224
    issue.init_journal(User.current)
225
    issue.update(:status_id => 4)
226
    issue.update(:assigned_to_id => nil)
227
    mail = last_email
228
    assert !mail.header['X-Redmine-Issue-Assignee']
229
  end
230
  
231
  def test_email_headers_should_include_assignee_when_assigned
232
    issue = Issue.find(6)
233
    issue.init_journal(User.current)
234
    issue.update(:assigned_to_id => 2)
235
    mail = last_email
236
    assert_equal issue.assigned_to.login, mail.header['X-Redmine-Issue-Assignee'].to_s
237
  end
238

  
239
  def test_email_headers_should_include_assignee_if_assigned_to_group
240
    issue = Issue.find(6)
241
    with_settings :issue_group_assignment => 1 do
242
      issue.init_journal(User.current)
243
      issue.update(:assigned_to_id => 10)  # Group: A Team
244
    end
245
    mail = last_email
246
    assert_equal "Group (#{issue.assigned_to.name})", mail.header['X-Redmine-Issue-Assignee'].to_s
247
  end
248

  
222 249
  def test_plain_text_mail
223 250
    Setting.plain_text_mail = 1
224 251
    journal = Journal.find(2)
225
-