Fixed issue #1369 - Ticket Hook Position between RE: and the ticket subject.
This commit is contained in:
parent
6ea12c212f
commit
c24e377b2d
2 changed files with 54 additions and 12 deletions
|
@ -22,22 +22,28 @@ returns
|
|||
ticket_hook = Setting.get('ticket_hook')
|
||||
ticket_hook_divider = Setting.get('ticket_hook_divider')
|
||||
ticket_subject_re = Setting.get('ticket_subject_re')
|
||||
if is_reply && !ticket_subject_re.empty?
|
||||
subject = "#{ticket_subject_re}: #{subject}"
|
||||
end
|
||||
|
||||
# none position
|
||||
if Setting.get('ticket_hook_position') == 'none'
|
||||
if is_reply && ticket_subject_re.present?
|
||||
subject = "#{ticket_subject_re}: #{subject}"
|
||||
end
|
||||
return subject
|
||||
end
|
||||
|
||||
# right position
|
||||
if Setting.get('ticket_hook_position') == 'right'
|
||||
return subject + " [#{ticket_hook}#{ticket_hook_divider}#{number}]"
|
||||
if is_reply && ticket_subject_re.present?
|
||||
subject = "#{ticket_subject_re}: #{subject}"
|
||||
end
|
||||
return "#{subject} [#{ticket_hook}#{ticket_hook_divider}#{number}]"
|
||||
end
|
||||
|
||||
# left position
|
||||
"[#{ticket_hook}#{ticket_hook_divider}#{number}] " + subject
|
||||
if is_reply && ticket_subject_re.present?
|
||||
return "#{ticket_subject_re}: [#{ticket_hook}#{ticket_hook_divider}#{number}] #{subject}"
|
||||
end
|
||||
"[#{ticket_hook}#{ticket_hook_divider}#{number}] #{subject}"
|
||||
end
|
||||
|
||||
=begin
|
||||
|
|
|
@ -289,7 +289,7 @@ class TicketTest < ActiveSupport::TestCase
|
|||
|
||||
test 'ticket subject' do
|
||||
|
||||
ticket1 = Ticket.create(
|
||||
ticket = Ticket.create(
|
||||
title: 'subject test 1',
|
||||
group: Group.lookup(name: 'Users'),
|
||||
customer_id: 2,
|
||||
|
@ -298,12 +298,48 @@ class TicketTest < ActiveSupport::TestCase
|
|||
updated_by_id: 1,
|
||||
created_by_id: 1,
|
||||
)
|
||||
assert_equal('subject test 1', ticket1.title)
|
||||
assert_equal("ABC subject test 1 [Ticket##{ticket1.number}]", ticket1.subject_build('ABC subject test 1'))
|
||||
assert_equal("RE: ABC subject test 1 [Ticket##{ticket1.number}]", ticket1.subject_build('ABC subject test 1', true))
|
||||
assert_equal("RE: ABC subject test 1 [Ticket##{ticket1.number}]", ticket1.subject_build(' ABC subject test 1', true))
|
||||
assert_equal("RE: ABC subject test 1 [Ticket##{ticket1.number}]", ticket1.subject_build('ABC subject test 1 ', true))
|
||||
ticket1.destroy
|
||||
assert_equal('subject test 1', ticket.title)
|
||||
assert_equal("ABC subject test 1 [Ticket##{ticket.number}]", ticket.subject_build('ABC subject test 1'))
|
||||
assert_equal("RE: ABC subject test 1 [Ticket##{ticket.number}]", ticket.subject_build('ABC subject test 1', true))
|
||||
assert_equal("RE: ABC subject test 1 [Ticket##{ticket.number}]", ticket.subject_build(' ABC subject test 1', true))
|
||||
assert_equal("RE: ABC subject test 1 [Ticket##{ticket.number}]", ticket.subject_build('ABC subject test 1 ', true))
|
||||
ticket.destroy
|
||||
|
||||
Setting.set('ticket_hook_position', 'left')
|
||||
|
||||
ticket = Ticket.create(
|
||||
title: 'subject test 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 1', ticket.title)
|
||||
assert_equal("[Ticket##{ticket.number}] ABC subject test 1", ticket.subject_build('ABC subject test 1'))
|
||||
assert_equal("RE: [Ticket##{ticket.number}] ABC subject test 1", ticket.subject_build('ABC subject test 1', true))
|
||||
assert_equal("RE: [Ticket##{ticket.number}] ABC subject test 1", ticket.subject_build(' ABC subject test 1', true))
|
||||
assert_equal("RE: [Ticket##{ticket.number}] ABC subject test 1", ticket.subject_build('ABC subject test 1 ', true))
|
||||
ticket.destroy
|
||||
|
||||
Setting.set('ticket_hook_position', 'none')
|
||||
|
||||
ticket = Ticket.create(
|
||||
title: 'subject test 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 1', ticket.title)
|
||||
assert_equal('ABC subject test 1', ticket.subject_build('ABC subject test 1'))
|
||||
assert_equal('RE: ABC subject test 1', ticket.subject_build('ABC subject test 1', true))
|
||||
assert_equal('RE: ABC subject test 1', ticket.subject_build(' ABC subject test 1', true))
|
||||
assert_equal('RE: ABC subject test 1', ticket.subject_build('ABC subject test 1 ', true))
|
||||
ticket.destroy
|
||||
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue