Feature #2746 » 2746.patch
app/models/mailer.rb | ||
---|---|---|
71 | 71 | |
72 | 72 |
# Builds a mail for notifying user about a new issue |
73 | 73 |
def issue_add(user, issue) |
74 |
headers['Priority'] = priority_for_header(issue) |
|
74 | 75 |
redmine_headers 'Project' => issue.project.identifier, |
75 | 76 |
'Issue-Tracker' => issue.tracker.name, |
76 | 77 |
'Issue-Id' => issue.id, |
... | ... | |
103 | 104 |
# Builds a mail for notifying user about an issue update |
104 | 105 |
def issue_edit(user, journal) |
105 | 106 |
issue = journal.journalized |
107 |
headers['Priority'] = priority_for_header(issue) |
|
106 | 108 |
redmine_headers 'Project' => issue.project.identifier, |
107 | 109 |
'Issue-Tracker' => issue.tracker.name, |
108 | 110 |
'Issue-Id' => issue.id, |
... | ... | |
763 | 765 |
h.each {|k, v| headers["X-Redmine-#{k}"] = v.to_s} |
764 | 766 |
end |
765 | 767 | |
768 |
def priority_for_header(issue) |
|
769 |
# IssuePriority#low? and IssuePriority#high? are not used for |
|
770 |
# performance reasons |
|
771 |
position_name = issue.priority.position_name.to_s |
|
772 |
if position_name == 'default' |
|
773 |
'normal' |
|
774 |
elsif position_name.start_with?('high') |
|
775 |
'urgent' |
|
776 |
elsif position_name.start_with?('low') |
|
777 |
'non-urgent' |
|
778 |
end |
|
779 |
end |
|
780 | ||
766 | 781 |
# Singleton class method is public |
767 | 782 |
class << self |
768 | 783 |
def token_for(object, user) |
test/unit/mailer_test.rb | ||
---|---|---|
210 | 210 |
# List-Id should not include the display name "Redmine" |
211 | 211 |
assert_equal '<redmine.example.net>', mail.header['List-Id'].to_s |
212 | 212 |
assert_equal 'Bug', mail.header['X-Redmine-Issue-Tracker'].to_s |
213 |
assert_equal 'non-urgent', mail.header['Priority'].to_s |
|
213 | 214 |
end |
214 | 215 | |
215 | 216 |
def test_email_headers_should_include_sender |
... | ... | |
219 | 220 |
assert_equal issue.author.login, mail.header['X-Redmine-Sender'].to_s |
220 | 221 |
end |
221 | 222 | |
223 |
def test_email_headers_should_include_priority |
|
224 |
to_test = { |
|
225 |
IssuePriority.find(4) => 'non-urgent', # Low |
|
226 |
IssuePriority.find(5) => 'normal', # Normal |
|
227 |
IssuePriority.find(6) => 'urgent', # High |
|
228 |
IssuePriority.find(7) => 'urgent', # Urgent |
|
229 |
IssuePriority.find(8) => 'urgent', # Immediate |
|
230 |
} |
|
231 | ||
232 |
issue = Issue.find(1) |
|
233 |
to_test.each do |priority, expected| |
|
234 |
issue.update_attribute :priority_id, priority.id |
|
235 |
Mailer.deliver_issue_add(issue) |
|
236 |
mail = last_email |
|
237 |
assert_equal expected, mail.header['Priority'].to_s |
|
238 |
end |
|
239 |
end |
|
240 | ||
222 | 241 |
def test_plain_text_mail |
223 | 242 |
Setting.plain_text_mail = 1 |
224 | 243 |
journal = Journal.find(2) |