Fixed issue #899 - Follow up detection is broken for Ticket::Number::Date ticket number generator.

This commit is contained in:
Martin Edenhofer 2017-03-27 14:30:26 +02:00
parent dde92a85df
commit f6c449327a
2 changed files with 37 additions and 2 deletions

View file

@ -82,12 +82,12 @@ module Ticket::Number::Date
ticket = nil
# probe format
string.scan(/#{Regexp.quote(ticket_hook)}#{Regexp.quote(ticket_hook_divider)}(#{system_id}\d{2,48})/i) {
string.scan(/#{Regexp.quote(ticket_hook)}#{Regexp.quote(ticket_hook_divider)}(\d{4,10}#{system_id}\d{2,40})/i) {
ticket = Ticket.find_by(number: $1)
break if ticket
}
if !ticket
string.scan(/#{Regexp.quote(ticket_hook)}\s{0,2}(#{system_id}\d{2,48})/i) {
string.scan(/#{Regexp.quote(ticket_hook)}\s{0,2}(\d{4,10}#{system_id}\d{2,40})/i) {
ticket = Ticket.find_by(number: $1)
break if ticket
}

View file

@ -307,6 +307,41 @@ class TicketTest < ActiveSupport::TestCase
end
test 'ticket followup number check' do
origin_backend = Setting.get('ticket_number')
Setting.set('ticket_number', 'Ticket::Number::Increment')
ticket1 = Ticket.create(
title: 'subject test 1234-1',
group: Group.lookup(name: 'Users'),
customer_id: 2,
state: Ticket::State.lookup(name: 'new'),
priority: Ticket::Priority.lookup(name: '2 normal'),
updated_by_id: 1,
created_by_id: 1,
)
assert_equal('subject test 1234-1', ticket1.title)
assert_equal("ABC subject test 1 [Ticket##{ticket1.number}]", ticket1.subject_build('ABC subject test 1'))
assert_equal(ticket1.id, Ticket::Number.check("Re: Help [Ticket##{ticket1.number}]").id)
Setting.set('ticket_number', 'Ticket::Number::Date')
ticket1 = Ticket.create(
title: 'subject test 1234-2',
group: Group.lookup(name: 'Users'),
customer_id: 2,
state: Ticket::State.lookup(name: 'new'),
priority: Ticket::Priority.lookup(name: '2 normal'),
updated_by_id: 1,
created_by_id: 1,
)
assert_equal('subject test 1234-2', ticket1.title)
assert_equal("ABC subject test 1 [Ticket##{ticket1.number}]", ticket1.subject_build('ABC subject test 1'))
assert_equal(ticket1.id, Ticket::Number.check("Re: Help [Ticket##{ticket1.number}]").id)
Setting.set('ticket_number', origin_backend)
end
test 'article attachment helper 1' do
ticket1 = Ticket.create(