Feature #2746 » 2746.patch
| app/models/mailer.rb | ||
|---|---|---|
|
# Builds a mail for notifying user about a new issue
|
||
|
def issue_add(user, issue)
|
||
|
headers['Priority'] = priority_for_header(issue)
|
||
|
redmine_headers 'Project' => issue.project.identifier,
|
||
|
'Issue-Tracker' => issue.tracker.name,
|
||
|
'Issue-Id' => issue.id,
|
||
| ... | ... | |
|
# Builds a mail for notifying user about an issue update
|
||
|
def issue_edit(user, journal)
|
||
|
issue = journal.journalized
|
||
|
headers['Priority'] = priority_for_header(issue)
|
||
|
redmine_headers 'Project' => issue.project.identifier,
|
||
|
'Issue-Tracker' => issue.tracker.name,
|
||
|
'Issue-Id' => issue.id,
|
||
| ... | ... | |
|
h.each {|k, v| headers["X-Redmine-#{k}"] = v.to_s}
|
||
|
end
|
||
|
def priority_for_header(issue)
|
||
|
# IssuePriority#low? and IssuePriority#high? are not used for
|
||
|
# performance reasons
|
||
|
position_name = issue.priority.position_name.to_s
|
||
|
if position_name == 'default'
|
||
|
'normal'
|
||
|
elsif position_name.start_with?('high')
|
||
|
'urgent'
|
||
|
elsif position_name.start_with?('low')
|
||
|
'non-urgent'
|
||
|
end
|
||
|
end
|
||
|
# Singleton class method is public
|
||
|
class << self
|
||
|
def token_for(object, user)
|
||
| test/unit/mailer_test.rb | ||
|---|---|---|
|
# List-Id should not include the display name "Redmine"
|
||
|
assert_equal '<redmine.example.net>', mail.header['List-Id'].to_s
|
||
|
assert_equal 'Bug', mail.header['X-Redmine-Issue-Tracker'].to_s
|
||
|
assert_equal 'non-urgent', mail.header['Priority'].to_s
|
||
|
end
|
||
|
def test_email_headers_should_include_sender
|
||
| ... | ... | |
|
assert_equal issue.author.login, mail.header['X-Redmine-Sender'].to_s
|
||
|
end
|
||
|
def test_email_headers_should_include_priority
|
||
|
to_test = {
|
||
|
IssuePriority.find(4) => 'non-urgent', # Low
|
||
|
IssuePriority.find(5) => 'normal', # Normal
|
||
|
IssuePriority.find(6) => 'urgent', # High
|
||
|
IssuePriority.find(7) => 'urgent', # Urgent
|
||
|
IssuePriority.find(8) => 'urgent', # Immediate
|
||
|
}
|
||
|
issue = Issue.find(1)
|
||
|
to_test.each do |priority, expected|
|
||
|
issue.update_attribute :priority_id, priority.id
|
||
|
Mailer.deliver_issue_add(issue)
|
||
|
mail = last_email
|
||
|
assert_equal expected, mail.header['Priority'].to_s
|
||
|
end
|
||
|
end
|
||
|
def test_plain_text_mail
|
||
|
Setting.plain_text_mail = 1
|
||
|
journal = Journal.find(2)
|
||