2022-01-01 13:38:12 +00:00
|
|
|
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
|
2021-06-01 12:20:20 +00:00
|
|
|
|
2015-01-02 15:50:31 +00:00
|
|
|
require 'test_helper'
|
|
|
|
|
|
|
|
class TicketNotificationTest < ActiveSupport::TestCase
|
2021-07-09 13:05:05 +00:00
|
|
|
setup do
|
2019-02-10 11:01:38 +00:00
|
|
|
Setting.set('timezone_default', 'Europe/Berlin')
|
2016-06-20 08:55:45 +00:00
|
|
|
Trigger.create_or_update(
|
2018-12-19 17:31:51 +00:00
|
|
|
name: 'auto reply - new ticket',
|
|
|
|
condition: {
|
|
|
|
'ticket.action' => {
|
2016-06-20 08:55:45 +00:00
|
|
|
'operator' => 'is',
|
2018-12-19 17:31:51 +00:00
|
|
|
'value' => 'create',
|
2016-06-20 08:55:45 +00:00
|
|
|
},
|
|
|
|
'ticket.state_id' => {
|
|
|
|
'operator' => 'is not',
|
2018-12-19 17:31:51 +00:00
|
|
|
'value' => Ticket::State.lookup(name: 'closed').id,
|
2016-06-20 08:55:45 +00:00
|
|
|
},
|
|
|
|
'article.type_id' => {
|
|
|
|
'operator' => 'is',
|
2018-12-19 17:31:51 +00:00
|
|
|
'value' => [
|
2016-06-20 08:55:45 +00:00
|
|
|
Ticket::Article::Type.lookup(name: 'email').id,
|
|
|
|
Ticket::Article::Type.lookup(name: 'phone').id,
|
|
|
|
Ticket::Article::Type.lookup(name: 'web').id,
|
|
|
|
],
|
|
|
|
},
|
2016-05-04 09:45:05 +00:00
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
perform: {
|
2016-06-20 08:55:45 +00:00
|
|
|
'notification.email' => {
|
2017-11-23 08:09:44 +00:00
|
|
|
# rubocop:disable Lint/InterpolationCheck
|
2018-12-19 17:31:51 +00:00
|
|
|
'body' => '<p>Your request (Ticket##{ticket.number}) has been received and will be reviewed by our support staff.<p>
|
2016-05-04 09:45:05 +00:00
|
|
|
<br/>
|
|
|
|
<p>To provide additional information, please reply to this email or click on the following link:
|
|
|
|
<a href="#{config.http_type}://#{config.fqdn}/#ticket/zoom/#{ticket.id}">#{config.http_type}://#{config.fqdn}/#ticket/zoom/#{ticket.id}</a>
|
|
|
|
</p>
|
|
|
|
<br/>
|
|
|
|
<p><i><a href="http://zammad.com">Zammad</a>, your customer support system</i></p>',
|
2016-06-20 08:55:45 +00:00
|
|
|
'recipient' => 'ticket_customer',
|
2018-12-19 17:31:51 +00:00
|
|
|
'subject' => 'Thanks for your inquiry (#{ticket.title})',
|
2017-11-23 08:09:44 +00:00
|
|
|
# rubocop:enable Lint/InterpolationCheck
|
2016-06-20 08:55:45 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
disable_notification: true,
|
2018-12-19 17:31:51 +00:00
|
|
|
active: true,
|
|
|
|
created_by_id: 1,
|
|
|
|
updated_by_id: 1,
|
2016-06-20 08:55:45 +00:00
|
|
|
)
|
|
|
|
|
2017-06-14 15:25:45 +00:00
|
|
|
# create @agent1 & @agent2
|
2016-06-20 08:55:45 +00:00
|
|
|
Group.create_or_update(
|
2018-12-19 17:31:51 +00:00
|
|
|
name: 'TicketNotificationTest',
|
2016-06-20 08:55:45 +00:00
|
|
|
updated_by_id: 1,
|
|
|
|
created_by_id: 1
|
|
|
|
)
|
|
|
|
groups = Group.where(name: 'TicketNotificationTest')
|
|
|
|
roles = Role.where(name: 'Agent')
|
2017-06-14 15:25:45 +00:00
|
|
|
@agent1 = User.create_or_update(
|
2018-12-19 17:31:51 +00:00
|
|
|
login: 'ticket-notification-agent1@example.com',
|
|
|
|
firstname: 'Notification',
|
|
|
|
lastname: 'Agent1',
|
|
|
|
email: 'ticket-notification-agent1@example.com',
|
|
|
|
password: 'agentpw',
|
2017-09-05 09:49:32 +00:00
|
|
|
out_of_office: false,
|
2018-12-19 17:31:51 +00:00
|
|
|
active: true,
|
|
|
|
roles: roles,
|
|
|
|
groups: groups,
|
|
|
|
preferences: {
|
2016-06-20 08:55:45 +00:00
|
|
|
locale: 'de-de',
|
2016-05-04 09:45:05 +00:00
|
|
|
},
|
2016-06-20 08:55:45 +00:00
|
|
|
updated_by_id: 1,
|
|
|
|
created_by_id: 1,
|
|
|
|
)
|
2017-06-14 15:25:45 +00:00
|
|
|
@agent2 = User.create_or_update(
|
2018-12-19 17:31:51 +00:00
|
|
|
login: 'ticket-notification-agent2@example.com',
|
|
|
|
firstname: 'Notification',
|
|
|
|
lastname: 'Agent2',
|
|
|
|
email: 'ticket-notification-agent2@example.com',
|
|
|
|
password: 'agentpw',
|
2017-09-05 09:49:32 +00:00
|
|
|
out_of_office: false,
|
2018-12-19 17:31:51 +00:00
|
|
|
active: true,
|
|
|
|
roles: roles,
|
|
|
|
groups: groups,
|
|
|
|
preferences: {
|
2019-02-10 11:01:38 +00:00
|
|
|
locale: 'en-us',
|
|
|
|
timezone: 'America/St_Lucia',
|
2016-06-20 08:55:45 +00:00
|
|
|
},
|
|
|
|
updated_by_id: 1,
|
|
|
|
created_by_id: 1,
|
|
|
|
)
|
2017-09-05 09:49:32 +00:00
|
|
|
@agent3 = User.create_or_update(
|
2018-12-19 17:31:51 +00:00
|
|
|
login: 'ticket-notification-agent3@example.com',
|
|
|
|
firstname: 'Notification',
|
|
|
|
lastname: 'Agent3',
|
|
|
|
email: 'ticket-notification-agent3@example.com',
|
|
|
|
password: 'agentpw',
|
2017-09-05 09:49:32 +00:00
|
|
|
out_of_office: false,
|
2018-12-19 17:31:51 +00:00
|
|
|
active: true,
|
|
|
|
roles: roles,
|
|
|
|
groups: groups,
|
|
|
|
preferences: {
|
2017-09-05 09:49:32 +00:00
|
|
|
locale: 'de-de',
|
|
|
|
},
|
|
|
|
updated_by_id: 1,
|
|
|
|
created_by_id: 1,
|
|
|
|
)
|
|
|
|
@agent4 = User.create_or_update(
|
2018-12-19 17:31:51 +00:00
|
|
|
login: 'ticket-notification-agent4@example.com',
|
|
|
|
firstname: 'Notification',
|
|
|
|
lastname: 'Agent4',
|
|
|
|
email: 'ticket-notification-agent4@example.com',
|
|
|
|
password: 'agentpw',
|
2017-09-05 09:49:32 +00:00
|
|
|
out_of_office: false,
|
2018-12-19 17:31:51 +00:00
|
|
|
active: true,
|
|
|
|
roles: roles,
|
|
|
|
groups: groups,
|
|
|
|
preferences: {
|
2017-09-05 09:49:32 +00:00
|
|
|
locale: 'de-de',
|
|
|
|
},
|
|
|
|
updated_by_id: 1,
|
|
|
|
created_by_id: 1,
|
|
|
|
)
|
2016-06-20 08:55:45 +00:00
|
|
|
Group.create_if_not_exists(
|
2018-12-19 17:31:51 +00:00
|
|
|
name: 'WithoutAccess',
|
|
|
|
note: 'Test for notification check.',
|
2016-06-20 08:55:45 +00:00
|
|
|
updated_by_id: 1,
|
|
|
|
created_by_id: 1
|
|
|
|
)
|
|
|
|
|
2017-06-14 15:25:45 +00:00
|
|
|
# create @customer
|
2016-06-20 08:55:45 +00:00
|
|
|
roles = Role.where(name: 'Customer')
|
2017-06-14 15:25:45 +00:00
|
|
|
@customer = User.create_or_update(
|
2018-12-19 17:31:51 +00:00
|
|
|
login: 'ticket-notification-customer@example.com',
|
|
|
|
firstname: 'Notification',
|
|
|
|
lastname: 'Customer',
|
|
|
|
email: 'ticket-notification-customer@example.com',
|
|
|
|
password: 'agentpw',
|
|
|
|
active: true,
|
|
|
|
roles: roles,
|
|
|
|
groups: groups,
|
2016-06-20 08:55:45 +00:00
|
|
|
updated_by_id: 1,
|
|
|
|
created_by_id: 1,
|
|
|
|
)
|
|
|
|
end
|
2015-01-02 23:46:11 +00:00
|
|
|
|
2016-02-03 07:58:51 +00:00
|
|
|
test 'ticket notification - to all agents / to explicit agents' do
|
2015-01-02 15:50:31 +00:00
|
|
|
|
|
|
|
# create ticket in group
|
2016-08-20 19:29:22 +00:00
|
|
|
ApplicationHandleInfo.current = 'scheduler.postmaster'
|
2017-06-14 15:25:45 +00:00
|
|
|
ticket1 = Ticket.create!(
|
2018-12-19 17:31:51 +00:00
|
|
|
title: 'some notification test 1',
|
|
|
|
group: Group.lookup(name: 'TicketNotificationTest'),
|
|
|
|
customer: @customer,
|
|
|
|
state: Ticket::State.lookup(name: 'new'),
|
|
|
|
priority: Ticket::Priority.lookup(name: '2 normal'),
|
2017-06-14 15:25:45 +00:00
|
|
|
updated_by_id: @agent1.id,
|
|
|
|
created_by_id: @agent1.id,
|
2016-02-03 07:58:51 +00:00
|
|
|
)
|
2017-06-14 15:25:45 +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.where(name: 'Customer').first,
|
|
|
|
type: Ticket::Article::Type.where(name: 'email').first,
|
2017-06-14 15:25:45 +00:00
|
|
|
updated_by_id: @agent1.id,
|
|
|
|
created_by_id: @agent1.id,
|
2016-02-03 07:58:51 +00:00
|
|
|
)
|
|
|
|
assert(ticket1)
|
|
|
|
|
2016-04-14 07:17:13 +00:00
|
|
|
# execute object transaction
|
2021-05-20 06:59:02 +00:00
|
|
|
TransactionDispatcher.commit
|
2016-04-26 09:30:46 +00:00
|
|
|
Scheduler.worker(true)
|
2016-02-03 07:58:51 +00:00
|
|
|
|
2017-06-14 15:25:45 +00:00
|
|
|
# verify notifications to @agent1 + @agent2
|
|
|
|
assert_equal(1, NotificationFactory::Mailer.already_sent?(ticket1, @agent1, 'email'), ticket1.id)
|
|
|
|
assert_equal(1, NotificationFactory::Mailer.already_sent?(ticket1, @agent2, 'email'), ticket1.id)
|
2016-02-03 07:58:51 +00:00
|
|
|
|
|
|
|
# create ticket in group
|
2016-08-20 19:29:22 +00:00
|
|
|
ApplicationHandleInfo.current = 'application_server'
|
2017-06-14 15:25:45 +00:00
|
|
|
ticket1 = Ticket.create!(
|
2018-12-19 17:31:51 +00:00
|
|
|
title: 'some notification test 2',
|
|
|
|
group: Group.lookup(name: 'TicketNotificationTest'),
|
|
|
|
customer: @customer,
|
|
|
|
state: Ticket::State.lookup(name: 'new'),
|
|
|
|
priority: Ticket::Priority.lookup(name: '2 normal'),
|
2017-06-14 15:25:45 +00:00
|
|
|
updated_by_id: @agent1.id,
|
|
|
|
created_by_id: @agent1.id,
|
2016-02-03 07:58:51 +00:00
|
|
|
)
|
2017-06-14 15:25:45 +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.where(name: 'Customer').first,
|
|
|
|
type: Ticket::Article::Type.where(name: 'email').first,
|
2017-06-14 15:25:45 +00:00
|
|
|
updated_by_id: @agent1.id,
|
|
|
|
created_by_id: @agent1.id,
|
2016-02-03 07:58:51 +00:00
|
|
|
)
|
|
|
|
assert(ticket1)
|
|
|
|
|
2016-04-14 07:17:13 +00:00
|
|
|
# execute object transaction
|
2021-05-20 06:59:02 +00:00
|
|
|
TransactionDispatcher.commit
|
2016-04-26 09:30:46 +00:00
|
|
|
Scheduler.worker(true)
|
2016-02-03 07:58:51 +00:00
|
|
|
|
2017-06-14 15:25:45 +00:00
|
|
|
# verify notifications to @agent1 + @agent2
|
|
|
|
assert_equal(0, NotificationFactory::Mailer.already_sent?(ticket1, @agent1, 'email'), ticket1.id)
|
|
|
|
assert_equal(1, NotificationFactory::Mailer.already_sent?(ticket1, @agent2, 'email'), ticket1.id)
|
2016-02-03 07:58:51 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
test 'ticket notification - simple' do
|
|
|
|
|
|
|
|
# create ticket in group
|
2016-08-20 19:29:22 +00:00
|
|
|
ApplicationHandleInfo.current = 'application_server'
|
2017-06-14 15:25:45 +00:00
|
|
|
ticket1 = Ticket.create!(
|
2018-12-19 17:31:51 +00:00
|
|
|
title: 'some notification test 3',
|
|
|
|
group: Group.lookup(name: 'TicketNotificationTest'),
|
|
|
|
customer: @customer,
|
|
|
|
state: Ticket::State.lookup(name: 'new'),
|
|
|
|
priority: Ticket::Priority.lookup(name: '2 normal'),
|
2017-06-14 15:25:45 +00:00
|
|
|
updated_by_id: @customer.id,
|
|
|
|
created_by_id: @customer.id,
|
2015-01-02 15:50:31 +00:00
|
|
|
)
|
2017-06-14 15:25:45 +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.where(name: 'Customer').first,
|
|
|
|
type: Ticket::Article::Type.where(name: 'email').first,
|
2017-06-14 15:25:45 +00:00
|
|
|
updated_by_id: @customer.id,
|
|
|
|
created_by_id: @customer.id,
|
2015-01-02 15:50:31 +00:00
|
|
|
)
|
2016-04-27 07:31:11 +00:00
|
|
|
assert(ticket1, 'ticket created - ticket notification simple')
|
2015-01-02 15:50:31 +00:00
|
|
|
|
2016-04-14 07:17:13 +00:00
|
|
|
# execute object transaction
|
2021-05-20 06:59:02 +00:00
|
|
|
TransactionDispatcher.commit
|
2016-04-26 09:30:46 +00:00
|
|
|
Scheduler.worker(true)
|
2015-01-02 15:50:31 +00:00
|
|
|
|
2017-06-14 15:25:45 +00:00
|
|
|
# verify notifications to @agent1 + @agent2
|
|
|
|
assert_equal(1, NotificationFactory::Mailer.already_sent?(ticket1, @agent1, 'email'), ticket1.id)
|
|
|
|
assert_equal(1, NotificationFactory::Mailer.already_sent?(ticket1, @agent2, 'email'), ticket1.id)
|
2015-01-02 15:50:31 +00:00
|
|
|
|
|
|
|
# update ticket attributes
|
|
|
|
ticket1.title = "#{ticket1.title} - #2"
|
2016-02-03 07:58:51 +00:00
|
|
|
ticket1.priority = Ticket::Priority.lookup(name: '3 high')
|
2017-06-14 15:25:45 +00:00
|
|
|
ticket1.save!
|
2015-01-02 15:50:31 +00:00
|
|
|
|
2016-04-14 07:17:13 +00:00
|
|
|
# execute object transaction
|
2021-05-20 06:59:02 +00:00
|
|
|
TransactionDispatcher.commit
|
2016-04-26 09:30:46 +00:00
|
|
|
Scheduler.worker(true)
|
2015-01-02 15:50:31 +00:00
|
|
|
|
2017-06-14 15:25:45 +00:00
|
|
|
# verify notifications to @agent1 + @agent2
|
|
|
|
assert_equal(2, NotificationFactory::Mailer.already_sent?(ticket1, @agent1, 'email'), ticket1.id)
|
|
|
|
assert_equal(2, NotificationFactory::Mailer.already_sent?(ticket1, @agent2, 'email'), ticket1.id)
|
2015-01-02 15:50:31 +00:00
|
|
|
|
|
|
|
# add article to ticket
|
2017-06-14 15:25:45 +00:00
|
|
|
Ticket::Article.create!(
|
2018-12-19 17:31:51 +00:00
|
|
|
ticket_id: ticket1.id,
|
|
|
|
from: 'some person',
|
|
|
|
subject: 'some note',
|
|
|
|
body: 'some message',
|
|
|
|
internal: true,
|
|
|
|
sender: Ticket::Article::Sender.where(name: 'Agent').first,
|
|
|
|
type: Ticket::Article::Type.where(name: 'note').first,
|
2017-06-14 15:25:45 +00:00
|
|
|
updated_by_id: @agent1.id,
|
|
|
|
created_by_id: @agent1.id,
|
2015-01-02 15:50:31 +00:00
|
|
|
)
|
|
|
|
|
2016-04-14 07:17:13 +00:00
|
|
|
# execute object transaction
|
2021-05-20 06:59:02 +00:00
|
|
|
TransactionDispatcher.commit
|
2016-04-26 09:30:46 +00:00
|
|
|
Scheduler.worker(true)
|
2015-01-02 15:50:31 +00:00
|
|
|
|
2017-06-14 15:25:45 +00:00
|
|
|
# verify notifications to not to @agent1 but to @agent2
|
|
|
|
assert_equal(2, NotificationFactory::Mailer.already_sent?(ticket1, @agent1, 'email'), ticket1.id)
|
|
|
|
assert_equal(3, NotificationFactory::Mailer.already_sent?(ticket1, @agent2, 'email'), ticket1.id)
|
2015-01-02 15:50:31 +00:00
|
|
|
|
2015-01-09 19:44:04 +00:00
|
|
|
# update ticket by user
|
2017-06-14 15:25:45 +00:00
|
|
|
ticket1.owner_id = @agent1.id
|
|
|
|
ticket1.updated_by_id = @agent1.id
|
|
|
|
ticket1.save!
|
|
|
|
Ticket::Article.create!(
|
2018-12-19 17:31:51 +00:00
|
|
|
ticket_id: ticket1.id,
|
|
|
|
from: 'some person',
|
|
|
|
subject: 'some note',
|
|
|
|
body: 'some message',
|
|
|
|
internal: true,
|
|
|
|
sender: Ticket::Article::Sender.where(name: 'Agent').first,
|
|
|
|
type: Ticket::Article::Type.where(name: 'note').first,
|
2017-06-14 15:25:45 +00:00
|
|
|
updated_by_id: @agent1.id,
|
|
|
|
created_by_id: @agent1.id,
|
2015-01-09 19:44:04 +00:00
|
|
|
)
|
|
|
|
|
2016-04-14 07:17:13 +00:00
|
|
|
# execute object transaction
|
2021-05-20 06:59:02 +00:00
|
|
|
TransactionDispatcher.commit
|
2016-04-26 09:30:46 +00:00
|
|
|
Scheduler.worker(true)
|
2015-01-09 19:44:04 +00:00
|
|
|
|
2017-06-14 15:25:45 +00:00
|
|
|
# verify notifications to not to @agent1 but to @agent2
|
|
|
|
assert_equal(2, NotificationFactory::Mailer.already_sent?(ticket1, @agent1, 'email'), ticket1.id)
|
|
|
|
assert_equal(3, NotificationFactory::Mailer.already_sent?(ticket1, @agent2, 'email'), ticket1.id)
|
2015-01-02 15:50:31 +00:00
|
|
|
|
2017-06-14 15:25:45 +00:00
|
|
|
# create ticket with @agent1 as owner
|
|
|
|
ticket2 = Ticket.create!(
|
2018-12-19 17:31:51 +00:00
|
|
|
title: 'some notification test 4',
|
|
|
|
group: Group.lookup(name: 'TicketNotificationTest'),
|
|
|
|
customer_id: 2,
|
|
|
|
owner_id: @agent1.id,
|
|
|
|
state: Ticket::State.lookup(name: 'new'),
|
|
|
|
priority: Ticket::Priority.lookup(name: '2 normal'),
|
2017-06-14 15:25:45 +00:00
|
|
|
updated_by_id: @agent1.id,
|
|
|
|
created_by_id: @agent1.id,
|
2015-01-02 15:50:31 +00:00
|
|
|
)
|
2017-06-14 15:25:45 +00:00
|
|
|
Ticket::Article.create!(
|
2018-12-19 17:31:51 +00:00
|
|
|
ticket_id: ticket2.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.where(name: 'Agent').first,
|
|
|
|
type: Ticket::Article::Type.where(name: 'phone').first,
|
2017-06-14 15:25:45 +00:00
|
|
|
updated_by_id: @agent1.id,
|
|
|
|
created_by_id: @agent1.id,
|
2015-01-02 15:50:31 +00:00
|
|
|
)
|
|
|
|
|
2016-04-14 07:17:13 +00:00
|
|
|
# execute object transaction
|
2021-05-20 06:59:02 +00:00
|
|
|
TransactionDispatcher.commit
|
2016-04-26 09:30:46 +00:00
|
|
|
Scheduler.worker(true)
|
2016-02-03 07:58:51 +00:00
|
|
|
assert(ticket2, 'ticket created')
|
2015-01-02 15:50:31 +00:00
|
|
|
|
|
|
|
# verify notifications to no one
|
2017-06-14 15:25:45 +00:00
|
|
|
assert_equal(0, NotificationFactory::Mailer.already_sent?(ticket2, @agent1, 'email'), ticket2.id)
|
|
|
|
assert_equal(0, NotificationFactory::Mailer.already_sent?(ticket2, @agent2, 'email'), ticket2.id)
|
2015-01-02 15:50:31 +00:00
|
|
|
|
|
|
|
# update ticket
|
|
|
|
ticket2.title = "#{ticket2.title} - #2"
|
2017-06-14 15:25:45 +00:00
|
|
|
ticket2.updated_by_id = @agent1.id
|
2016-02-03 07:58:51 +00:00
|
|
|
ticket2.priority = Ticket::Priority.lookup(name: '3 high')
|
2017-06-14 15:25:45 +00:00
|
|
|
ticket2.save!
|
2015-01-02 15:50:31 +00:00
|
|
|
|
2016-04-14 07:17:13 +00:00
|
|
|
# execute object transaction
|
2021-05-20 06:59:02 +00:00
|
|
|
TransactionDispatcher.commit
|
2016-04-26 09:30:46 +00:00
|
|
|
Scheduler.worker(true)
|
2015-01-02 15:50:31 +00:00
|
|
|
|
2016-04-27 07:31:11 +00:00
|
|
|
# verify notifications to none
|
2017-06-14 15:25:45 +00:00
|
|
|
assert_equal(0, NotificationFactory::Mailer.already_sent?(ticket2, @agent1, 'email'), ticket2.id)
|
|
|
|
assert_equal(0, NotificationFactory::Mailer.already_sent?(ticket2, @agent2, 'email'), ticket2.id)
|
2015-01-02 15:50:31 +00:00
|
|
|
|
|
|
|
# update ticket
|
|
|
|
ticket2.title = "#{ticket2.title} - #3"
|
2017-06-14 15:25:45 +00:00
|
|
|
ticket2.updated_by_id = @agent2.id
|
2016-02-03 07:58:51 +00:00
|
|
|
ticket2.priority = Ticket::Priority.lookup(name: '2 normal')
|
2017-06-14 15:25:45 +00:00
|
|
|
ticket2.save!
|
2015-01-02 15:50:31 +00:00
|
|
|
|
2016-04-14 07:17:13 +00:00
|
|
|
# execute object transaction
|
2021-05-20 06:59:02 +00:00
|
|
|
TransactionDispatcher.commit
|
2016-04-26 09:30:46 +00:00
|
|
|
Scheduler.worker(true)
|
2015-01-02 15:50:31 +00:00
|
|
|
|
2017-06-14 15:25:45 +00:00
|
|
|
# verify notifications to @agent1 and not to @agent2
|
|
|
|
assert_equal(1, NotificationFactory::Mailer.already_sent?(ticket2, @agent1, 'email'), ticket2.id)
|
|
|
|
assert_equal(0, NotificationFactory::Mailer.already_sent?(ticket2, @agent2, 'email'), ticket2.id)
|
2015-01-02 15:50:31 +00:00
|
|
|
|
2017-06-14 15:25:45 +00:00
|
|
|
# create ticket with @agent2 and @agent1 as owner
|
|
|
|
ticket3 = Ticket.create!(
|
2018-12-19 17:31:51 +00:00
|
|
|
title: 'some notification test 5',
|
|
|
|
group: Group.lookup(name: 'TicketNotificationTest'),
|
|
|
|
customer_id: 2,
|
|
|
|
owner_id: @agent1.id,
|
|
|
|
state: Ticket::State.lookup(name: 'new'),
|
|
|
|
priority: Ticket::Priority.lookup(name: '2 normal'),
|
2017-06-14 15:25:45 +00:00
|
|
|
updated_by_id: @agent2.id,
|
|
|
|
created_by_id: @agent2.id,
|
2015-01-02 15:50:31 +00:00
|
|
|
)
|
2017-06-14 15:25:45 +00:00
|
|
|
article_inbound = Ticket::Article.create!(
|
2018-12-19 17:31:51 +00:00
|
|
|
ticket_id: ticket3.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.where(name: 'Agent').first,
|
|
|
|
type: Ticket::Article::Type.where(name: 'phone').first,
|
2017-06-14 15:25:45 +00:00
|
|
|
updated_by_id: @agent2.id,
|
|
|
|
created_by_id: @agent2.id,
|
2015-01-02 15:50:31 +00:00
|
|
|
)
|
|
|
|
|
2016-04-14 07:17:13 +00:00
|
|
|
# execute object transaction
|
2021-05-20 06:59:02 +00:00
|
|
|
TransactionDispatcher.commit
|
2016-04-26 09:30:46 +00:00
|
|
|
Scheduler.worker(true)
|
2016-02-03 07:58:51 +00:00
|
|
|
assert(ticket3, 'ticket created')
|
2015-01-02 15:50:31 +00:00
|
|
|
|
2017-06-14 15:25:45 +00:00
|
|
|
# verify notifications to @agent1 and not to @agent2
|
|
|
|
assert_equal(1, NotificationFactory::Mailer.already_sent?(ticket3, @agent1, 'email'), ticket3.id)
|
|
|
|
assert_equal(0, NotificationFactory::Mailer.already_sent?(ticket3, @agent2, 'email'), ticket3.id)
|
2015-01-02 15:50:31 +00:00
|
|
|
|
|
|
|
# update ticket
|
|
|
|
ticket3.title = "#{ticket3.title} - #2"
|
2017-06-14 15:25:45 +00:00
|
|
|
ticket3.updated_by_id = @agent1.id
|
2016-02-03 07:58:51 +00:00
|
|
|
ticket3.priority = Ticket::Priority.lookup(name: '3 high')
|
2017-06-14 15:25:45 +00:00
|
|
|
ticket3.save!
|
2015-01-02 15:50:31 +00:00
|
|
|
|
2016-04-14 07:17:13 +00:00
|
|
|
# execute object transaction
|
2021-05-20 06:59:02 +00:00
|
|
|
TransactionDispatcher.commit
|
2016-04-26 09:30:46 +00:00
|
|
|
Scheduler.worker(true)
|
2015-01-02 15:50:31 +00:00
|
|
|
|
|
|
|
# verify notifications to no one
|
2017-06-14 15:25:45 +00:00
|
|
|
assert_equal(1, NotificationFactory::Mailer.already_sent?(ticket3, @agent1, 'email'), ticket3.id)
|
|
|
|
assert_equal(0, NotificationFactory::Mailer.already_sent?(ticket3, @agent2, 'email'), ticket3.id)
|
2015-01-02 15:50:31 +00:00
|
|
|
|
|
|
|
# update ticket
|
|
|
|
ticket3.title = "#{ticket3.title} - #3"
|
2017-06-14 15:25:45 +00:00
|
|
|
ticket3.updated_by_id = @agent2.id
|
2016-02-03 07:58:51 +00:00
|
|
|
ticket3.priority = Ticket::Priority.lookup(name: '2 normal')
|
2017-06-14 15:25:45 +00:00
|
|
|
ticket3.save!
|
2015-01-02 15:50:31 +00:00
|
|
|
|
2016-04-14 07:17:13 +00:00
|
|
|
# execute object transaction
|
2021-05-20 06:59:02 +00:00
|
|
|
TransactionDispatcher.commit
|
2016-04-26 09:30:46 +00:00
|
|
|
Scheduler.worker(true)
|
2015-01-02 15:50:31 +00:00
|
|
|
|
2017-06-14 15:25:45 +00:00
|
|
|
# verify notifications to @agent1 and not to @agent2
|
|
|
|
assert_equal(2, NotificationFactory::Mailer.already_sent?(ticket3, @agent1, 'email'), ticket3.id)
|
|
|
|
assert_equal(0, NotificationFactory::Mailer.already_sent?(ticket3, @agent2, 'email'), ticket3.id)
|
2015-01-02 15:50:31 +00:00
|
|
|
|
2015-02-10 12:37:47 +00:00
|
|
|
# update article / not notification should be sent
|
|
|
|
article_inbound.internal = true
|
2017-06-14 15:25:45 +00:00
|
|
|
article_inbound.save!
|
2015-02-10 12:37:47 +00:00
|
|
|
|
2016-04-14 07:17:13 +00:00
|
|
|
# execute object transaction
|
2021-05-20 06:59:02 +00:00
|
|
|
TransactionDispatcher.commit
|
2016-04-26 09:30:46 +00:00
|
|
|
Scheduler.worker(true)
|
2015-02-10 12:37:47 +00:00
|
|
|
|
2017-06-14 15:25:45 +00:00
|
|
|
# verify notifications not to @agent1 and not to @agent2
|
|
|
|
assert_equal(2, NotificationFactory::Mailer.already_sent?(ticket3, @agent1, 'email'), ticket3.id)
|
|
|
|
assert_equal(0, NotificationFactory::Mailer.already_sent?(ticket3, @agent2, 'email'), ticket3.id)
|
2015-02-10 12:37:47 +00:00
|
|
|
|
2015-01-02 15:50:31 +00:00
|
|
|
delete = ticket1.destroy
|
2016-02-03 07:58:51 +00:00
|
|
|
assert(delete, 'ticket1 destroy')
|
2015-01-02 15:50:31 +00:00
|
|
|
|
|
|
|
delete = ticket2.destroy
|
2016-02-03 07:58:51 +00:00
|
|
|
assert(delete, 'ticket2 destroy')
|
2015-01-02 15:50:31 +00:00
|
|
|
|
|
|
|
delete = ticket3.destroy
|
2016-02-03 07:58:51 +00:00
|
|
|
assert(delete, 'ticket3 destroy')
|
2015-01-02 15:50:31 +00:00
|
|
|
|
|
|
|
end
|
|
|
|
|
2016-04-16 09:13:12 +00:00
|
|
|
test 'ticket notification - no notification' do
|
|
|
|
|
|
|
|
# create ticket in group
|
2017-06-14 15:25:45 +00:00
|
|
|
ticket1 = Ticket.create!(
|
2018-12-19 17:31:51 +00:00
|
|
|
title: 'some notification test 1 - no notification',
|
|
|
|
group: Group.lookup(name: 'TicketNotificationTest'),
|
|
|
|
customer: @customer,
|
|
|
|
state: Ticket::State.lookup(name: 'new'),
|
|
|
|
priority: Ticket::Priority.lookup(name: '2 normal'),
|
2017-06-14 15:25:45 +00:00
|
|
|
updated_by_id: @customer.id,
|
|
|
|
created_by_id: @customer.id,
|
2016-04-16 09:13:12 +00:00
|
|
|
)
|
2017-06-14 15:25:45 +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.where(name: 'Customer').first,
|
|
|
|
type: Ticket::Article::Type.where(name: 'email').first,
|
2017-06-14 15:25:45 +00:00
|
|
|
updated_by_id: @customer.id,
|
|
|
|
created_by_id: @customer.id,
|
2016-04-16 09:13:12 +00:00
|
|
|
)
|
2016-04-27 07:31:11 +00:00
|
|
|
assert(ticket1, 'ticket created - ticket no notification')
|
2016-04-16 09:13:12 +00:00
|
|
|
|
|
|
|
# execute object transaction
|
2021-05-20 06:59:02 +00:00
|
|
|
TransactionDispatcher.commit(disable_notification: true)
|
2016-04-26 09:30:46 +00:00
|
|
|
Scheduler.worker(true)
|
2016-04-16 09:13:12 +00:00
|
|
|
|
2017-06-14 15:25:45 +00:00
|
|
|
# verify notifications to @agent1 + @agent2
|
|
|
|
assert_equal(0, NotificationFactory::Mailer.already_sent?(ticket1, @agent1, 'email'), ticket1.id)
|
|
|
|
assert_equal(0, NotificationFactory::Mailer.already_sent?(ticket1, @agent2, 'email'), ticket1.id)
|
2016-04-16 09:13:12 +00:00
|
|
|
|
|
|
|
end
|
|
|
|
|
2016-02-07 13:00:29 +00:00
|
|
|
test 'ticket notification - z preferences tests' do
|
|
|
|
|
2017-06-14 15:25:45 +00:00
|
|
|
@agent1.preferences['notification_config']['matrix']['create']['criteria']['owned_by_me'] = true
|
|
|
|
@agent1.preferences['notification_config']['matrix']['create']['criteria']['owned_by_nobody'] = false
|
|
|
|
@agent1.preferences['notification_config']['matrix']['create']['criteria']['no'] = false
|
|
|
|
@agent1.preferences['notification_config']['matrix']['update']['criteria']['owned_by_me'] = true
|
|
|
|
@agent1.preferences['notification_config']['matrix']['update']['criteria']['owned_by_nobody'] = false
|
|
|
|
@agent1.preferences['notification_config']['matrix']['update']['criteria']['no'] = false
|
|
|
|
@agent1.save!
|
|
|
|
|
|
|
|
@agent2.preferences['notification_config']['matrix']['create']['criteria']['owned_by_me'] = false
|
|
|
|
@agent2.preferences['notification_config']['matrix']['create']['criteria']['owned_by_nobody'] = false
|
|
|
|
@agent2.preferences['notification_config']['matrix']['create']['criteria']['no'] = true
|
|
|
|
@agent2.preferences['notification_config']['matrix']['update']['criteria']['owned_by_me'] = false
|
|
|
|
@agent2.preferences['notification_config']['matrix']['update']['criteria']['owned_by_nobody'] = false
|
|
|
|
@agent2.preferences['notification_config']['matrix']['update']['criteria']['no'] = true
|
|
|
|
@agent2.save!
|
2016-02-07 13:00:29 +00:00
|
|
|
|
|
|
|
# create ticket in group
|
2016-08-20 19:29:22 +00:00
|
|
|
ApplicationHandleInfo.current = 'scheduler.postmaster'
|
2017-06-14 15:25:45 +00:00
|
|
|
ticket1 = Ticket.create!(
|
2018-12-19 17:31:51 +00:00
|
|
|
title: 'some notification test - z preferences tests 1',
|
|
|
|
group: Group.lookup(name: 'TicketNotificationTest'),
|
|
|
|
customer: @customer,
|
|
|
|
state: Ticket::State.lookup(name: 'new'),
|
|
|
|
priority: Ticket::Priority.lookup(name: '2 normal'),
|
2017-06-14 15:25:45 +00:00
|
|
|
updated_by_id: @customer.id,
|
|
|
|
created_by_id: @customer.id,
|
2016-02-07 13:00:29 +00:00
|
|
|
)
|
2017-06-14 15:25:45 +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.where(name: 'Customer').first,
|
|
|
|
type: Ticket::Article::Type.where(name: 'email').first,
|
2017-06-14 15:25:45 +00:00
|
|
|
updated_by_id: @customer.id,
|
|
|
|
created_by_id: @customer.id,
|
2016-02-07 13:00:29 +00:00
|
|
|
)
|
|
|
|
|
2016-04-14 07:17:13 +00:00
|
|
|
# execute object transaction
|
2021-05-20 06:59:02 +00:00
|
|
|
TransactionDispatcher.commit
|
2016-04-26 09:30:46 +00:00
|
|
|
Scheduler.worker(true)
|
2016-02-07 13:00:29 +00:00
|
|
|
|
2017-06-14 15:25:45 +00:00
|
|
|
# verify notifications to @agent1 + @agent2
|
|
|
|
assert_equal(0, NotificationFactory::Mailer.already_sent?(ticket1, @agent1, 'email'), ticket1.id)
|
|
|
|
assert_equal(1, NotificationFactory::Mailer.already_sent?(ticket1, @agent2, 'email'), ticket1.id)
|
2016-02-07 13:00:29 +00:00
|
|
|
|
|
|
|
# update ticket attributes
|
|
|
|
ticket1.title = "#{ticket1.title} - #2"
|
|
|
|
ticket1.priority = Ticket::Priority.lookup(name: '3 high')
|
2017-06-14 15:25:45 +00:00
|
|
|
ticket1.save!
|
2016-02-07 13:00:29 +00:00
|
|
|
|
2016-04-14 07:17:13 +00:00
|
|
|
# execute object transaction
|
2021-05-20 06:59:02 +00:00
|
|
|
TransactionDispatcher.commit
|
2016-04-26 09:30:46 +00:00
|
|
|
Scheduler.worker(true)
|
2016-02-07 13:00:29 +00:00
|
|
|
|
2017-06-14 15:25:45 +00:00
|
|
|
# verify notifications to @agent1 + @agent2
|
|
|
|
assert_equal(0, NotificationFactory::Mailer.already_sent?(ticket1, @agent1, 'email'), ticket1.id)
|
|
|
|
assert_equal(2, NotificationFactory::Mailer.already_sent?(ticket1, @agent2, 'email'), ticket1.id)
|
2016-02-07 13:00:29 +00:00
|
|
|
|
|
|
|
# create ticket in group
|
2017-06-14 15:25:45 +00:00
|
|
|
ticket2 = Ticket.create!(
|
2018-12-19 17:31:51 +00:00
|
|
|
title: 'some notification test - z preferences tests 2',
|
|
|
|
group: Group.lookup(name: 'TicketNotificationTest'),
|
|
|
|
customer: @customer,
|
|
|
|
owner: @agent1,
|
|
|
|
state: Ticket::State.lookup(name: 'new'),
|
|
|
|
priority: Ticket::Priority.lookup(name: '2 normal'),
|
2017-06-14 15:25:45 +00:00
|
|
|
updated_by_id: @customer.id,
|
|
|
|
created_by_id: @customer.id,
|
2016-02-07 13:00:29 +00:00
|
|
|
)
|
2017-06-14 15:25:45 +00:00
|
|
|
Ticket::Article.create!(
|
2018-12-19 17:31:51 +00:00
|
|
|
ticket_id: ticket2.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.where(name: 'Customer').first,
|
|
|
|
type: Ticket::Article::Type.where(name: 'email').first,
|
2017-06-14 15:25:45 +00:00
|
|
|
updated_by_id: @customer.id,
|
|
|
|
created_by_id: @customer.id,
|
2016-02-07 13:00:29 +00:00
|
|
|
)
|
|
|
|
|
2016-04-14 07:17:13 +00:00
|
|
|
# execute object transaction
|
2021-05-20 06:59:02 +00:00
|
|
|
TransactionDispatcher.commit
|
2016-04-26 09:30:46 +00:00
|
|
|
Scheduler.worker(true)
|
2016-02-07 13:00:29 +00:00
|
|
|
|
2017-06-14 15:25:45 +00:00
|
|
|
# verify notifications to @agent1 + @agent2
|
|
|
|
assert_equal(1, NotificationFactory::Mailer.already_sent?(ticket2, @agent1, 'email'), ticket2.id)
|
|
|
|
assert_equal(1, NotificationFactory::Mailer.already_sent?(ticket2, @agent2, 'email'), ticket2.id)
|
2016-02-07 13:00:29 +00:00
|
|
|
|
|
|
|
# update ticket attributes
|
|
|
|
ticket2.title = "#{ticket2.title} - #2"
|
|
|
|
ticket2.priority = Ticket::Priority.lookup(name: '3 high')
|
2017-06-14 15:25:45 +00:00
|
|
|
ticket2.save!
|
2016-02-07 13:00:29 +00:00
|
|
|
|
2016-04-14 07:17:13 +00:00
|
|
|
# execute object transaction
|
2021-05-20 06:59:02 +00:00
|
|
|
TransactionDispatcher.commit
|
2016-04-26 09:30:46 +00:00
|
|
|
Scheduler.worker(true)
|
2016-02-07 13:00:29 +00:00
|
|
|
|
2017-06-14 15:25:45 +00:00
|
|
|
# verify notifications to @agent1 + @agent2
|
|
|
|
assert_equal(2, NotificationFactory::Mailer.already_sent?(ticket2, @agent1, 'email'), ticket2.id)
|
|
|
|
assert_equal(2, NotificationFactory::Mailer.already_sent?(ticket2, @agent2, 'email'), ticket2.id)
|
2016-02-07 13:00:29 +00:00
|
|
|
|
|
|
|
# create ticket in group
|
2017-06-14 15:25:45 +00:00
|
|
|
ticket3 = Ticket.create!(
|
2018-12-19 17:31:51 +00:00
|
|
|
title: 'some notification test - z preferences tests 3',
|
|
|
|
group: Group.lookup(name: 'TicketNotificationTest'),
|
|
|
|
customer: @customer,
|
|
|
|
owner: @agent2,
|
|
|
|
state: Ticket::State.lookup(name: 'new'),
|
|
|
|
priority: Ticket::Priority.lookup(name: '2 normal'),
|
2017-06-14 15:25:45 +00:00
|
|
|
updated_by_id: @customer.id,
|
|
|
|
created_by_id: @customer.id,
|
2016-02-07 13:00:29 +00:00
|
|
|
)
|
2017-06-14 15:25:45 +00:00
|
|
|
Ticket::Article.create!(
|
2018-12-19 17:31:51 +00:00
|
|
|
ticket_id: ticket3.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.where(name: 'Customer').first,
|
|
|
|
type: Ticket::Article::Type.where(name: 'email').first,
|
2017-06-14 15:25:45 +00:00
|
|
|
updated_by_id: @customer.id,
|
|
|
|
created_by_id: @customer.id,
|
2016-02-07 13:00:29 +00:00
|
|
|
)
|
|
|
|
|
2016-04-14 07:17:13 +00:00
|
|
|
# execute object transaction
|
2021-05-20 06:59:02 +00:00
|
|
|
TransactionDispatcher.commit
|
2016-04-26 09:30:46 +00:00
|
|
|
Scheduler.worker(true)
|
2016-02-07 13:00:29 +00:00
|
|
|
|
2017-06-14 15:25:45 +00:00
|
|
|
# verify notifications to @agent1 + @agent2
|
|
|
|
assert_equal(0, NotificationFactory::Mailer.already_sent?(ticket3, @agent1, 'email'), ticket3.id)
|
|
|
|
assert_equal(1, NotificationFactory::Mailer.already_sent?(ticket3, @agent2, 'email'), ticket3.id)
|
2016-02-07 13:00:29 +00:00
|
|
|
|
|
|
|
# update ticket attributes
|
|
|
|
ticket3.title = "#{ticket3.title} - #2"
|
|
|
|
ticket3.priority = Ticket::Priority.lookup(name: '3 high')
|
2017-06-14 15:25:45 +00:00
|
|
|
ticket3.save!
|
2016-02-07 13:00:29 +00:00
|
|
|
|
2016-04-14 07:17:13 +00:00
|
|
|
# execute object transaction
|
2021-05-20 06:59:02 +00:00
|
|
|
TransactionDispatcher.commit
|
2016-04-26 09:30:46 +00:00
|
|
|
Scheduler.worker(true)
|
2016-02-07 13:00:29 +00:00
|
|
|
|
2017-06-14 15:25:45 +00:00
|
|
|
# verify notifications to @agent1 + @agent2
|
|
|
|
assert_equal(0, NotificationFactory::Mailer.already_sent?(ticket3, @agent1, 'email'), ticket3.id)
|
|
|
|
assert_equal(2, NotificationFactory::Mailer.already_sent?(ticket3, @agent2, 'email'), ticket3.id)
|
|
|
|
|
|
|
|
@agent1.preferences['notification_config']['matrix']['create']['criteria']['owned_by_me'] = true
|
|
|
|
@agent1.preferences['notification_config']['matrix']['create']['criteria']['owned_by_nobody'] = false
|
|
|
|
@agent1.preferences['notification_config']['matrix']['create']['criteria']['no'] = true
|
|
|
|
@agent1.preferences['notification_config']['matrix']['update']['criteria']['owned_by_me'] = true
|
|
|
|
@agent1.preferences['notification_config']['matrix']['update']['criteria']['owned_by_nobody'] = false
|
|
|
|
@agent1.preferences['notification_config']['matrix']['update']['criteria']['no'] = true
|
|
|
|
@agent1.preferences['notification_config']['group_ids'] = [Group.lookup(name: 'TicketNotificationTest').id.to_s]
|
|
|
|
@agent1.save!
|
|
|
|
|
|
|
|
@agent2.preferences['notification_config']['matrix']['create']['criteria']['owned_by_me'] = false
|
|
|
|
@agent2.preferences['notification_config']['matrix']['create']['criteria']['owned_by_nobody'] = false
|
|
|
|
@agent2.preferences['notification_config']['matrix']['create']['criteria']['no'] = true
|
|
|
|
@agent2.preferences['notification_config']['matrix']['update']['criteria']['owned_by_me'] = false
|
|
|
|
@agent2.preferences['notification_config']['matrix']['update']['criteria']['owned_by_nobody'] = false
|
|
|
|
@agent2.preferences['notification_config']['matrix']['update']['criteria']['no'] = true
|
|
|
|
@agent1.preferences['notification_config']['group_ids'] = ['-']
|
|
|
|
@agent2.save!
|
2016-02-07 13:00:29 +00:00
|
|
|
|
2019-10-04 09:42:44 +00:00
|
|
|
travel 1.minute # to skip loopup cache in Transaction::Notification
|
2021-07-02 11:46:37 +00:00
|
|
|
if Rails.application.config.cache_store.first.eql? :mem_cache_store
|
|
|
|
# External memcached does not support time travel, so clear the cache to avoid an outdated match.
|
|
|
|
Cache.clear
|
|
|
|
end
|
2019-10-04 09:42:44 +00:00
|
|
|
|
2016-02-07 13:00:29 +00:00
|
|
|
# create ticket in group
|
2016-08-20 19:29:22 +00:00
|
|
|
ApplicationHandleInfo.current = 'scheduler.postmaster'
|
2017-06-14 15:25:45 +00:00
|
|
|
ticket4 = Ticket.create!(
|
2018-12-19 17:31:51 +00:00
|
|
|
title: 'some notification test - z preferences tests 4',
|
|
|
|
group: Group.lookup(name: 'TicketNotificationTest'),
|
|
|
|
customer: @customer,
|
|
|
|
state: Ticket::State.lookup(name: 'new'),
|
|
|
|
priority: Ticket::Priority.lookup(name: '2 normal'),
|
2017-06-14 15:25:45 +00:00
|
|
|
updated_by_id: @customer.id,
|
|
|
|
created_by_id: @customer.id,
|
2016-02-07 13:00:29 +00:00
|
|
|
)
|
2017-06-14 15:25:45 +00:00
|
|
|
Ticket::Article.create!(
|
2018-12-19 17:31:51 +00:00
|
|
|
ticket_id: ticket4.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.where(name: 'Customer').first,
|
|
|
|
type: Ticket::Article::Type.where(name: 'email').first,
|
2017-06-14 15:25:45 +00:00
|
|
|
updated_by_id: @customer.id,
|
|
|
|
created_by_id: @customer.id,
|
2016-02-07 13:00:29 +00:00
|
|
|
)
|
|
|
|
|
2016-04-14 07:17:13 +00:00
|
|
|
# execute object transaction
|
2021-05-20 06:59:02 +00:00
|
|
|
TransactionDispatcher.commit
|
2016-04-26 09:30:46 +00:00
|
|
|
Scheduler.worker(true)
|
2016-02-07 13:00:29 +00:00
|
|
|
|
2017-06-14 15:25:45 +00:00
|
|
|
# verify notifications to @agent1 + @agent2
|
|
|
|
assert_equal(1, NotificationFactory::Mailer.already_sent?(ticket4, @agent1, 'email'), ticket4.id)
|
|
|
|
assert_equal(1, NotificationFactory::Mailer.already_sent?(ticket4, @agent2, 'email'), ticket4.id)
|
2016-02-07 13:00:29 +00:00
|
|
|
|
|
|
|
# update ticket attributes
|
|
|
|
ticket4.title = "#{ticket4.title} - #2"
|
|
|
|
ticket4.priority = Ticket::Priority.lookup(name: '3 high')
|
2017-06-14 15:25:45 +00:00
|
|
|
ticket4.save!
|
2016-02-07 13:00:29 +00:00
|
|
|
|
2016-04-14 07:17:13 +00:00
|
|
|
# execute object transaction
|
2021-05-20 06:59:02 +00:00
|
|
|
TransactionDispatcher.commit
|
2016-04-26 09:30:46 +00:00
|
|
|
Scheduler.worker(true)
|
2016-02-07 13:00:29 +00:00
|
|
|
|
2017-06-14 15:25:45 +00:00
|
|
|
# verify notifications to @agent1 + @agent2
|
|
|
|
assert_equal(2, NotificationFactory::Mailer.already_sent?(ticket4, @agent1, 'email'), ticket4.id)
|
|
|
|
assert_equal(2, NotificationFactory::Mailer.already_sent?(ticket4, @agent2, 'email'), ticket4.id)
|
|
|
|
|
|
|
|
@agent1.preferences['notification_config']['matrix']['create']['criteria']['owned_by_me'] = true
|
|
|
|
@agent1.preferences['notification_config']['matrix']['create']['criteria']['owned_by_nobody'] = false
|
|
|
|
@agent1.preferences['notification_config']['matrix']['create']['criteria']['no'] = true
|
|
|
|
@agent1.preferences['notification_config']['matrix']['update']['criteria']['owned_by_me'] = true
|
|
|
|
@agent1.preferences['notification_config']['matrix']['update']['criteria']['owned_by_nobody'] = false
|
|
|
|
@agent1.preferences['notification_config']['matrix']['update']['criteria']['no'] = true
|
|
|
|
@agent1.preferences['notification_config']['group_ids'] = [Group.lookup(name: 'TicketNotificationTest').id.to_s]
|
|
|
|
@agent1.save!
|
|
|
|
|
|
|
|
@agent2.preferences['notification_config']['matrix']['create']['criteria']['owned_by_me'] = false
|
|
|
|
@agent2.preferences['notification_config']['matrix']['create']['criteria']['owned_by_nobody'] = false
|
|
|
|
@agent2.preferences['notification_config']['matrix']['create']['criteria']['no'] = true
|
|
|
|
@agent2.preferences['notification_config']['matrix']['update']['criteria']['owned_by_me'] = false
|
|
|
|
@agent2.preferences['notification_config']['matrix']['update']['criteria']['owned_by_nobody'] = false
|
|
|
|
@agent2.preferences['notification_config']['matrix']['update']['criteria']['no'] = true
|
|
|
|
@agent2.preferences['notification_config']['group_ids'] = [99]
|
|
|
|
@agent2.save!
|
2016-02-07 13:00:29 +00:00
|
|
|
|
2019-10-04 09:42:44 +00:00
|
|
|
travel 1.minute # to skip loopup cache in Transaction::Notification
|
2021-07-02 11:46:37 +00:00
|
|
|
if Rails.application.config.cache_store.first.eql? :mem_cache_store
|
|
|
|
# External memcached does not support time travel, so clear the cache to avoid an outdated match.
|
|
|
|
Cache.clear
|
|
|
|
end
|
2019-10-04 09:42:44 +00:00
|
|
|
|
2016-02-07 13:00:29 +00:00
|
|
|
# create ticket in group
|
2016-08-20 19:29:22 +00:00
|
|
|
ApplicationHandleInfo.current = 'scheduler.postmaster'
|
2017-06-14 15:25:45 +00:00
|
|
|
ticket5 = Ticket.create!(
|
2018-12-19 17:31:51 +00:00
|
|
|
title: 'some notification test - z preferences tests 5',
|
|
|
|
group: Group.lookup(name: 'TicketNotificationTest'),
|
|
|
|
customer: @customer,
|
|
|
|
state: Ticket::State.lookup(name: 'new'),
|
|
|
|
priority: Ticket::Priority.lookup(name: '2 normal'),
|
2017-06-14 15:25:45 +00:00
|
|
|
updated_by_id: @customer.id,
|
|
|
|
created_by_id: @customer.id,
|
2016-02-07 13:00:29 +00:00
|
|
|
)
|
2017-06-14 15:25:45 +00:00
|
|
|
Ticket::Article.create!(
|
2018-12-19 17:31:51 +00:00
|
|
|
ticket_id: ticket5.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.where(name: 'Customer').first,
|
|
|
|
type: Ticket::Article::Type.where(name: 'email').first,
|
2017-06-14 15:25:45 +00:00
|
|
|
updated_by_id: @customer.id,
|
|
|
|
created_by_id: @customer.id,
|
2016-02-07 13:00:29 +00:00
|
|
|
)
|
|
|
|
|
2016-04-14 07:17:13 +00:00
|
|
|
# execute object transaction
|
2021-05-20 06:59:02 +00:00
|
|
|
TransactionDispatcher.commit
|
2016-04-26 09:30:46 +00:00
|
|
|
Scheduler.worker(true)
|
2016-02-07 13:00:29 +00:00
|
|
|
|
2017-06-14 15:25:45 +00:00
|
|
|
# verify notifications to @agent1 + @agent2
|
|
|
|
assert_equal(1, NotificationFactory::Mailer.already_sent?(ticket5, @agent1, 'email'), ticket5.id)
|
|
|
|
assert_equal(0, NotificationFactory::Mailer.already_sent?(ticket5, @agent2, 'email'), ticket5.id)
|
2016-02-07 13:00:29 +00:00
|
|
|
|
|
|
|
# update ticket attributes
|
|
|
|
ticket5.title = "#{ticket5.title} - #2"
|
|
|
|
ticket5.priority = Ticket::Priority.lookup(name: '3 high')
|
2017-06-14 15:25:45 +00:00
|
|
|
ticket5.save!
|
2016-02-07 13:00:29 +00:00
|
|
|
|
2016-04-14 07:17:13 +00:00
|
|
|
# execute object transaction
|
2021-05-20 06:59:02 +00:00
|
|
|
TransactionDispatcher.commit
|
2016-04-26 09:30:46 +00:00
|
|
|
Scheduler.worker(true)
|
2016-02-07 13:00:29 +00:00
|
|
|
|
2017-06-14 15:25:45 +00:00
|
|
|
# verify notifications to @agent1 + @agent2
|
|
|
|
assert_equal(2, NotificationFactory::Mailer.already_sent?(ticket5, @agent1, 'email'), ticket5.id)
|
|
|
|
assert_equal(0, NotificationFactory::Mailer.already_sent?(ticket5, @agent2, 'email'), ticket5.id)
|
|
|
|
|
|
|
|
@agent1.preferences['notification_config']['matrix']['create']['criteria']['owned_by_me'] = true
|
|
|
|
@agent1.preferences['notification_config']['matrix']['create']['criteria']['owned_by_nobody'] = false
|
|
|
|
@agent1.preferences['notification_config']['matrix']['create']['criteria']['no'] = true
|
|
|
|
@agent1.preferences['notification_config']['matrix']['update']['criteria']['owned_by_me'] = true
|
|
|
|
@agent1.preferences['notification_config']['matrix']['update']['criteria']['owned_by_nobody'] = false
|
|
|
|
@agent1.preferences['notification_config']['matrix']['update']['criteria']['no'] = true
|
|
|
|
@agent1.preferences['notification_config']['group_ids'] = [999]
|
|
|
|
@agent1.save!
|
|
|
|
|
|
|
|
@agent2.preferences['notification_config']['matrix']['create']['criteria']['owned_by_me'] = true
|
|
|
|
@agent2.preferences['notification_config']['matrix']['create']['criteria']['owned_by_nobody'] = false
|
|
|
|
@agent2.preferences['notification_config']['matrix']['create']['criteria']['no'] = true
|
|
|
|
@agent2.preferences['notification_config']['matrix']['update']['criteria']['owned_by_me'] = true
|
|
|
|
@agent2.preferences['notification_config']['matrix']['update']['criteria']['owned_by_nobody'] = false
|
|
|
|
@agent2.preferences['notification_config']['matrix']['update']['criteria']['no'] = true
|
|
|
|
@agent2.preferences['notification_config']['group_ids'] = [999]
|
|
|
|
@agent2.save!
|
2016-02-07 13:00:29 +00:00
|
|
|
|
2019-10-04 09:42:44 +00:00
|
|
|
travel 1.minute # to skip loopup cache in Transaction::Notification
|
2021-07-02 11:46:37 +00:00
|
|
|
if Rails.application.config.cache_store.first.eql? :mem_cache_store
|
|
|
|
# External memcached does not support time travel, so clear the cache to avoid an outdated match.
|
|
|
|
Cache.clear
|
|
|
|
end
|
2019-10-04 09:42:44 +00:00
|
|
|
|
2016-02-07 13:00:29 +00:00
|
|
|
# create ticket in group
|
2016-08-20 19:29:22 +00:00
|
|
|
ApplicationHandleInfo.current = 'scheduler.postmaster'
|
2017-06-14 15:25:45 +00:00
|
|
|
ticket6 = Ticket.create!(
|
2018-12-19 17:31:51 +00:00
|
|
|
title: 'some notification test - z preferences tests 6',
|
|
|
|
group: Group.lookup(name: 'TicketNotificationTest'),
|
|
|
|
customer: @customer,
|
|
|
|
owner: @agent1,
|
|
|
|
state: Ticket::State.lookup(name: 'new'),
|
|
|
|
priority: Ticket::Priority.lookup(name: '2 normal'),
|
2017-06-14 15:25:45 +00:00
|
|
|
updated_by_id: @customer.id,
|
|
|
|
created_by_id: @customer.id,
|
2016-02-07 13:00:29 +00:00
|
|
|
)
|
2017-06-14 15:25:45 +00:00
|
|
|
Ticket::Article.create!(
|
2018-12-19 17:31:51 +00:00
|
|
|
ticket_id: ticket6.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.where(name: 'Customer').first,
|
|
|
|
type: Ticket::Article::Type.where(name: 'email').first,
|
2017-06-14 15:25:45 +00:00
|
|
|
updated_by_id: @customer.id,
|
|
|
|
created_by_id: @customer.id,
|
2016-02-07 13:00:29 +00:00
|
|
|
)
|
|
|
|
|
2016-04-14 07:17:13 +00:00
|
|
|
# execute object transaction
|
2021-05-20 06:59:02 +00:00
|
|
|
TransactionDispatcher.commit
|
2016-04-26 09:30:46 +00:00
|
|
|
Scheduler.worker(true)
|
2016-02-07 13:00:29 +00:00
|
|
|
|
2017-06-14 15:25:45 +00:00
|
|
|
# verify notifications to @agent1 + @agent2
|
|
|
|
assert_equal(1, NotificationFactory::Mailer.already_sent?(ticket6, @agent1, 'email'), ticket6.id)
|
|
|
|
assert_equal(1, NotificationFactory::Mailer.already_sent?(ticket6, @agent1, 'online'), ticket6.id)
|
|
|
|
assert_equal(0, NotificationFactory::Mailer.already_sent?(ticket6, @agent2, 'email'), ticket6.id)
|
|
|
|
assert_equal(0, NotificationFactory::Mailer.already_sent?(ticket6, @agent2, 'online'), ticket6.id)
|
2016-02-07 13:00:29 +00:00
|
|
|
|
|
|
|
# update ticket attributes
|
|
|
|
ticket6.title = "#{ticket6.title} - #2"
|
|
|
|
ticket6.priority = Ticket::Priority.lookup(name: '3 high')
|
2017-06-14 15:25:45 +00:00
|
|
|
ticket6.save!
|
2016-02-07 13:00:29 +00:00
|
|
|
|
2016-04-14 07:17:13 +00:00
|
|
|
# execute object transaction
|
2021-05-20 06:59:02 +00:00
|
|
|
TransactionDispatcher.commit
|
2016-04-26 09:30:46 +00:00
|
|
|
Scheduler.worker(true)
|
2016-02-07 13:00:29 +00:00
|
|
|
|
2017-06-14 15:25:45 +00:00
|
|
|
# verify notifications to @agent1 + @agent2
|
|
|
|
assert_equal(2, NotificationFactory::Mailer.already_sent?(ticket6, @agent1, 'email'), ticket6.id)
|
|
|
|
assert_equal(2, NotificationFactory::Mailer.already_sent?(ticket6, @agent1, 'online'), ticket6.id)
|
|
|
|
assert_equal(0, NotificationFactory::Mailer.already_sent?(ticket6, @agent2, 'email'), ticket6.id)
|
|
|
|
assert_equal(0, NotificationFactory::Mailer.already_sent?(ticket6, @agent2, 'online'), ticket6.id)
|
|
|
|
|
|
|
|
@agent1.preferences['notification_config']['matrix']['create']['criteria']['owned_by_me'] = true
|
|
|
|
@agent1.preferences['notification_config']['matrix']['create']['criteria']['owned_by_nobody'] = false
|
|
|
|
@agent1.preferences['notification_config']['matrix']['create']['criteria']['no'] = true
|
|
|
|
@agent1.preferences['notification_config']['matrix']['create']['channel']['email'] = false
|
|
|
|
@agent1.preferences['notification_config']['matrix']['create']['channel']['online'] = true
|
|
|
|
@agent1.preferences['notification_config']['matrix']['update']['criteria']['owned_by_me'] = true
|
|
|
|
@agent1.preferences['notification_config']['matrix']['update']['criteria']['owned_by_nobody'] = false
|
|
|
|
@agent1.preferences['notification_config']['matrix']['update']['criteria']['no'] = true
|
|
|
|
@agent1.preferences['notification_config']['matrix']['update']['channel']['email'] = false
|
|
|
|
@agent1.preferences['notification_config']['matrix']['update']['channel']['online'] = true
|
|
|
|
@agent1.preferences['notification_config']['group_ids'] = [999]
|
|
|
|
@agent1.save!
|
|
|
|
|
|
|
|
@agent2.preferences['notification_config']['matrix']['create']['criteria']['owned_by_me'] = true
|
|
|
|
@agent2.preferences['notification_config']['matrix']['create']['criteria']['owned_by_nobody'] = false
|
|
|
|
@agent2.preferences['notification_config']['matrix']['create']['criteria']['no'] = true
|
|
|
|
@agent2.preferences['notification_config']['matrix']['create']['channel']['email'] = false
|
|
|
|
@agent2.preferences['notification_config']['matrix']['create']['channel']['online'] = true
|
|
|
|
@agent2.preferences['notification_config']['matrix']['update']['criteria']['owned_by_me'] = true
|
|
|
|
@agent2.preferences['notification_config']['matrix']['update']['criteria']['owned_by_nobody'] = false
|
|
|
|
@agent2.preferences['notification_config']['matrix']['update']['criteria']['no'] = true
|
|
|
|
@agent2.preferences['notification_config']['matrix']['update']['channel']['email'] = false
|
|
|
|
@agent2.preferences['notification_config']['matrix']['update']['channel']['online'] = true
|
|
|
|
@agent2.preferences['notification_config']['group_ids'] = [999]
|
|
|
|
@agent2.save!
|
2016-02-08 11:01:32 +00:00
|
|
|
|
2019-10-04 09:42:44 +00:00
|
|
|
travel 1.minute # to skip loopup cache in Transaction::Notification
|
2021-07-02 11:46:37 +00:00
|
|
|
if Rails.application.config.cache_store.first.eql? :mem_cache_store
|
|
|
|
# External memcached does not support time travel, so clear the cache to avoid an outdated match.
|
|
|
|
Cache.clear
|
|
|
|
end
|
2019-10-04 09:42:44 +00:00
|
|
|
|
2016-02-08 11:01:32 +00:00
|
|
|
# create ticket in group
|
2016-08-20 19:29:22 +00:00
|
|
|
ApplicationHandleInfo.current = 'scheduler.postmaster'
|
2017-06-14 15:25:45 +00:00
|
|
|
ticket7 = Ticket.create!(
|
2018-12-19 17:31:51 +00:00
|
|
|
title: 'some notification test - z preferences tests 7',
|
|
|
|
group: Group.lookup(name: 'TicketNotificationTest'),
|
|
|
|
customer: @customer,
|
|
|
|
owner: @agent1,
|
|
|
|
state: Ticket::State.lookup(name: 'new'),
|
|
|
|
priority: Ticket::Priority.lookup(name: '2 normal'),
|
2017-06-14 15:25:45 +00:00
|
|
|
updated_by_id: @customer.id,
|
|
|
|
created_by_id: @customer.id,
|
2016-02-08 11:01:32 +00:00
|
|
|
)
|
2017-06-14 15:25:45 +00:00
|
|
|
Ticket::Article.create!(
|
2018-12-19 17:31:51 +00:00
|
|
|
ticket_id: ticket7.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.where(name: 'Customer').first,
|
|
|
|
type: Ticket::Article::Type.where(name: 'email').first,
|
2017-06-14 15:25:45 +00:00
|
|
|
updated_by_id: @customer.id,
|
|
|
|
created_by_id: @customer.id,
|
2016-02-08 11:01:32 +00:00
|
|
|
)
|
|
|
|
|
2016-04-14 07:17:13 +00:00
|
|
|
# execute object transaction
|
2021-05-20 06:59:02 +00:00
|
|
|
TransactionDispatcher.commit
|
2016-04-26 09:30:46 +00:00
|
|
|
Scheduler.worker(true)
|
2016-02-08 11:01:32 +00:00
|
|
|
|
2017-06-14 15:25:45 +00:00
|
|
|
# verify notifications to @agent1 + @agent2
|
|
|
|
assert_equal(0, NotificationFactory::Mailer.already_sent?(ticket7, @agent1, 'email'), ticket7.id)
|
|
|
|
assert_equal(1, NotificationFactory::Mailer.already_sent?(ticket7, @agent1, 'online'), ticket7.id)
|
|
|
|
assert_equal(0, NotificationFactory::Mailer.already_sent?(ticket7, @agent2, 'email'), ticket7.id)
|
|
|
|
assert_equal(0, NotificationFactory::Mailer.already_sent?(ticket7, @agent2, 'online'), ticket7.id)
|
2016-02-08 11:01:32 +00:00
|
|
|
|
|
|
|
# update ticket attributes
|
|
|
|
ticket7.title = "#{ticket7.title} - #2"
|
|
|
|
ticket7.priority = Ticket::Priority.lookup(name: '3 high')
|
2017-06-14 15:25:45 +00:00
|
|
|
ticket7.save!
|
2016-02-08 11:01:32 +00:00
|
|
|
|
2016-04-14 07:17:13 +00:00
|
|
|
# execute object transaction
|
2021-05-20 06:59:02 +00:00
|
|
|
TransactionDispatcher.commit
|
2016-04-26 09:30:46 +00:00
|
|
|
Scheduler.worker(true)
|
2016-02-08 11:01:32 +00:00
|
|
|
|
2017-06-14 15:25:45 +00:00
|
|
|
# verify notifications to @agent1 + @agent2
|
|
|
|
assert_equal(0, NotificationFactory::Mailer.already_sent?(ticket7, @agent1, 'email'), ticket7.id)
|
|
|
|
assert_equal(2, NotificationFactory::Mailer.already_sent?(ticket7, @agent1, 'online'), ticket7.id)
|
|
|
|
assert_equal(0, NotificationFactory::Mailer.already_sent?(ticket7, @agent2, 'email'), ticket7.id)
|
|
|
|
assert_equal(0, NotificationFactory::Mailer.already_sent?(ticket7, @agent2, 'online'), ticket7.id)
|
2016-02-07 13:00:29 +00:00
|
|
|
|
|
|
|
end
|
|
|
|
|
2015-01-02 23:46:11 +00:00
|
|
|
test 'ticket notification events' do
|
|
|
|
|
|
|
|
# create ticket in group
|
2017-06-14 15:25:45 +00:00
|
|
|
ticket1 = Ticket.create!(
|
2018-12-19 17:31:51 +00:00
|
|
|
title: 'some notification event test 1',
|
|
|
|
group: Group.lookup(name: 'TicketNotificationTest'),
|
|
|
|
customer: @customer,
|
|
|
|
state: Ticket::State.lookup(name: 'new'),
|
|
|
|
priority: Ticket::Priority.lookup(name: '2 normal'),
|
2017-06-14 15:25:45 +00:00
|
|
|
updated_by_id: @customer.id,
|
|
|
|
created_by_id: @customer.id,
|
2015-01-02 23:46:11 +00:00
|
|
|
)
|
2017-06-14 15:25:45 +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.where(name: 'Customer').first,
|
|
|
|
type: Ticket::Article::Type.where(name: 'email').first,
|
2017-06-14 15:25:45 +00:00
|
|
|
updated_by_id: @customer.id,
|
|
|
|
created_by_id: @customer.id,
|
2015-01-02 23:46:11 +00:00
|
|
|
)
|
2016-02-03 07:58:51 +00:00
|
|
|
assert(ticket1, 'ticket created')
|
2015-01-02 23:46:11 +00:00
|
|
|
|
2016-04-14 07:17:13 +00:00
|
|
|
# execute object transaction
|
2021-05-20 06:59:02 +00:00
|
|
|
TransactionDispatcher.commit
|
2015-01-02 23:46:11 +00:00
|
|
|
|
|
|
|
# update ticket attributes
|
|
|
|
ticket1.title = "#{ticket1.title} - #2"
|
2016-02-03 07:58:51 +00:00
|
|
|
ticket1.priority = Ticket::Priority.lookup(name: '3 high')
|
2017-06-14 15:25:45 +00:00
|
|
|
ticket1.save!
|
2015-01-02 23:46:11 +00:00
|
|
|
|
2016-04-15 21:56:10 +00:00
|
|
|
list = EventBuffer.list('transaction')
|
2021-05-20 06:59:02 +00:00
|
|
|
list_objects = TransactionDispatcher.get_uniq_changes(list)
|
2015-01-02 23:46:11 +00:00
|
|
|
|
2016-04-22 06:55:10 +00:00
|
|
|
assert_equal('some notification event test 1', list_objects['Ticket'][ticket1.id][:changes]['title'][0])
|
|
|
|
assert_equal('some notification event test 1 - #2', list_objects['Ticket'][ticket1.id][:changes]['title'][1])
|
|
|
|
assert_not(list_objects['Ticket'][ticket1.id][:changes]['priority'])
|
|
|
|
assert_equal(2, list_objects['Ticket'][ticket1.id][:changes]['priority_id'][0])
|
|
|
|
assert_equal(3, list_objects['Ticket'][ticket1.id][:changes]['priority_id'][1])
|
2015-01-02 23:46:11 +00:00
|
|
|
|
|
|
|
# update ticket attributes
|
|
|
|
ticket1.title = "#{ticket1.title} - #3"
|
2016-02-03 07:58:51 +00:00
|
|
|
ticket1.priority = Ticket::Priority.lookup(name: '1 low')
|
2017-06-14 15:25:45 +00:00
|
|
|
ticket1.save!
|
2015-01-02 23:46:11 +00:00
|
|
|
|
2016-04-15 21:56:10 +00:00
|
|
|
list = EventBuffer.list('transaction')
|
2021-05-20 06:59:02 +00:00
|
|
|
list_objects = TransactionDispatcher.get_uniq_changes(list)
|
2015-01-02 23:46:11 +00:00
|
|
|
|
2016-04-22 06:55:10 +00:00
|
|
|
assert_equal('some notification event test 1', list_objects['Ticket'][ticket1.id][:changes]['title'][0])
|
|
|
|
assert_equal('some notification event test 1 - #2 - #3', list_objects['Ticket'][ticket1.id][:changes]['title'][1])
|
|
|
|
assert_not(list_objects['Ticket'][ticket1.id][:changes]['priority'])
|
|
|
|
assert_equal(2, list_objects['Ticket'][ticket1.id][:changes]['priority_id'][0])
|
|
|
|
assert_equal(1, list_objects['Ticket'][ticket1.id][:changes]['priority_id'][1])
|
2015-01-04 12:52:14 +00:00
|
|
|
|
|
|
|
end
|
|
|
|
|
2017-09-05 09:49:32 +00:00
|
|
|
test 'ticket notification - out of office' do
|
|
|
|
|
|
|
|
# create ticket in group
|
|
|
|
ticket1 = Ticket.create!(
|
2018-12-19 17:31:51 +00:00
|
|
|
title: 'some notification test out of office',
|
|
|
|
group: Group.lookup(name: 'TicketNotificationTest'),
|
|
|
|
customer: @customer,
|
|
|
|
owner_id: @agent2.id,
|
2021-07-16 13:44:10 +00:00
|
|
|
# state: Ticket::State.lookup(name: 'new'),
|
|
|
|
# priority: Ticket::Priority.lookup(name: '2 normal'),
|
2017-09-05 09:49:32 +00:00
|
|
|
updated_by_id: @customer.id,
|
|
|
|
created_by_id: @customer.id,
|
|
|
|
)
|
|
|
|
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.where(name: 'Customer').first,
|
|
|
|
type: Ticket::Article::Type.where(name: 'email').first,
|
2017-09-05 09:49:32 +00:00
|
|
|
updated_by_id: @customer.id,
|
|
|
|
created_by_id: @customer.id,
|
|
|
|
)
|
|
|
|
assert(ticket1, 'ticket created - ticket notification simple')
|
|
|
|
|
|
|
|
# execute object transaction
|
2021-05-20 06:59:02 +00:00
|
|
|
TransactionDispatcher.commit
|
2017-09-05 09:49:32 +00:00
|
|
|
Scheduler.worker(true)
|
|
|
|
|
|
|
|
# verify notifications to @agent1 + @agent2
|
|
|
|
assert_equal(0, NotificationFactory::Mailer.already_sent?(ticket1, @agent1, 'email'), ticket1.id)
|
|
|
|
assert_equal(1, NotificationFactory::Mailer.already_sent?(ticket1, @agent2, 'email'), ticket1.id)
|
|
|
|
assert_equal(0, NotificationFactory::Mailer.already_sent?(ticket1, @agent3, 'email'), ticket1.id)
|
|
|
|
assert_equal(0, NotificationFactory::Mailer.already_sent?(ticket1, @agent4, 'email'), ticket1.id)
|
|
|
|
|
|
|
|
@agent2.out_of_office = true
|
|
|
|
@agent2.preferences[:out_of_office_text] = 'at the doctor'
|
|
|
|
@agent2.out_of_office_replacement_id = @agent3.id
|
|
|
|
@agent2.out_of_office_start_at = Time.zone.today - 2.days
|
|
|
|
@agent2.out_of_office_end_at = Time.zone.today + 2.days
|
|
|
|
@agent2.save!
|
|
|
|
|
|
|
|
# create ticket in group
|
|
|
|
ticket2 = Ticket.create!(
|
2018-12-19 17:31:51 +00:00
|
|
|
title: 'some notification test out of office',
|
|
|
|
group: Group.lookup(name: 'TicketNotificationTest'),
|
|
|
|
customer: @customer,
|
|
|
|
owner_id: @agent2.id,
|
2021-07-16 13:44:10 +00:00
|
|
|
# state: Ticket::State.lookup(name: 'new'),
|
|
|
|
# priority: Ticket::Priority.lookup(name: '2 normal'),
|
2017-09-05 09:49:32 +00:00
|
|
|
updated_by_id: @customer.id,
|
|
|
|
created_by_id: @customer.id,
|
|
|
|
)
|
|
|
|
Ticket::Article.create!(
|
2018-12-19 17:31:51 +00:00
|
|
|
ticket_id: ticket2.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.where(name: 'Customer').first,
|
|
|
|
type: Ticket::Article::Type.where(name: 'email').first,
|
2017-09-05 09:49:32 +00:00
|
|
|
updated_by_id: @customer.id,
|
|
|
|
created_by_id: @customer.id,
|
|
|
|
)
|
|
|
|
assert(ticket2, 'ticket created - ticket notification simple')
|
|
|
|
|
|
|
|
# execute object transaction
|
2021-05-20 06:59:02 +00:00
|
|
|
TransactionDispatcher.commit
|
2017-09-05 09:49:32 +00:00
|
|
|
Scheduler.worker(true)
|
|
|
|
|
|
|
|
# verify notifications to @agent1 + @agent2
|
|
|
|
assert_equal(0, NotificationFactory::Mailer.already_sent?(ticket2, @agent1, 'email'), ticket2.id)
|
|
|
|
assert_equal(1, NotificationFactory::Mailer.already_sent?(ticket2, @agent2, 'email'), ticket2.id)
|
|
|
|
assert_equal(1, NotificationFactory::Mailer.already_sent?(ticket2, @agent3, 'email'), ticket2.id)
|
|
|
|
assert_equal(0, NotificationFactory::Mailer.already_sent?(ticket2, @agent4, 'email'), ticket2.id)
|
|
|
|
|
|
|
|
# update ticket attributes
|
|
|
|
ticket2.title = "#{ticket2.title} - #2"
|
|
|
|
ticket2.priority = Ticket::Priority.lookup(name: '3 high')
|
|
|
|
ticket2.save!
|
|
|
|
|
|
|
|
# execute object transaction
|
2021-05-20 06:59:02 +00:00
|
|
|
TransactionDispatcher.commit
|
2017-09-05 09:49:32 +00:00
|
|
|
Scheduler.worker(true)
|
|
|
|
|
|
|
|
# verify notifications to @agent1 + @agent2
|
|
|
|
assert_equal(0, NotificationFactory::Mailer.already_sent?(ticket2, @agent1, 'email'), ticket2.id)
|
|
|
|
assert_equal(2, NotificationFactory::Mailer.already_sent?(ticket2, @agent2, 'email'), ticket2.id)
|
|
|
|
assert_equal(2, NotificationFactory::Mailer.already_sent?(ticket2, @agent3, 'email'), ticket2.id)
|
|
|
|
assert_equal(0, NotificationFactory::Mailer.already_sent?(ticket2, @agent4, 'email'), ticket2.id)
|
|
|
|
|
|
|
|
@agent3.out_of_office = true
|
|
|
|
@agent3.preferences[:out_of_office_text] = 'at the doctor'
|
|
|
|
@agent3.out_of_office_replacement_id = @agent4.id
|
|
|
|
@agent3.out_of_office_start_at = Time.zone.today - 2.days
|
|
|
|
@agent3.out_of_office_end_at = Time.zone.today + 2.days
|
|
|
|
@agent3.save!
|
|
|
|
|
|
|
|
# update ticket attributes
|
|
|
|
ticket2.title = "#{ticket2.title} - #3"
|
|
|
|
ticket2.priority = Ticket::Priority.lookup(name: '3 high')
|
|
|
|
ticket2.save!
|
|
|
|
|
|
|
|
# execute object transaction
|
2021-05-20 06:59:02 +00:00
|
|
|
TransactionDispatcher.commit
|
2017-09-05 09:49:32 +00:00
|
|
|
Scheduler.worker(true)
|
|
|
|
|
|
|
|
# verify notifications to @agent1 + @agent2
|
|
|
|
assert_equal(0, NotificationFactory::Mailer.already_sent?(ticket2, @agent1, 'email'), ticket2.id)
|
|
|
|
assert_equal(3, NotificationFactory::Mailer.already_sent?(ticket2, @agent2, 'email'), ticket2.id)
|
2021-08-27 15:09:11 +00:00
|
|
|
assert_equal(2, NotificationFactory::Mailer.already_sent?(ticket2, @agent3, 'email'), ticket2.id)
|
2017-09-05 09:49:32 +00:00
|
|
|
assert_equal(1, NotificationFactory::Mailer.already_sent?(ticket2, @agent4, 'email'), ticket2.id)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2015-01-04 12:52:14 +00:00
|
|
|
test 'ticket notification template' do
|
|
|
|
|
|
|
|
# create ticket in group
|
2017-06-14 15:25:45 +00:00
|
|
|
ticket1 = Ticket.create!(
|
2018-12-19 17:31:51 +00:00
|
|
|
title: 'some notification template test 1 Bobs\'s resumé',
|
|
|
|
group: Group.lookup(name: 'TicketNotificationTest'),
|
|
|
|
customer: @customer,
|
|
|
|
state: Ticket::State.lookup(name: 'new'),
|
|
|
|
priority: Ticket::Priority.lookup(name: '2 normal'),
|
2017-06-14 15:25:45 +00:00
|
|
|
updated_by_id: @customer.id,
|
|
|
|
created_by_id: @customer.id,
|
2015-01-04 12:52:14 +00:00
|
|
|
)
|
2017-06-14 15:25:45 +00:00
|
|
|
article = 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\nnewline1 abc\nnewline2",
|
|
|
|
internal: false,
|
|
|
|
sender: Ticket::Article::Sender.where(name: 'Customer').first,
|
|
|
|
type: Ticket::Article::Type.where(name: 'email').first,
|
2017-06-14 15:25:45 +00:00
|
|
|
updated_by_id: @customer.id,
|
|
|
|
created_by_id: @customer.id,
|
2015-01-04 12:52:14 +00:00
|
|
|
)
|
2016-02-03 07:58:51 +00:00
|
|
|
assert(ticket1, 'ticket created - ticket notification template')
|
2015-01-04 12:52:14 +00:00
|
|
|
|
2016-04-15 21:56:10 +00:00
|
|
|
bg = Transaction::Notification.new(
|
2018-12-19 17:31:51 +00:00
|
|
|
ticket_id: ticket1.id,
|
2015-04-27 13:42:53 +00:00
|
|
|
article_id: article.id,
|
2018-12-19 17:31:51 +00:00
|
|
|
type: 'update',
|
|
|
|
changes: {
|
2015-02-10 22:32:56 +00:00
|
|
|
'priority_id' => [1, 2],
|
2015-04-27 17:42:59 +00:00
|
|
|
'pending_time' => [nil, Time.zone.parse('2015-01-11 23:33:47 UTC')],
|
2015-01-04 12:52:14 +00:00
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
user_id: ticket1.updated_by_id,
|
2015-01-04 12:52:14 +00:00
|
|
|
)
|
2015-01-04 15:39:57 +00:00
|
|
|
|
|
|
|
# check changed attributes
|
2017-06-14 15:25:45 +00:00
|
|
|
human_changes = bg.human_changes(@agent2, ticket1)
|
2016-04-27 07:31:11 +00:00
|
|
|
assert(human_changes['Priority'], 'Check if attributes translated based on ObjectManager::Attribute')
|
|
|
|
assert(human_changes['Pending till'], 'Check if attributes translated based on ObjectManager::Attribute')
|
|
|
|
assert_equal('1 low', human_changes['Priority'][0])
|
|
|
|
assert_equal('2 normal', human_changes['Priority'][1])
|
|
|
|
assert_equal('', human_changes['Pending till'][0].to_s)
|
|
|
|
assert_equal('2015-01-11 23:33:47 UTC', human_changes['Pending till'][1].to_s)
|
|
|
|
assert_not(human_changes['priority_id'])
|
|
|
|
assert_not(human_changes['pending_time'])
|
|
|
|
assert_not(human_changes['pending_till'])
|
2015-01-04 12:52:14 +00:00
|
|
|
|
2015-01-04 15:39:57 +00:00
|
|
|
# en notification
|
2016-04-13 23:40:37 +00:00
|
|
|
result = NotificationFactory::Mailer.template(
|
2018-12-19 17:31:51 +00:00
|
|
|
locale: @agent2.preferences[:locale],
|
2019-02-10 11:01:38 +00:00
|
|
|
timezone: @agent2.preferences[:timezone],
|
2016-02-19 21:05:36 +00:00
|
|
|
template: 'ticket_update',
|
2018-12-19 17:31:51 +00:00
|
|
|
objects: {
|
|
|
|
ticket: ticket1,
|
|
|
|
article: article,
|
2017-06-14 15:25:45 +00:00
|
|
|
recipient: @agent2,
|
2018-12-19 17:31:51 +00:00
|
|
|
changes: human_changes,
|
2016-04-27 07:31:11 +00:00
|
|
|
},
|
2015-01-22 07:17:06 +00:00
|
|
|
)
|
2021-05-12 11:37:44 +00:00
|
|
|
assert_match(%r{Bobs's resumé}, result[:subject])
|
|
|
|
assert_match(%r{Priority}, result[:body])
|
|
|
|
assert_match(%r{1 low}, result[:body])
|
|
|
|
assert_match(%r{2 normal}, result[:body])
|
|
|
|
assert_match(%r{Pending till}, result[:body])
|
2022-01-12 10:53:36 +00:00
|
|
|
assert_match('01/11/2015 7:33 pm (America/St_Lucia)', result[:body])
|
2021-05-12 11:37:44 +00:00
|
|
|
assert_match(%r{update}, result[:body])
|
|
|
|
assert_no_match(%r{pending_till}, result[:body])
|
|
|
|
assert_no_match(%r{i18n}, result[:body])
|
2016-02-19 21:05:36 +00:00
|
|
|
|
2017-06-14 15:25:45 +00:00
|
|
|
human_changes = bg.human_changes(@agent1, ticket1)
|
2016-04-27 07:31:11 +00:00
|
|
|
assert(human_changes['Priority'], 'Check if attributes translated based on ObjectManager::Attribute')
|
|
|
|
assert(human_changes['Pending till'], 'Check if attributes translated based on ObjectManager::Attribute')
|
|
|
|
assert_equal('1 niedrig', human_changes['Priority'][0])
|
|
|
|
assert_equal('2 normal', human_changes['Priority'][1])
|
|
|
|
assert_equal('', human_changes['Pending till'][0].to_s)
|
|
|
|
assert_equal('2015-01-11 23:33:47 UTC', human_changes['Pending till'][1].to_s)
|
|
|
|
assert_not(human_changes['priority_id'])
|
|
|
|
assert_not(human_changes['pending_time'])
|
|
|
|
assert_not(human_changes['pending_till'])
|
2015-01-04 15:39:57 +00:00
|
|
|
|
2019-02-10 11:01:38 +00:00
|
|
|
# de & Europe/Berlin notification
|
2016-04-13 23:40:37 +00:00
|
|
|
result = NotificationFactory::Mailer.template(
|
2018-12-19 17:31:51 +00:00
|
|
|
locale: @agent1.preferences[:locale],
|
2019-02-10 11:01:38 +00:00
|
|
|
timezone: @agent1.preferences[:timezone],
|
2016-02-19 21:05:36 +00:00
|
|
|
template: 'ticket_update',
|
2018-12-19 17:31:51 +00:00
|
|
|
objects: {
|
|
|
|
ticket: ticket1,
|
|
|
|
article: article,
|
2017-06-14 15:25:45 +00:00
|
|
|
recipient: @agent1,
|
2018-12-19 17:31:51 +00:00
|
|
|
changes: human_changes,
|
2016-04-27 07:31:11 +00:00
|
|
|
},
|
2015-01-04 15:39:57 +00:00
|
|
|
)
|
|
|
|
|
2021-05-12 11:37:44 +00:00
|
|
|
assert_match(%r{Bobs's resumé}, result[:subject])
|
|
|
|
assert_match(%r{Priorität}, result[:body])
|
|
|
|
assert_match(%r{1 niedrig}, result[:body])
|
|
|
|
assert_match(%r{2 normal}, result[:body])
|
|
|
|
assert_match(%r{Warten}, result[:body])
|
2019-02-10 11:01:38 +00:00
|
|
|
assert_match('12.01.2015 00:33 (Europe/Berlin)', result[:body])
|
2021-05-12 11:37:44 +00:00
|
|
|
assert_match(%r{aktualis}, result[:body])
|
|
|
|
assert_no_match(%r{pending_till}, result[:body])
|
|
|
|
assert_no_match(%r{i18n}, result[:body])
|
2015-01-02 23:46:11 +00:00
|
|
|
|
2016-04-15 21:56:10 +00:00
|
|
|
bg = Transaction::Notification.new(
|
2018-12-19 17:31:51 +00:00
|
|
|
ticket_id: ticket1.id,
|
2015-04-27 13:42:53 +00:00
|
|
|
article_id: article.id,
|
2018-12-19 17:31:51 +00:00
|
|
|
type: 'update',
|
|
|
|
changes: {
|
|
|
|
title: ['some notification template test old 1', 'some notification template test 1 #2'],
|
2015-04-27 13:42:53 +00:00
|
|
|
priority_id: [2, 3],
|
2015-02-10 12:37:47 +00:00
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
user_id: @customer.id,
|
2015-02-10 12:37:47 +00:00
|
|
|
)
|
|
|
|
|
2015-02-10 22:32:56 +00:00
|
|
|
# check changed attributes
|
2017-06-14 15:25:45 +00:00
|
|
|
human_changes = bg.human_changes(@agent1, ticket1)
|
2016-02-03 07:58:51 +00:00
|
|
|
assert(human_changes['Title'], 'Check if attributes translated based on ObjectManager::Attribute')
|
|
|
|
assert(human_changes['Priority'], 'Check if attributes translated based on ObjectManager::Attribute')
|
2016-02-19 21:05:36 +00:00
|
|
|
assert_equal('2 normal', human_changes['Priority'][0])
|
|
|
|
assert_equal('3 hoch', human_changes['Priority'][1])
|
|
|
|
assert_equal('some notification template test old 1', human_changes['Title'][0])
|
2016-02-03 07:58:51 +00:00
|
|
|
assert_equal('some notification template test 1 #2', human_changes['Title'][1])
|
|
|
|
assert_not(human_changes['priority_id'])
|
|
|
|
assert_not(human_changes['pending_time'])
|
|
|
|
assert_not(human_changes['pending_till'])
|
2015-02-10 12:37:47 +00:00
|
|
|
|
2016-02-19 21:05:36 +00:00
|
|
|
# de notification
|
2016-04-13 23:40:37 +00:00
|
|
|
result = NotificationFactory::Mailer.template(
|
2018-12-19 17:31:51 +00:00
|
|
|
locale: @agent1.preferences[:locale],
|
2019-02-10 11:01:38 +00:00
|
|
|
timezone: @agent1.preferences[:timezone],
|
2016-02-19 21:05:36 +00:00
|
|
|
template: 'ticket_update',
|
2018-12-19 17:31:51 +00:00
|
|
|
objects: {
|
|
|
|
ticket: ticket1,
|
|
|
|
article: article,
|
2017-06-14 15:25:45 +00:00
|
|
|
recipient: @agent1,
|
2018-12-19 17:31:51 +00:00
|
|
|
changes: human_changes,
|
2016-02-19 21:05:36 +00:00
|
|
|
}
|
|
|
|
)
|
|
|
|
|
2021-05-12 11:37:44 +00:00
|
|
|
assert_match(%r{Bobs's resumé}, result[:subject])
|
|
|
|
assert_match(%r{Titel}, result[:body])
|
|
|
|
assert_no_match(%r{Title}, result[:body])
|
|
|
|
assert_match(%r{some notification template test old 1}, result[:body])
|
|
|
|
assert_match(%r{some notification template test 1 #2}, result[:body])
|
|
|
|
assert_match(%r{Priorität}, result[:body])
|
|
|
|
assert_no_match(%r{Priority}, result[:body])
|
|
|
|
assert_match(%r{3 hoch}, result[:body])
|
|
|
|
assert_match(%r{2 normal}, result[:body])
|
|
|
|
assert_match(%r{aktualisier}, result[:body])
|
2016-02-19 21:05:36 +00:00
|
|
|
|
2017-06-14 15:25:45 +00:00
|
|
|
human_changes = bg.human_changes(@agent2, ticket1)
|
2015-02-10 12:37:47 +00:00
|
|
|
|
2016-02-19 21:05:36 +00:00
|
|
|
# en notification
|
2016-04-13 23:40:37 +00:00
|
|
|
result = NotificationFactory::Mailer.template(
|
2018-12-19 17:31:51 +00:00
|
|
|
locale: @agent2.preferences[:locale],
|
2019-02-10 11:01:38 +00:00
|
|
|
timezone: @agent2.preferences[:timezone],
|
2016-02-19 21:05:36 +00:00
|
|
|
template: 'ticket_update',
|
2018-12-19 17:31:51 +00:00
|
|
|
objects: {
|
|
|
|
ticket: ticket1,
|
|
|
|
article: article,
|
2017-06-14 15:25:45 +00:00
|
|
|
recipient: @agent2,
|
2018-12-19 17:31:51 +00:00
|
|
|
changes: human_changes,
|
2016-02-19 21:05:36 +00:00
|
|
|
}
|
|
|
|
)
|
2015-02-10 12:37:47 +00:00
|
|
|
|
2021-05-12 11:37:44 +00:00
|
|
|
assert_match(%r{Bobs's resumé}, result[:subject])
|
|
|
|
assert_match(%r{Title}, result[:body])
|
|
|
|
assert_match(%r{some notification template test old 1}, result[:body])
|
|
|
|
assert_match(%r{some notification template test 1 #2}, result[:body])
|
|
|
|
assert_match(%r{Priority}, result[:body])
|
|
|
|
assert_match(%r{3 high}, result[:body])
|
|
|
|
assert_match(%r{2 normal}, result[:body])
|
|
|
|
assert_no_match(%r{Pending till}, result[:body])
|
|
|
|
assert_no_match(%r{2015-01-11 23:33:47 UTC}, result[:body])
|
|
|
|
assert_match(%r{update}, result[:body])
|
|
|
|
assert_no_match(%r{pending_till}, result[:body])
|
|
|
|
assert_no_match(%r{i18n}, result[:body])
|
2015-02-10 12:37:47 +00:00
|
|
|
|
2019-02-10 11:01:38 +00:00
|
|
|
# en notification
|
|
|
|
ticket1.escalation_at = Time.zone.parse('2019-04-01T10:00:00Z')
|
|
|
|
result = NotificationFactory::Mailer.template(
|
|
|
|
locale: @agent2.preferences[:locale],
|
|
|
|
timezone: @agent2.preferences[:timezone],
|
|
|
|
template: 'ticket_escalation',
|
|
|
|
objects: {
|
|
|
|
ticket: ticket1,
|
|
|
|
article: article,
|
|
|
|
recipient: @agent2,
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
assert_match('Ticket is escalated (some notification template test 1 Bobs\'s resumé', result[:subject])
|
2022-01-12 10:53:36 +00:00
|
|
|
assert_match('is escalated since "04/01/2019 6:00 am (America/St_Lucia)"!', result[:body])
|
2019-02-10 11:01:38 +00:00
|
|
|
|
2015-01-02 23:46:11 +00:00
|
|
|
end
|
|
|
|
|
2015-04-27 14:15:29 +00:00
|
|
|
end
|