2021-06-01 12:20:20 +00:00
|
|
|
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
|
|
|
|
|
2018-05-29 15:42:14 +00:00
|
|
|
require 'test_helper'
|
|
|
|
|
|
|
|
class TicketTriggerExtendedTest < ActiveSupport::TestCase
|
|
|
|
|
|
|
|
setup do
|
|
|
|
Setting.set('ticket_trigger_recursive', true)
|
|
|
|
end
|
|
|
|
|
|
|
|
test 'recursive trigger' do
|
2019-06-28 11:38:49 +00:00
|
|
|
Trigger.create!(
|
2018-12-19 17:31:51 +00:00
|
|
|
name: '1) set prio to 3 high',
|
|
|
|
condition: {
|
|
|
|
'ticket.action' => {
|
2018-05-29 15:42:14 +00:00
|
|
|
'operator' => 'is',
|
2018-12-19 17:31:51 +00:00
|
|
|
'value' => 'create',
|
2018-05-29 15:42:14 +00:00
|
|
|
},
|
|
|
|
'ticket.state_id' => {
|
|
|
|
'operator' => 'is',
|
2018-12-19 17:31:51 +00:00
|
|
|
'value' => Ticket::State.lookup(name: 'new').id.to_s,
|
2018-05-29 15:42:14 +00:00
|
|
|
},
|
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
perform: {
|
2018-05-29 15:42:14 +00:00
|
|
|
'ticket.priority_id' => {
|
|
|
|
'value' => Ticket::Priority.lookup(name: '3 high').id.to_s,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
disable_notification: true,
|
2018-12-19 17:31:51 +00:00
|
|
|
active: true,
|
|
|
|
created_by_id: 1,
|
|
|
|
updated_by_id: 1,
|
2018-05-29 15:42:14 +00:00
|
|
|
)
|
|
|
|
|
2019-06-28 11:38:49 +00:00
|
|
|
Trigger.create!(
|
2018-12-19 17:31:51 +00:00
|
|
|
name: '2) set state to closed',
|
|
|
|
condition: {
|
|
|
|
'ticket.action' => {
|
2018-05-29 15:42:14 +00:00
|
|
|
'operator' => 'is',
|
2018-12-19 17:31:51 +00:00
|
|
|
'value' => 'create',
|
2018-05-29 15:42:14 +00:00
|
|
|
},
|
|
|
|
'ticket.priority_id' => {
|
|
|
|
'operator' => 'is',
|
2018-12-19 17:31:51 +00:00
|
|
|
'value' => Ticket::Priority.lookup(name: '3 high').id.to_s,
|
2018-05-29 15:42:14 +00:00
|
|
|
},
|
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
perform: {
|
2018-05-29 15:42:14 +00:00
|
|
|
'ticket.state_id' => {
|
|
|
|
'value' => Ticket::State.lookup(name: 'closed').id.to_s,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
disable_notification: true,
|
2018-12-19 17:31:51 +00:00
|
|
|
active: true,
|
|
|
|
created_by_id: 1,
|
|
|
|
updated_by_id: 1,
|
2018-05-29 15:42:14 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
email_raw_string = 'From: me@example.com
|
|
|
|
To: customer@example.com
|
|
|
|
Subject: some new subject
|
|
|
|
|
|
|
|
Some Text'
|
|
|
|
|
2019-06-28 11:38:49 +00:00
|
|
|
ticket_p, _article_p, _user_p, _mail = Channel::EmailParser.new.process({}, email_raw_string)
|
2018-05-29 15:42:14 +00:00
|
|
|
assert_equal('some new subject', ticket_p.title)
|
|
|
|
assert_equal('Users', ticket_p.group.name)
|
|
|
|
assert_equal('3 high', ticket_p.priority.name)
|
|
|
|
assert_equal('closed', ticket_p.state.name)
|
|
|
|
|
|
|
|
assert_equal(1, ticket_p.articles.count, 'ticket1.articles verify')
|
|
|
|
end
|
|
|
|
|
|
|
|
test 'recursive trigger - loop test' do
|
2019-06-28 11:38:49 +00:00
|
|
|
Trigger.create!(
|
2018-12-19 17:31:51 +00:00
|
|
|
name: '1) set prio to 3 high',
|
|
|
|
condition: {
|
2018-05-29 15:42:14 +00:00
|
|
|
'ticket.priority_id' => {
|
|
|
|
'operator' => 'is',
|
2018-12-19 17:31:51 +00:00
|
|
|
'value' => Ticket::Priority.lookup(name: '2 normal').id.to_s,
|
2018-05-29 15:42:14 +00:00
|
|
|
},
|
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
perform: {
|
2018-05-29 15:42:14 +00:00
|
|
|
'ticket.priority_id' => {
|
|
|
|
'value' => Ticket::Priority.lookup(name: '3 high').id.to_s,
|
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
'ticket.state_id' => {
|
2018-05-29 15:42:14 +00:00
|
|
|
'value' => Ticket::State.lookup(name: 'closed').id.to_s,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
disable_notification: true,
|
2018-12-19 17:31:51 +00:00
|
|
|
active: true,
|
|
|
|
created_by_id: 1,
|
|
|
|
updated_by_id: 1,
|
2018-05-29 15:42:14 +00:00
|
|
|
)
|
|
|
|
|
2019-06-28 11:38:49 +00:00
|
|
|
Trigger.create!(
|
2018-12-19 17:31:51 +00:00
|
|
|
name: '2) set prio to 1 low',
|
|
|
|
condition: {
|
2018-05-29 15:42:14 +00:00
|
|
|
'ticket.priority_id' => {
|
|
|
|
'operator' => 'is',
|
2018-12-19 17:31:51 +00:00
|
|
|
'value' => Ticket::Priority.lookup(name: '3 high').id.to_s,
|
2018-05-29 15:42:14 +00:00
|
|
|
},
|
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
perform: {
|
2018-05-29 15:42:14 +00:00
|
|
|
'ticket.priority_id' => {
|
|
|
|
'value' => Ticket::Priority.lookup(name: '1 low').id.to_s,
|
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
'ticket.state_id' => {
|
2018-05-29 15:42:14 +00:00
|
|
|
'value' => Ticket::State.lookup(name: 'open').id.to_s,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
disable_notification: true,
|
2018-12-19 17:31:51 +00:00
|
|
|
active: true,
|
|
|
|
created_by_id: 1,
|
|
|
|
updated_by_id: 1,
|
2018-05-29 15:42:14 +00:00
|
|
|
)
|
|
|
|
|
2019-06-28 11:38:49 +00:00
|
|
|
Trigger.create!(
|
2018-12-19 17:31:51 +00:00
|
|
|
name: '3) set prio to 3 high',
|
|
|
|
condition: {
|
2018-05-29 15:42:14 +00:00
|
|
|
'ticket.priority_id' => {
|
|
|
|
'operator' => 'is',
|
2018-12-19 17:31:51 +00:00
|
|
|
'value' => Ticket::Priority.lookup(name: '1 low').id.to_s,
|
2018-05-29 15:42:14 +00:00
|
|
|
},
|
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
perform: {
|
2018-05-29 15:42:14 +00:00
|
|
|
'ticket.priority_id' => {
|
|
|
|
'value' => Ticket::Priority.lookup(name: '2 normal').id.to_s,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
disable_notification: true,
|
2018-12-19 17:31:51 +00:00
|
|
|
active: true,
|
|
|
|
created_by_id: 1,
|
|
|
|
updated_by_id: 1,
|
2018-05-29 15:42:14 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
email_raw_string = 'From: me@example.com
|
|
|
|
To: customer@example.com
|
|
|
|
Subject: some new subject
|
|
|
|
|
|
|
|
Some Text'
|
|
|
|
|
2019-06-28 11:38:49 +00:00
|
|
|
ticket_p, _article_p, _user_p, _mail = Channel::EmailParser.new.process({}, email_raw_string)
|
2018-05-29 15:42:14 +00:00
|
|
|
assert_equal('some new subject', ticket_p.title)
|
|
|
|
assert_equal('Users', ticket_p.group.name)
|
|
|
|
assert_equal('2 normal', ticket_p.priority.name)
|
|
|
|
assert_equal('open', ticket_p.state.name)
|
|
|
|
|
|
|
|
assert_equal(1, ticket_p.articles.count, 'ticket1.articles verify')
|
|
|
|
end
|
|
|
|
|
|
|
|
test 'recursive trigger - 2 trigger will not trigger next trigger' do
|
2019-06-28 11:38:49 +00:00
|
|
|
Trigger.create!(
|
2018-12-19 17:31:51 +00:00
|
|
|
name: '1) set prio to 3 high',
|
|
|
|
condition: {
|
|
|
|
'ticket.action' => {
|
2018-05-29 15:42:14 +00:00
|
|
|
'operator' => 'is',
|
2018-12-19 17:31:51 +00:00
|
|
|
'value' => 'create',
|
2018-05-29 15:42:14 +00:00
|
|
|
},
|
|
|
|
'ticket.priority_id' => {
|
|
|
|
'operator' => 'is',
|
2018-12-19 17:31:51 +00:00
|
|
|
'value' => Ticket::Priority.lookup(name: '2 normal').id.to_s,
|
2018-05-29 15:42:14 +00:00
|
|
|
},
|
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
perform: {
|
2018-05-29 15:42:14 +00:00
|
|
|
'ticket.priority_id' => {
|
|
|
|
'value' => Ticket::Priority.lookup(name: '3 high').id.to_s,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
disable_notification: true,
|
2018-12-19 17:31:51 +00:00
|
|
|
active: true,
|
|
|
|
created_by_id: 1,
|
|
|
|
updated_by_id: 1,
|
2018-05-29 15:42:14 +00:00
|
|
|
)
|
|
|
|
|
2019-06-28 11:38:49 +00:00
|
|
|
Trigger.create!(
|
2018-12-19 17:31:51 +00:00
|
|
|
name: '2) set state to open',
|
|
|
|
condition: {
|
|
|
|
'ticket.action' => {
|
2018-05-29 15:42:14 +00:00
|
|
|
'operator' => 'is',
|
2018-12-19 17:31:51 +00:00
|
|
|
'value' => 'create',
|
2018-05-29 15:42:14 +00:00
|
|
|
},
|
|
|
|
'ticket.priority_id' => {
|
|
|
|
'operator' => 'is',
|
2018-12-19 17:31:51 +00:00
|
|
|
'value' => Ticket::Priority.lookup(name: '2 normal').id.to_s,
|
2018-05-29 15:42:14 +00:00
|
|
|
},
|
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
perform: {
|
2018-05-29 15:42:14 +00:00
|
|
|
'ticket.state_id' => {
|
|
|
|
'value' => Ticket::State.lookup(name: 'open').id.to_s,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
disable_notification: true,
|
2018-12-19 17:31:51 +00:00
|
|
|
active: true,
|
|
|
|
created_by_id: 1,
|
|
|
|
updated_by_id: 1,
|
2018-05-29 15:42:14 +00:00
|
|
|
)
|
|
|
|
|
2019-06-28 11:38:49 +00:00
|
|
|
Trigger.create!(
|
2018-12-19 17:31:51 +00:00
|
|
|
name: '3) set state to closed',
|
|
|
|
condition: {
|
|
|
|
'ticket.action' => {
|
2018-05-29 15:42:14 +00:00
|
|
|
'operator' => 'is',
|
2018-12-19 17:31:51 +00:00
|
|
|
'value' => 'create',
|
2018-05-29 15:42:14 +00:00
|
|
|
},
|
|
|
|
'ticket.priority_id' => {
|
|
|
|
'operator' => 'is',
|
2018-12-19 17:31:51 +00:00
|
|
|
'value' => Ticket::Priority.lookup(name: '2 normal').id.to_s,
|
2018-05-29 15:42:14 +00:00
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
'ticket.state_id' => {
|
2018-05-29 15:42:14 +00:00
|
|
|
'operator' => 'is',
|
2018-12-19 17:31:51 +00:00
|
|
|
'value' => Ticket::State.lookup(name: 'open').id.to_s,
|
2018-05-29 15:42:14 +00:00
|
|
|
},
|
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
perform: {
|
2018-05-29 15:42:14 +00:00
|
|
|
'ticket.state_id' => {
|
|
|
|
'value' => Ticket::State.lookup(name: 'closed').id.to_s,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
disable_notification: true,
|
2018-12-19 17:31:51 +00:00
|
|
|
active: true,
|
|
|
|
created_by_id: 1,
|
|
|
|
updated_by_id: 1,
|
2018-05-29 15:42:14 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
email_raw_string = 'From: me@example.com
|
|
|
|
To: customer@example.com
|
|
|
|
Subject: some new subject
|
|
|
|
|
|
|
|
Some Text'
|
|
|
|
|
2019-06-28 11:38:49 +00:00
|
|
|
ticket_p, _article_p, _user_p, _mail = Channel::EmailParser.new.process({}, email_raw_string)
|
2018-05-29 15:42:14 +00:00
|
|
|
assert_equal('some new subject', ticket_p.title)
|
|
|
|
assert_equal('Users', ticket_p.group.name)
|
|
|
|
assert_equal('3 high', ticket_p.priority.name)
|
|
|
|
assert_equal('new', ticket_p.state.name)
|
|
|
|
|
|
|
|
assert_equal(1, ticket_p.articles.count, 'ticket1.articles verify')
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
test 'recursive trigger - 2 trigger will trigger next trigger - case 1' do
|
2019-06-28 11:38:49 +00:00
|
|
|
Trigger.create!(
|
2018-12-19 17:31:51 +00:00
|
|
|
name: '1) set state to closed',
|
|
|
|
condition: {
|
|
|
|
'ticket.action' => {
|
2018-05-29 15:42:14 +00:00
|
|
|
'operator' => 'is',
|
2018-12-19 17:31:51 +00:00
|
|
|
'value' => 'create',
|
2018-05-29 15:42:14 +00:00
|
|
|
},
|
|
|
|
'ticket.priority_id' => {
|
|
|
|
'operator' => 'is',
|
2018-12-19 17:31:51 +00:00
|
|
|
'value' => Ticket::Priority.lookup(name: '3 high').id.to_s,
|
2018-05-29 15:42:14 +00:00
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
'ticket.state_id' => {
|
2018-05-29 15:42:14 +00:00
|
|
|
'operator' => 'is',
|
2018-12-19 17:31:51 +00:00
|
|
|
'value' => Ticket::State.lookup(name: 'open').id.to_s,
|
2018-05-29 15:42:14 +00:00
|
|
|
},
|
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
perform: {
|
2018-05-29 15:42:14 +00:00
|
|
|
'ticket.state_id' => {
|
|
|
|
'value' => Ticket::State.lookup(name: 'closed').id.to_s,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
disable_notification: true,
|
2018-12-19 17:31:51 +00:00
|
|
|
active: true,
|
|
|
|
created_by_id: 1,
|
|
|
|
updated_by_id: 1,
|
2018-05-29 15:42:14 +00:00
|
|
|
)
|
|
|
|
|
2019-06-28 11:38:49 +00:00
|
|
|
Trigger.create!(
|
2018-12-19 17:31:51 +00:00
|
|
|
name: '2) set prio to 3 high',
|
|
|
|
condition: {
|
|
|
|
'ticket.action' => {
|
2018-05-29 15:42:14 +00:00
|
|
|
'operator' => 'is',
|
2018-12-19 17:31:51 +00:00
|
|
|
'value' => 'create',
|
2018-05-29 15:42:14 +00:00
|
|
|
},
|
|
|
|
'ticket.priority_id' => {
|
|
|
|
'operator' => 'is',
|
2018-12-19 17:31:51 +00:00
|
|
|
'value' => Ticket::Priority.lookup(name: '2 normal').id.to_s,
|
2018-05-29 15:42:14 +00:00
|
|
|
},
|
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
perform: {
|
2018-05-29 15:42:14 +00:00
|
|
|
'ticket.priority_id' => {
|
|
|
|
'value' => Ticket::Priority.lookup(name: '3 high').id.to_s,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
disable_notification: true,
|
2018-12-19 17:31:51 +00:00
|
|
|
active: true,
|
|
|
|
created_by_id: 1,
|
|
|
|
updated_by_id: 1,
|
2018-05-29 15:42:14 +00:00
|
|
|
)
|
|
|
|
|
2019-06-28 11:38:49 +00:00
|
|
|
Trigger.create!(
|
2018-12-19 17:31:51 +00:00
|
|
|
name: '3) set state to open',
|
|
|
|
condition: {
|
2018-05-29 15:42:14 +00:00
|
|
|
'ticket.action' => {
|
|
|
|
'operator' => 'is',
|
2018-12-19 17:31:51 +00:00
|
|
|
'value' => 'create',
|
2018-05-29 15:42:14 +00:00
|
|
|
},
|
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
perform: {
|
2018-05-29 15:42:14 +00:00
|
|
|
'ticket.state_id' => {
|
|
|
|
'value' => Ticket::State.lookup(name: 'open').id.to_s,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
disable_notification: true,
|
2018-12-19 17:31:51 +00:00
|
|
|
active: true,
|
|
|
|
created_by_id: 1,
|
|
|
|
updated_by_id: 1,
|
2018-05-29 15:42:14 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
email_raw_string = 'From: me@example.com
|
|
|
|
To: customer@example.com
|
|
|
|
Subject: some new subject
|
|
|
|
|
|
|
|
Some Text'
|
|
|
|
|
2019-06-28 11:38:49 +00:00
|
|
|
ticket_p, _article_p, _user_p, _mail = Channel::EmailParser.new.process({}, email_raw_string)
|
2018-05-29 15:42:14 +00:00
|
|
|
|
|
|
|
assert_equal('some new subject', ticket_p.title)
|
|
|
|
assert_equal('Users', ticket_p.group.name)
|
|
|
|
assert_equal('3 high', ticket_p.priority.name)
|
|
|
|
assert_equal('closed', ticket_p.state.name)
|
|
|
|
assert_equal(1, ticket_p.articles.count, 'ticket1.articles verify')
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
test 'recursive trigger - 2 trigger will trigger next trigger - case 2' do
|
2019-06-28 11:38:49 +00:00
|
|
|
Trigger.create!(
|
2018-12-19 17:31:51 +00:00
|
|
|
name: '1) set prio to 3 high',
|
|
|
|
condition: {
|
|
|
|
'ticket.action' => {
|
2018-05-29 15:42:14 +00:00
|
|
|
'operator' => 'is',
|
2018-12-19 17:31:51 +00:00
|
|
|
'value' => 'create',
|
2018-05-29 15:42:14 +00:00
|
|
|
},
|
|
|
|
'ticket.priority_id' => {
|
|
|
|
'operator' => 'is',
|
2018-12-19 17:31:51 +00:00
|
|
|
'value' => Ticket::Priority.lookup(name: '2 normal').id.to_s,
|
2018-05-29 15:42:14 +00:00
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
'ticket.state_id' => {
|
2018-05-29 15:42:14 +00:00
|
|
|
'operator' => 'is',
|
2018-12-19 17:31:51 +00:00
|
|
|
'value' => Ticket::State.lookup(name: 'closed').id.to_s,
|
2018-05-29 15:42:14 +00:00
|
|
|
},
|
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
perform: {
|
2018-05-29 15:42:14 +00:00
|
|
|
'ticket.priority_id' => {
|
|
|
|
'value' => Ticket::Priority.lookup(name: '3 high').id.to_s,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
disable_notification: true,
|
2018-12-19 17:31:51 +00:00
|
|
|
active: true,
|
|
|
|
created_by_id: 1,
|
|
|
|
updated_by_id: 1,
|
2018-05-29 15:42:14 +00:00
|
|
|
)
|
|
|
|
|
2019-06-28 11:38:49 +00:00
|
|
|
Trigger.create!(
|
2018-12-19 17:31:51 +00:00
|
|
|
name: '2) set state to closed',
|
|
|
|
condition: {
|
|
|
|
'ticket.action' => {
|
2018-05-29 15:42:14 +00:00
|
|
|
'operator' => 'is',
|
2018-12-19 17:31:51 +00:00
|
|
|
'value' => 'create',
|
2018-05-29 15:42:14 +00:00
|
|
|
},
|
|
|
|
'ticket.priority_id' => {
|
|
|
|
'operator' => 'is',
|
2018-12-19 17:31:51 +00:00
|
|
|
'value' => Ticket::Priority.lookup(name: '2 normal').id.to_s,
|
2018-05-29 15:42:14 +00:00
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
'ticket.state_id' => {
|
2018-05-29 15:42:14 +00:00
|
|
|
'operator' => 'is',
|
2018-12-19 17:31:51 +00:00
|
|
|
'value' => Ticket::State.lookup(name: 'open').id.to_s,
|
2018-05-29 15:42:14 +00:00
|
|
|
},
|
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
perform: {
|
2018-05-29 15:42:14 +00:00
|
|
|
'ticket.state_id' => {
|
|
|
|
'value' => Ticket::State.lookup(name: 'closed').id.to_s,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
disable_notification: true,
|
2018-12-19 17:31:51 +00:00
|
|
|
active: true,
|
|
|
|
created_by_id: 1,
|
|
|
|
updated_by_id: 1,
|
2018-05-29 15:42:14 +00:00
|
|
|
)
|
|
|
|
|
2019-06-28 11:38:49 +00:00
|
|
|
Trigger.create!(
|
2018-12-19 17:31:51 +00:00
|
|
|
name: '3) set state to open',
|
|
|
|
condition: {
|
2018-05-29 15:42:14 +00:00
|
|
|
'ticket.action' => {
|
|
|
|
'operator' => 'is',
|
2018-12-19 17:31:51 +00:00
|
|
|
'value' => 'create',
|
2018-05-29 15:42:14 +00:00
|
|
|
},
|
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
perform: {
|
2018-05-29 15:42:14 +00:00
|
|
|
'ticket.state_id' => {
|
|
|
|
'value' => Ticket::State.lookup(name: 'open').id.to_s,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
disable_notification: true,
|
2018-12-19 17:31:51 +00:00
|
|
|
active: true,
|
|
|
|
created_by_id: 1,
|
|
|
|
updated_by_id: 1,
|
2018-05-29 15:42:14 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
email_raw_string = 'From: me@example.com
|
|
|
|
To: customer@example.com
|
|
|
|
Subject: some new subject
|
|
|
|
|
|
|
|
Some Text'
|
|
|
|
|
2019-06-28 11:38:49 +00:00
|
|
|
ticket_p, _article_p, _user_p, _mail = Channel::EmailParser.new.process({}, email_raw_string)
|
2018-05-29 15:42:14 +00:00
|
|
|
|
|
|
|
assert_equal('some new subject', ticket_p.title)
|
|
|
|
assert_equal('Users', ticket_p.group.name)
|
|
|
|
assert_equal('3 high', ticket_p.priority.name)
|
|
|
|
assert_equal('closed', ticket_p.state.name)
|
|
|
|
|
|
|
|
assert_equal(1, ticket_p.articles.count, 'ticket1.articles verify')
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
test 'trigger based move and verify correct agent notifications' do
|
|
|
|
|
|
|
|
group1 = Group.create!(
|
2018-12-19 17:31:51 +00:00
|
|
|
name: 'Group 1',
|
|
|
|
active: true,
|
2018-05-29 15:42:14 +00:00
|
|
|
email_address: EmailAddress.first,
|
|
|
|
created_by_id: 1,
|
|
|
|
updated_by_id: 1,
|
|
|
|
)
|
|
|
|
group2 = Group.create!(
|
2018-12-19 17:31:51 +00:00
|
|
|
name: 'Group 2',
|
|
|
|
active: true,
|
2018-05-29 15:42:14 +00:00
|
|
|
email_address: EmailAddress.first,
|
|
|
|
created_by_id: 1,
|
|
|
|
updated_by_id: 1,
|
|
|
|
)
|
|
|
|
group3 = Group.create!(
|
2018-12-19 17:31:51 +00:00
|
|
|
name: 'Group 3',
|
|
|
|
active: true,
|
2018-05-29 15:42:14 +00:00
|
|
|
email_address: EmailAddress.first,
|
|
|
|
created_by_id: 1,
|
|
|
|
updated_by_id: 1,
|
|
|
|
)
|
|
|
|
roles = Role.where(name: 'Agent')
|
|
|
|
user1 = User.create!(
|
2018-12-19 17:31:51 +00:00
|
|
|
login: 'trigger1@example.org',
|
|
|
|
firstname: 'trigger1',
|
|
|
|
lastname: 'trigger1',
|
|
|
|
email: 'trigger1@example.org',
|
|
|
|
password: 'some_pass',
|
|
|
|
active: true,
|
|
|
|
groups: [group1],
|
|
|
|
roles: roles,
|
2018-05-29 15:42:14 +00:00
|
|
|
created_by_id: 1,
|
|
|
|
updated_by_id: 1,
|
|
|
|
)
|
|
|
|
user2 = User.create!(
|
2018-12-19 17:31:51 +00:00
|
|
|
login: 'trigger2@example.org',
|
|
|
|
firstname: 'trigger2',
|
|
|
|
lastname: 'trigger2',
|
|
|
|
email: 'trigger2@example.org',
|
|
|
|
password: 'some_pass',
|
|
|
|
active: true,
|
|
|
|
groups: [group2],
|
|
|
|
roles: roles,
|
2018-05-29 15:42:14 +00:00
|
|
|
created_by_id: 1,
|
|
|
|
updated_by_id: 1,
|
|
|
|
)
|
|
|
|
|
|
|
|
# trigger, move ticket created in group1 into group3 and then into group2
|
2019-06-28 11:38:49 +00:00
|
|
|
Trigger.create_or_update(
|
2018-12-19 17:31:51 +00:00
|
|
|
name: '1 dispatch',
|
|
|
|
condition: {
|
|
|
|
'ticket.action' => {
|
2018-05-29 15:42:14 +00:00
|
|
|
'operator' => 'is',
|
2018-12-19 17:31:51 +00:00
|
|
|
'value' => 'create',
|
2018-05-29 15:42:14 +00:00
|
|
|
},
|
|
|
|
'ticket.group_id' => {
|
|
|
|
'operator' => 'is',
|
2018-12-19 17:31:51 +00:00
|
|
|
'value' => group3.id.to_s,
|
2018-05-29 15:42:14 +00:00
|
|
|
},
|
|
|
|
'ticket.state_id' => {
|
|
|
|
'operator' => 'is',
|
2018-12-19 17:31:51 +00:00
|
|
|
'value' => Ticket::State.lookup(name: 'new').id.to_s,
|
2018-05-29 15:42:14 +00:00
|
|
|
},
|
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
perform: {
|
2018-05-29 15:42:14 +00:00
|
|
|
'ticket.group_id' => {
|
|
|
|
'value' => group2.id.to_s,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
disable_notification: true,
|
2018-12-19 17:31:51 +00:00
|
|
|
active: true,
|
|
|
|
created_by_id: 1,
|
|
|
|
updated_by_id: 1,
|
2018-05-29 15:42:14 +00:00
|
|
|
)
|
2019-06-28 11:38:49 +00:00
|
|
|
Trigger.create_or_update(
|
2018-12-19 17:31:51 +00:00
|
|
|
name: '2 dispatch',
|
|
|
|
condition: {
|
|
|
|
'ticket.action' => {
|
2018-05-29 15:42:14 +00:00
|
|
|
'operator' => 'is',
|
2018-12-19 17:31:51 +00:00
|
|
|
'value' => 'create',
|
2018-05-29 15:42:14 +00:00
|
|
|
},
|
|
|
|
'ticket.state_id' => {
|
|
|
|
'operator' => 'is',
|
2018-12-19 17:31:51 +00:00
|
|
|
'value' => Ticket::State.lookup(name: 'new').id.to_s,
|
2018-05-29 15:42:14 +00:00
|
|
|
},
|
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
perform: {
|
2018-05-29 15:42:14 +00:00
|
|
|
'ticket.group_id' => {
|
|
|
|
'value' => group3.id.to_s,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
disable_notification: true,
|
2018-12-19 17:31:51 +00:00
|
|
|
active: true,
|
|
|
|
created_by_id: 1,
|
|
|
|
updated_by_id: 1,
|
2018-05-29 15:42:14 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
ticket1 = Ticket.create!(
|
2018-12-19 17:31:51 +00:00
|
|
|
title: '123',
|
|
|
|
group: group1,
|
|
|
|
customer_id: 2,
|
|
|
|
state: Ticket::State.lookup(name: 'new'),
|
|
|
|
priority: Ticket::Priority.lookup(name: '2 normal'),
|
2018-05-29 15:42:14 +00:00
|
|
|
updated_by_id: 1,
|
|
|
|
created_by_id: 1,
|
|
|
|
)
|
|
|
|
assert(ticket1)
|
|
|
|
|
|
|
|
assert_equal(ticket1.title, '123')
|
|
|
|
assert_equal(ticket1.group.name, group1.name)
|
|
|
|
assert_equal(ticket1.state.name, 'new')
|
|
|
|
|
2019-06-28 11:38:49 +00:00
|
|
|
Ticket::Article.create!(
|
2018-12-19 17:31:51 +00:00
|
|
|
ticket_id: ticket1.id,
|
|
|
|
from: 'some_sender@example.com',
|
|
|
|
to: 'some_recipient@example.com',
|
|
|
|
subject: 'some subject',
|
|
|
|
message_id: 'some@id',
|
|
|
|
body: 'some message',
|
|
|
|
internal: false,
|
|
|
|
sender: Ticket::Article::Sender.find_by(name: 'Customer'),
|
|
|
|
type: Ticket::Article::Type.find_by(name: 'email'),
|
2018-05-29 15:42:14 +00:00
|
|
|
updated_by_id: 1,
|
|
|
|
created_by_id: 1,
|
|
|
|
)
|
|
|
|
|
|
|
|
# verfiy if agent1 got no notifcation
|
|
|
|
assert_equal(0, NotificationFactory::Mailer.already_sent?(ticket1, user1, 'email'), ticket1.id)
|
|
|
|
|
|
|
|
# verfiy if agent2 got no notifcation
|
|
|
|
assert_equal(0, NotificationFactory::Mailer.already_sent?(ticket1, user2, 'email'), ticket1.id)
|
|
|
|
|
2021-05-20 06:59:02 +00:00
|
|
|
TransactionDispatcher.commit
|
2018-05-29 15:42:14 +00:00
|
|
|
Scheduler.worker(true)
|
|
|
|
|
|
|
|
ticket1.reload
|
|
|
|
assert_equal('123', ticket1.title)
|
|
|
|
assert_equal(group2.name, ticket1.group.name)
|
|
|
|
assert_equal('new', ticket1.state.name)
|
|
|
|
assert_equal('2 normal', ticket1.priority.name)
|
|
|
|
assert_equal(1, ticket1.articles.count)
|
|
|
|
|
|
|
|
# verfiy if agent1 got no notifcation
|
|
|
|
assert_equal(0, NotificationFactory::Mailer.already_sent?(ticket1, user1, 'email'), ticket1.id)
|
|
|
|
|
|
|
|
# verfiy if agent2 got notifcation
|
|
|
|
assert_equal(1, NotificationFactory::Mailer.already_sent?(ticket1, user2, 'email'), ticket1.id)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
test 'recursive trigger loop check' do
|
|
|
|
Setting.set('ticket_trigger_recursive_max_loop', 2)
|
2019-06-28 11:38:49 +00:00
|
|
|
Trigger.create!(
|
2018-12-19 17:31:51 +00:00
|
|
|
name: '000',
|
|
|
|
condition: {
|
|
|
|
'ticket.action' => {
|
2018-05-29 15:42:14 +00:00
|
|
|
'operator' => 'is',
|
2018-12-19 17:31:51 +00:00
|
|
|
'value' => 'create',
|
2018-05-29 15:42:14 +00:00
|
|
|
},
|
|
|
|
'ticket.priority_id' => {
|
|
|
|
'operator' => 'is',
|
2018-12-19 17:31:51 +00:00
|
|
|
'value' => Ticket::Priority.lookup(name: '1 low').id.to_s,
|
2018-05-29 15:42:14 +00:00
|
|
|
},
|
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
perform: {
|
2018-05-29 15:42:14 +00:00
|
|
|
'ticket.state_id' => {
|
|
|
|
'value' => Ticket::State.lookup(name: 'closed').id.to_s,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
disable_notification: true,
|
2018-12-19 17:31:51 +00:00
|
|
|
active: true,
|
|
|
|
created_by_id: 1,
|
|
|
|
updated_by_id: 1,
|
2018-05-29 15:42:14 +00:00
|
|
|
)
|
2019-06-28 11:38:49 +00:00
|
|
|
Trigger.create!(
|
2018-12-19 17:31:51 +00:00
|
|
|
name: '001',
|
|
|
|
condition: {
|
|
|
|
'ticket.action' => {
|
2018-05-29 15:42:14 +00:00
|
|
|
'operator' => 'is',
|
2018-12-19 17:31:51 +00:00
|
|
|
'value' => 'create',
|
2018-05-29 15:42:14 +00:00
|
|
|
},
|
|
|
|
'ticket.priority_id' => {
|
|
|
|
'operator' => 'is',
|
2018-12-19 17:31:51 +00:00
|
|
|
'value' => Ticket::Priority.lookup(name: '3 high').id.to_s,
|
2018-05-29 15:42:14 +00:00
|
|
|
},
|
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
perform: {
|
2018-05-29 15:42:14 +00:00
|
|
|
'ticket.priority_id' => {
|
|
|
|
'value' => Ticket::Priority.lookup(name: '1 low').id.to_s,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
disable_notification: true,
|
2018-12-19 17:31:51 +00:00
|
|
|
active: true,
|
|
|
|
created_by_id: 1,
|
|
|
|
updated_by_id: 1,
|
2018-05-29 15:42:14 +00:00
|
|
|
)
|
2019-06-28 11:38:49 +00:00
|
|
|
Trigger.create!(
|
2018-12-19 17:31:51 +00:00
|
|
|
name: '002',
|
|
|
|
condition: {
|
|
|
|
'ticket.action' => {
|
2018-05-29 15:42:14 +00:00
|
|
|
'operator' => 'is',
|
2018-12-19 17:31:51 +00:00
|
|
|
'value' => 'create',
|
2018-05-29 15:42:14 +00:00
|
|
|
},
|
|
|
|
'ticket.priority_id' => {
|
|
|
|
'operator' => 'is',
|
2018-12-19 17:31:51 +00:00
|
|
|
'value' => Ticket::Priority.lookup(name: '2 normal').id.to_s,
|
2018-05-29 15:42:14 +00:00
|
|
|
},
|
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
perform: {
|
2018-05-29 15:42:14 +00:00
|
|
|
'ticket.priority_id' => {
|
|
|
|
'value' => Ticket::Priority.lookup(name: '3 high').id.to_s,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
disable_notification: true,
|
2018-12-19 17:31:51 +00:00
|
|
|
active: true,
|
|
|
|
created_by_id: 1,
|
|
|
|
updated_by_id: 1,
|
2018-05-29 15:42:14 +00:00
|
|
|
)
|
|
|
|
group1 = Group.find_by(name: 'Users')
|
|
|
|
ticket1 = Ticket.create!(
|
2018-12-19 17:31:51 +00:00
|
|
|
title: '123',
|
|
|
|
group: group1,
|
|
|
|
customer_id: 2,
|
|
|
|
state: Ticket::State.lookup(name: 'new'),
|
|
|
|
priority: Ticket::Priority.lookup(name: '2 normal'),
|
2018-05-29 15:42:14 +00:00
|
|
|
updated_by_id: 1,
|
|
|
|
created_by_id: 1,
|
|
|
|
)
|
|
|
|
assert(ticket1)
|
|
|
|
|
|
|
|
assert_equal(ticket1.title, '123')
|
|
|
|
assert_equal(ticket1.group.name, group1.name)
|
|
|
|
assert_equal(ticket1.state.name, 'new')
|
|
|
|
|
2019-06-28 11:38:49 +00:00
|
|
|
Ticket::Article.create!(
|
2018-12-19 17:31:51 +00:00
|
|
|
ticket_id: ticket1.id,
|
|
|
|
from: 'some_sender@example.com',
|
|
|
|
to: 'some_recipient@example.com',
|
|
|
|
subject: 'some subject',
|
|
|
|
message_id: 'some@id',
|
|
|
|
body: 'some message',
|
|
|
|
internal: false,
|
|
|
|
sender: Ticket::Article::Sender.find_by(name: 'Customer'),
|
|
|
|
type: Ticket::Article::Type.find_by(name: 'email'),
|
2018-05-29 15:42:14 +00:00
|
|
|
updated_by_id: 1,
|
|
|
|
created_by_id: 1,
|
|
|
|
)
|
|
|
|
|
2021-05-20 06:59:02 +00:00
|
|
|
TransactionDispatcher.commit
|
2018-05-29 15:42:14 +00:00
|
|
|
Scheduler.worker(true)
|
|
|
|
|
|
|
|
ticket1.reload
|
|
|
|
assert_equal('123', ticket1.title)
|
|
|
|
assert_equal('new', ticket1.state.name)
|
|
|
|
assert_equal('1 low', ticket1.priority.name)
|
|
|
|
assert_equal(1, ticket1.articles.count)
|
|
|
|
|
|
|
|
Setting.set('ticket_trigger_recursive_max_loop', 3)
|
|
|
|
|
|
|
|
ticket1 = Ticket.create!(
|
2018-12-19 17:31:51 +00:00
|
|
|
title: '123',
|
|
|
|
group: group1,
|
|
|
|
customer_id: 2,
|
|
|
|
state: Ticket::State.lookup(name: 'new'),
|
|
|
|
priority: Ticket::Priority.lookup(name: '2 normal'),
|
2018-05-29 15:42:14 +00:00
|
|
|
updated_by_id: 1,
|
|
|
|
created_by_id: 1,
|
|
|
|
)
|
|
|
|
assert(ticket1)
|
|
|
|
|
|
|
|
assert_equal(ticket1.title, '123')
|
|
|
|
assert_equal(ticket1.group.name, group1.name)
|
|
|
|
assert_equal(ticket1.state.name, 'new')
|
|
|
|
|
2019-06-28 11:38:49 +00:00
|
|
|
Ticket::Article.create!(
|
2018-12-19 17:31:51 +00:00
|
|
|
ticket_id: ticket1.id,
|
|
|
|
from: 'some_sender@example.com',
|
|
|
|
to: 'some_recipient@example.com',
|
|
|
|
subject: 'some subject',
|
|
|
|
message_id: 'some@id',
|
|
|
|
body: 'some message',
|
|
|
|
internal: false,
|
|
|
|
sender: Ticket::Article::Sender.find_by(name: 'Customer'),
|
|
|
|
type: Ticket::Article::Type.find_by(name: 'email'),
|
2018-05-29 15:42:14 +00:00
|
|
|
updated_by_id: 1,
|
|
|
|
created_by_id: 1,
|
|
|
|
)
|
|
|
|
|
2021-05-20 06:59:02 +00:00
|
|
|
TransactionDispatcher.commit
|
2018-05-29 15:42:14 +00:00
|
|
|
Scheduler.worker(true)
|
|
|
|
|
|
|
|
ticket1.reload
|
|
|
|
assert_equal('123', ticket1.title)
|
|
|
|
assert_equal('closed', ticket1.state.name)
|
|
|
|
assert_equal('1 low', ticket1.priority.name)
|
|
|
|
assert_equal(1, ticket1.articles.count)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2018-07-13 17:50:10 +00:00
|
|
|
test 'recursive trigger with auto responder' do
|
|
|
|
|
|
|
|
group1 = Group.create!(
|
2018-12-19 17:31:51 +00:00
|
|
|
name: 'Group dispatch',
|
|
|
|
active: true,
|
2018-07-13 17:50:10 +00:00
|
|
|
created_by_id: 1,
|
|
|
|
updated_by_id: 1,
|
|
|
|
)
|
|
|
|
group2 = Group.create!(
|
2018-12-19 17:31:51 +00:00
|
|
|
name: 'Group with auto responder',
|
|
|
|
active: true,
|
2018-07-13 17:50:10 +00:00
|
|
|
email_address: EmailAddress.first,
|
|
|
|
created_by_id: 1,
|
|
|
|
updated_by_id: 1,
|
|
|
|
)
|
|
|
|
|
2019-06-28 11:38:49 +00:00
|
|
|
Trigger.create!(
|
2018-12-19 17:31:51 +00:00
|
|
|
name: "002 - move ticket to #{group2.name}",
|
|
|
|
condition: {
|
|
|
|
'ticket.action' => {
|
2018-07-13 17:50:10 +00:00
|
|
|
'operator' => 'is',
|
2018-12-19 17:31:51 +00:00
|
|
|
'value' => 'create',
|
2018-07-13 17:50:10 +00:00
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
'ticket.group_id' => {
|
2018-07-13 17:50:10 +00:00
|
|
|
'operator' => 'is',
|
2018-12-19 17:31:51 +00:00
|
|
|
'value' => group1.id.to_s,
|
2018-07-13 17:50:10 +00:00
|
|
|
},
|
|
|
|
'ticket.organization_id' => {
|
2018-12-19 17:31:51 +00:00
|
|
|
'operator' => 'is',
|
2018-07-13 17:50:10 +00:00
|
|
|
'pre_condition' => 'specific',
|
2018-12-19 17:31:51 +00:00
|
|
|
'value' => User.lookup(email: 'nicole.braun@zammad.org').organization_id.to_s,
|
2018-07-13 17:50:10 +00:00
|
|
|
}
|
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
perform: {
|
2018-07-13 17:50:10 +00:00
|
|
|
'ticket.group_id' => {
|
|
|
|
'value' => group2.id.to_s,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
disable_notification: true,
|
2018-12-19 17:31:51 +00:00
|
|
|
active: true,
|
|
|
|
created_by_id: 1,
|
|
|
|
updated_by_id: 1,
|
2018-07-13 17:50:10 +00:00
|
|
|
)
|
|
|
|
|
2019-06-28 11:38:49 +00:00
|
|
|
Trigger.create_or_update(
|
2018-12-19 17:31:51 +00:00
|
|
|
name: "001 auto reply for tickets in group #{group1.name}",
|
|
|
|
condition: {
|
|
|
|
'ticket.action' => {
|
2018-07-13 17:50:10 +00:00
|
|
|
'operator' => 'is',
|
2018-12-19 17:31:51 +00:00
|
|
|
'value' => 'create',
|
2018-07-13 17:50:10 +00:00
|
|
|
},
|
|
|
|
'ticket.state_id' => {
|
|
|
|
'operator' => 'is',
|
2018-12-19 17:31:51 +00:00
|
|
|
'value' => Ticket::State.lookup(name: 'new').id.to_s,
|
2018-07-13 17:50:10 +00:00
|
|
|
},
|
|
|
|
'ticket.group_id' => {
|
|
|
|
'operator' => 'is not',
|
2018-12-19 17:31:51 +00:00
|
|
|
'value' => group1.id.to_s,
|
2018-07-13 17:50:10 +00:00
|
|
|
},
|
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
perform: {
|
2018-07-13 17:50:10 +00:00
|
|
|
'notification.email' => {
|
2018-12-19 17:31:51 +00:00
|
|
|
'body' => "some text<br>\#{ticket.customer.lastname}<br>\#{ticket.title}<br>\#{article.body}",
|
2018-07-13 17:50:10 +00:00
|
|
|
'recipient' => 'ticket_customer',
|
2018-12-19 17:31:51 +00:00
|
|
|
'subject' => "Thanks for your inquiry (\#{ticket.title})!",
|
2018-07-13 17:50:10 +00:00
|
|
|
},
|
|
|
|
'ticket.priority_id' => {
|
|
|
|
'value' => Ticket::Priority.lookup(name: '3 high').id.to_s,
|
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
'ticket.tags' => {
|
2018-07-13 17:50:10 +00:00
|
|
|
'operator' => 'add',
|
2018-12-19 17:31:51 +00:00
|
|
|
'value' => 'aa, kk',
|
2018-07-13 17:50:10 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
disable_notification: true,
|
2018-12-19 17:31:51 +00:00
|
|
|
active: true,
|
|
|
|
created_by_id: 1,
|
|
|
|
updated_by_id: 1,
|
2018-07-13 17:50:10 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
ticket1 = Ticket.create!(
|
2018-12-19 17:31:51 +00:00
|
|
|
title: "some <b>title</b>\n äöüß",
|
|
|
|
group: group1,
|
|
|
|
customer: User.lookup(email: 'nicole.braun@zammad.org'),
|
2018-07-13 17:50:10 +00:00
|
|
|
updated_by_id: 1,
|
|
|
|
created_by_id: 1,
|
|
|
|
)
|
|
|
|
Ticket::Article.create!(
|
2018-12-19 17:31:51 +00:00
|
|
|
ticket_id: ticket1.id,
|
|
|
|
from: 'some_sender@example.com',
|
|
|
|
to: 'some_recipient@example.com',
|
|
|
|
subject: 'some subject',
|
|
|
|
message_id: 'some@id',
|
|
|
|
body: "some message <b>note</b>\nnew line",
|
|
|
|
internal: false,
|
|
|
|
sender: Ticket::Article::Sender.find_by(name: 'Customer'),
|
|
|
|
type: Ticket::Article::Type.find_by(name: 'web'),
|
2018-07-13 17:50:10 +00:00
|
|
|
updated_by_id: 1,
|
|
|
|
created_by_id: 1,
|
|
|
|
)
|
|
|
|
|
|
|
|
ticket1.reload
|
|
|
|
assert_equal('some <b>title</b> äöüß', ticket1.title, 'ticket1.title verify')
|
|
|
|
assert_equal('Group dispatch', ticket1.group.name, 'ticket1.group verify')
|
|
|
|
assert_equal('new', ticket1.state.name, 'ticket1.state verify')
|
|
|
|
assert_equal('2 normal', ticket1.priority.name, 'ticket1.priority verify')
|
|
|
|
assert_equal(1, ticket1.articles.count, 'ticket1.articles verify')
|
|
|
|
assert_equal([], ticket1.tag_list)
|
|
|
|
|
2021-05-20 06:59:02 +00:00
|
|
|
TransactionDispatcher.commit
|
2018-07-13 17:50:10 +00:00
|
|
|
|
|
|
|
ticket1.reload
|
|
|
|
assert_equal('some <b>title</b> äöüß', ticket1.title, 'ticket1.title verify')
|
|
|
|
assert_equal('Group with auto responder', ticket1.group.name, 'ticket1.group verify')
|
|
|
|
assert_equal('new', ticket1.state.name, 'ticket1.state verify')
|
|
|
|
assert_equal('3 high', ticket1.priority.name, 'ticket1.priority verify')
|
|
|
|
assert_equal(2, ticket1.articles.count, 'ticket1.articles verify')
|
|
|
|
assert_equal(%w[aa kk], ticket1.tag_list)
|
|
|
|
|
|
|
|
email_raw = "From: nicole.braun@zammad.org
|
|
|
|
To: zammad@example.com
|
|
|
|
Subject: test 1
|
|
|
|
X-Zammad-Ticket-Group: #{group1.name}
|
|
|
|
|
|
|
|
test 1"
|
|
|
|
|
2019-06-28 11:38:49 +00:00
|
|
|
ticket2, _article2, _user2 = Channel::EmailParser.new.process({ trusted: true }, email_raw)
|
2018-07-13 17:50:10 +00:00
|
|
|
|
|
|
|
assert_equal('test 1', ticket2.title, 'ticket2.title verify')
|
|
|
|
assert_equal('Group with auto responder', ticket2.group.name, 'ticket2.group verify')
|
|
|
|
assert_equal('new', ticket2.state.name, 'ticket2.state verify')
|
|
|
|
assert_equal('3 high', ticket2.priority.name, 'ticket2.priority verify')
|
|
|
|
assert_equal(2, ticket2.articles.count, 'ticket2.articles verify')
|
|
|
|
assert_equal(%w[aa kk], ticket2.tag_list)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2018-05-29 15:42:14 +00:00
|
|
|
end
|