Feature #38263 » 38263-with_test.patch
| app/models/mail_handler.rb | ||
|---|---|---|
|
# Reply will be added to the issue
|
||
|
def receive_journal_reply(journal_id)
|
||
|
journal = Journal.find_by(:id => journal_id)
|
||
|
if journal.nil?
|
||
|
logger&.info "MailHandler: ignoring reply from [#{email.from.first}] to a nonexistent journal"
|
||
|
return nil
|
||
|
end
|
||
|
if journal.journalized_type == 'Issue'
|
||
|
if journal && journal.journalized_type == 'Issue'
|
||
|
receive_issue_reply(journal.journalized_id, journal)
|
||
|
elsif m = email.subject.to_s.match(ISSUE_REPLY_SUBJECT_RE)
|
||
|
logger&.info "MailHandler: reply to a nonexistant journal, calling receive_issue_reply with issue from subject"
|
||
|
receive_issue_reply(m[1].to_i)
|
||
|
else
|
||
|
logger&.info "MailHandler: ignoring reply from [#{email.from.first}] to a journal whose journalized_type is not Issue"
|
||
|
logger&.info "MailHandler: ignoring reply to a nonexistant journal or issue"
|
||
|
return nil
|
||
|
end
|
||
|
end
|
||
| test/unit/mail_handler_test.rb | ||
|---|---|---|
|
end
|
||
|
end
|
||
|
def test_reply_to_a_nonexitent_journal_with_subject_fallback
|
||
|
journal_id = Issue.find(2).journals.last.id
|
||
|
Journal.destroy(journal_id)
|
||
|
assert_no_difference 'Issue.count' do
|
||
|
assert_difference 'Journal.count', 1 do
|
||
|
journal = submit_email('ticket_reply.eml') do |email|
|
||
|
email.sub! %r{^In-Reply-To:.*$}, "In-Reply-To: <redmine.journal-#{journal_id}.20060719210421@osiris>"
|
||
|
email.sub! %r{^Subject:.*$}, "Subject: Re: [Feature request #2] Add ingredients categories"
|
||
|
end
|
||
|
puts journal.inspect
|
||
|
assert_kind_of Journal, journal
|
||
|
assert_equal Issue.find(2), journal.journalized
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
def test_reply_to_a_message
|
||
|
m = submit_email('message_reply.eml')
|
||
|
assert m.is_a?(Message)
|
||
- « Previous
- 1
- 2
- Next »