2015-01-21 20:45:22 +00:00
|
|
|
require 'test_helper'
|
|
|
|
|
|
|
|
class OnlineNotificationTest < ActiveSupport::TestCase
|
2017-06-14 15:25:45 +00:00
|
|
|
|
|
|
|
setup do
|
|
|
|
role = Role.lookup(name: 'Agent')
|
|
|
|
@group = Group.create_or_update(
|
2018-12-19 17:31:51 +00:00
|
|
|
name: 'OnlineNotificationTest',
|
2016-06-20 08:55:45 +00:00
|
|
|
updated_by_id: 1,
|
|
|
|
created_by_id: 1
|
|
|
|
)
|
2017-06-14 15:25:45 +00:00
|
|
|
@agent_user1 = User.create_or_update(
|
2018-12-19 17:31:51 +00:00
|
|
|
login: 'agent_online_notify1',
|
|
|
|
firstname: 'Bob',
|
|
|
|
lastname: 'Smith',
|
|
|
|
email: 'agent_online_notify1@example.com',
|
|
|
|
password: 'some_pass',
|
|
|
|
active: true,
|
|
|
|
role_ids: [role.id],
|
|
|
|
group_ids: [@group.id],
|
2016-06-20 08:55:45 +00:00
|
|
|
updated_by_id: 1,
|
|
|
|
created_by_id: 1
|
|
|
|
)
|
2017-06-14 15:25:45 +00:00
|
|
|
@agent_user2 = User.create_or_update(
|
2018-12-19 17:31:51 +00:00
|
|
|
login: 'agent_online_notify2',
|
|
|
|
firstname: 'Bob',
|
|
|
|
lastname: 'Smith',
|
|
|
|
email: 'agent_online_notify2@example.com',
|
|
|
|
password: 'some_pass',
|
|
|
|
active: true,
|
|
|
|
role_ids: [role.id],
|
|
|
|
group_ids: [@group.id],
|
2016-06-20 08:55:45 +00:00
|
|
|
updated_by_id: 1,
|
|
|
|
created_by_id: 1
|
|
|
|
)
|
2017-06-14 15:25:45 +00:00
|
|
|
@customer_user = User.lookup(email: 'nicole.braun@zammad.org')
|
2018-04-04 19:32:43 +00:00
|
|
|
|
|
|
|
calendar1 = Calendar.create_or_update(
|
2018-12-19 17:31:51 +00:00
|
|
|
name: 'EU 1 - test',
|
|
|
|
timezone: 'Europe/Berlin',
|
2018-04-04 19:32:43 +00:00
|
|
|
business_hours: {
|
|
|
|
mon: {
|
2018-12-19 17:31:51 +00:00
|
|
|
active: true,
|
2018-04-04 19:32:43 +00:00
|
|
|
timeframes: [ ['00:00', '23:59'] ]
|
|
|
|
},
|
|
|
|
tue: {
|
2018-12-19 17:31:51 +00:00
|
|
|
active: true,
|
2018-04-04 19:32:43 +00:00
|
|
|
timeframes: [ ['00:00', '23:59'] ]
|
|
|
|
},
|
|
|
|
wed: {
|
2018-12-19 17:31:51 +00:00
|
|
|
active: true,
|
2018-04-04 19:32:43 +00:00
|
|
|
timeframes: [ ['00:00', '23:59'] ]
|
|
|
|
},
|
|
|
|
thu: {
|
2018-12-19 17:31:51 +00:00
|
|
|
active: true,
|
2018-04-04 19:32:43 +00:00
|
|
|
timeframes: [ ['00:00', '23:59'] ]
|
|
|
|
},
|
|
|
|
fri: {
|
2018-12-19 17:31:51 +00:00
|
|
|
active: true,
|
2018-04-04 19:32:43 +00:00
|
|
|
timeframes: [ ['00:00', '23:59'] ]
|
|
|
|
},
|
|
|
|
sat: {
|
2018-12-19 17:31:51 +00:00
|
|
|
active: true,
|
2018-04-04 19:32:43 +00:00
|
|
|
timeframes: [ ['00:00', '23:59'] ]
|
|
|
|
},
|
|
|
|
sun: {
|
2018-12-19 17:31:51 +00:00
|
|
|
active: true,
|
2018-04-04 19:32:43 +00:00
|
|
|
timeframes: [ ['00:00', '23:59'] ]
|
|
|
|
},
|
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
default: true,
|
|
|
|
ical_url: nil,
|
|
|
|
updated_by_id: 1,
|
|
|
|
created_by_id: 1,
|
2018-04-04 19:32:43 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
sla1 = Sla.create_or_update(
|
2018-12-19 17:31:51 +00:00
|
|
|
name: 'test sla 1',
|
|
|
|
condition: {},
|
2018-04-04 19:32:43 +00:00
|
|
|
first_response_time: 20,
|
2018-12-19 17:31:51 +00:00
|
|
|
update_time: 60,
|
|
|
|
solution_time: 120,
|
|
|
|
calendar_id: calendar1.id,
|
|
|
|
updated_by_id: 1,
|
|
|
|
created_by_id: 1,
|
2018-04-04 19:32:43 +00:00
|
|
|
)
|
|
|
|
|
2016-06-20 08:55:45 +00:00
|
|
|
end
|
2015-01-21 20:45:22 +00:00
|
|
|
|
2015-09-03 09:14:09 +00:00
|
|
|
test 'ticket notification' do
|
2016-02-22 07:58:33 +00:00
|
|
|
|
2016-08-20 19:29:22 +00:00
|
|
|
ApplicationHandleInfo.current = 'application_server'
|
2016-02-22 08:51:56 +00:00
|
|
|
|
2016-02-22 07:58:33 +00:00
|
|
|
# case #1
|
|
|
|
ticket1 = Ticket.create(
|
2018-12-19 17:31:51 +00:00
|
|
|
group: @group,
|
|
|
|
customer_id: @customer_user.id,
|
|
|
|
owner_id: User.lookup(login: '-').id,
|
|
|
|
title: 'Unit Test 1 (äöüß)!',
|
|
|
|
state_id: Ticket::State.lookup(name: 'closed').id,
|
|
|
|
priority_id: Ticket::Priority.lookup(name: '2 normal').id,
|
2017-06-14 15:25:45 +00:00
|
|
|
updated_by_id: @agent_user1.id,
|
|
|
|
created_by_id: @agent_user1.id,
|
2016-02-22 07:58:33 +00:00
|
|
|
)
|
|
|
|
article1 = Ticket::Article.create(
|
2018-12-19 17:31:51 +00:00
|
|
|
ticket_id: ticket1.id,
|
2017-06-14 15:25:45 +00:00
|
|
|
updated_by_id: @agent_user1.id,
|
|
|
|
created_by_id: @agent_user1.id,
|
2018-12-19 17:31:51 +00:00
|
|
|
type_id: Ticket::Article::Type.lookup(name: 'phone').id,
|
|
|
|
sender_id: Ticket::Article::Sender.lookup(name: 'Customer').id,
|
|
|
|
from: 'Unit Test <unittest@example.com>',
|
|
|
|
body: 'Unit Test 123',
|
|
|
|
internal: false
|
2016-02-22 07:58:33 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
# remember ticket
|
2015-01-21 20:45:22 +00:00
|
|
|
tickets = []
|
2016-02-22 07:58:33 +00:00
|
|
|
tickets.push ticket1
|
2015-01-21 20:45:22 +00:00
|
|
|
|
2016-04-14 07:17:13 +00:00
|
|
|
# execute object transaction
|
|
|
|
Observer::Transaction.commit
|
2016-04-26 09:30:46 +00:00
|
|
|
Scheduler.worker(true)
|
2015-01-21 20:45:22 +00:00
|
|
|
|
2016-02-22 07:58:33 +00:00
|
|
|
# because it's already closed
|
|
|
|
assert(OnlineNotification.all_seen?('Ticket', ticket1.id))
|
2018-10-09 06:17:41 +00:00
|
|
|
assert_not(OnlineNotification.exists?(@agent_user1, 'Ticket', ticket1.id, 'create', @agent_user1, false))
|
|
|
|
assert_not(OnlineNotification.exists?(@agent_user1, 'Ticket', ticket1.id, 'create', @agent_user1, true))
|
|
|
|
assert_not(OnlineNotification.exists?(@agent_user2, 'Ticket', ticket1.id, 'create', @agent_user1, false))
|
2017-06-14 15:25:45 +00:00
|
|
|
assert(OnlineNotification.exists?(@agent_user2, 'Ticket', ticket1.id, 'create', @agent_user1, true))
|
2015-01-21 20:45:22 +00:00
|
|
|
|
2017-09-11 11:16:08 +00:00
|
|
|
ticket1.update!(
|
2018-12-19 17:31:51 +00:00
|
|
|
title: 'Unit Test 1 (äöüß) - update!',
|
|
|
|
state_id: Ticket::State.lookup(name: 'open').id,
|
|
|
|
priority_id: Ticket::Priority.lookup(name: '1 low').id,
|
2017-06-14 15:25:45 +00:00
|
|
|
updated_by_id: @customer_user.id,
|
2016-02-22 07:58:33 +00:00
|
|
|
)
|
2015-01-21 20:45:22 +00:00
|
|
|
|
2016-04-14 07:17:13 +00:00
|
|
|
# execute object transaction
|
|
|
|
Observer::Transaction.commit
|
2016-04-26 09:30:46 +00:00
|
|
|
Scheduler.worker(true)
|
2015-01-21 20:45:22 +00:00
|
|
|
|
2016-02-22 07:58:33 +00:00
|
|
|
# because it's already open
|
2018-10-09 06:17:41 +00:00
|
|
|
assert_not(OnlineNotification.all_seen?('Ticket', ticket1.id))
|
|
|
|
assert_not(OnlineNotification.exists?(@agent_user1, 'Ticket', ticket1.id, 'update', @customer_user, true))
|
2017-06-14 15:25:45 +00:00
|
|
|
assert(OnlineNotification.exists?(@agent_user1, 'Ticket', ticket1.id, 'update', @customer_user, false))
|
2018-10-09 06:17:41 +00:00
|
|
|
assert_not(OnlineNotification.exists?(@agent_user2, 'Ticket', ticket1.id, 'update', @customer_user, true))
|
2017-06-14 15:25:45 +00:00
|
|
|
assert(OnlineNotification.exists?(@agent_user2, 'Ticket', ticket1.id, 'update', @customer_user, false))
|
2016-02-22 07:58:33 +00:00
|
|
|
|
|
|
|
# case #2
|
|
|
|
ticket2 = Ticket.create(
|
2018-12-19 17:31:51 +00:00
|
|
|
group: @group,
|
|
|
|
customer_id: @customer_user.id,
|
|
|
|
owner_id: @agent_user1.id,
|
|
|
|
title: 'Unit Test 1 (äöüß)!',
|
|
|
|
state_id: Ticket::State.lookup(name: 'closed').id,
|
|
|
|
priority_id: Ticket::Priority.lookup(name: '2 normal').id,
|
2017-06-14 15:25:45 +00:00
|
|
|
updated_by_id: @customer_user.id,
|
|
|
|
created_by_id: @customer_user.id,
|
2016-02-22 07:58:33 +00:00
|
|
|
)
|
|
|
|
article2 = Ticket::Article.create(
|
2018-12-19 17:31:51 +00:00
|
|
|
ticket_id: ticket2.id,
|
2017-06-14 15:25:45 +00:00
|
|
|
updated_by_id: @customer_user.id,
|
|
|
|
created_by_id: @customer_user.id,
|
2018-12-19 17:31:51 +00:00
|
|
|
type_id: Ticket::Article::Type.lookup(name: 'phone').id,
|
|
|
|
sender_id: Ticket::Article::Sender.lookup(name: 'Customer').id,
|
|
|
|
from: 'Unit Test <unittest@example.com>',
|
|
|
|
body: 'Unit Test 123',
|
|
|
|
internal: false
|
2016-02-22 07:58:33 +00:00
|
|
|
)
|
2015-01-21 20:45:22 +00:00
|
|
|
|
2016-02-22 07:58:33 +00:00
|
|
|
# remember ticket
|
|
|
|
tickets = []
|
|
|
|
tickets.push ticket2
|
2015-01-21 20:45:22 +00:00
|
|
|
|
2016-04-14 07:17:13 +00:00
|
|
|
# execute object transaction
|
|
|
|
Observer::Transaction.commit
|
2016-04-26 09:30:46 +00:00
|
|
|
Scheduler.worker(true)
|
2015-04-01 14:33:24 +00:00
|
|
|
|
2016-02-22 07:58:33 +00:00
|
|
|
# because it's already closed
|
2018-10-09 06:17:41 +00:00
|
|
|
assert_not(OnlineNotification.all_seen?('Ticket', ticket2.id))
|
2017-06-14 15:25:45 +00:00
|
|
|
assert(OnlineNotification.exists?(@agent_user1, 'Ticket', ticket2.id, 'create', @customer_user, false))
|
2018-10-09 06:17:41 +00:00
|
|
|
assert_not(OnlineNotification.exists?(@agent_user1, 'Ticket', ticket2.id, 'create', @customer_user, true))
|
|
|
|
assert_not(OnlineNotification.exists?(@agent_user2, 'Ticket', ticket2.id, 'create', @customer_user, false))
|
|
|
|
assert_not(OnlineNotification.exists?(@agent_user2, 'Ticket', ticket2.id, 'create', @customer_user, true))
|
2016-02-22 07:58:33 +00:00
|
|
|
|
2017-09-11 11:16:08 +00:00
|
|
|
ticket2.update!(
|
2018-12-19 17:31:51 +00:00
|
|
|
title: 'Unit Test 1 (äöüß) - update!',
|
|
|
|
state_id: Ticket::State.lookup(name: 'open').id,
|
|
|
|
priority_id: Ticket::Priority.lookup(name: '1 low').id,
|
2017-06-14 15:25:45 +00:00
|
|
|
updated_by_id: @customer_user.id,
|
2016-02-22 07:58:33 +00:00
|
|
|
)
|
2015-07-03 17:40:58 +00:00
|
|
|
|
2016-04-14 07:17:13 +00:00
|
|
|
# execute object transaction
|
|
|
|
Observer::Transaction.commit
|
2016-04-26 09:30:46 +00:00
|
|
|
Scheduler.worker(true)
|
2016-02-22 07:58:33 +00:00
|
|
|
|
|
|
|
# because it's already open
|
2018-10-09 06:17:41 +00:00
|
|
|
assert_not(OnlineNotification.all_seen?('Ticket', ticket2.id))
|
2017-06-14 15:25:45 +00:00
|
|
|
assert(OnlineNotification.exists?(@agent_user1, 'Ticket', ticket2.id, 'update', @customer_user, false))
|
2018-10-09 06:17:41 +00:00
|
|
|
assert_not(OnlineNotification.exists?(@agent_user1, 'Ticket', ticket2.id, 'update', @customer_user, true))
|
|
|
|
assert_not(OnlineNotification.exists?(@agent_user2, 'Ticket', ticket2.id, 'update', @customer_user, true))
|
|
|
|
assert_not(OnlineNotification.exists?(@agent_user2, 'Ticket', ticket2.id, 'update', @customer_user, false))
|
2016-02-22 07:58:33 +00:00
|
|
|
|
|
|
|
# case #3
|
|
|
|
ticket3 = Ticket.create(
|
2018-12-19 17:31:51 +00:00
|
|
|
group: @group,
|
|
|
|
customer_id: @customer_user.id,
|
|
|
|
owner_id: User.lookup(login: '-').id,
|
|
|
|
title: 'Unit Test 2 (äöüß)!',
|
|
|
|
state_id: Ticket::State.lookup(name: 'new').id,
|
|
|
|
priority_id: Ticket::Priority.lookup(name: '2 normal').id,
|
2017-06-14 15:25:45 +00:00
|
|
|
updated_by_id: @agent_user1.id,
|
|
|
|
created_by_id: @agent_user1.id,
|
2016-02-22 07:58:33 +00:00
|
|
|
)
|
|
|
|
article3 = Ticket::Article.create(
|
2018-12-19 17:31:51 +00:00
|
|
|
ticket_id: ticket3.id,
|
2017-06-14 15:25:45 +00:00
|
|
|
updated_by_id: @agent_user1.id,
|
|
|
|
created_by_id: @agent_user1.id,
|
2018-12-19 17:31:51 +00:00
|
|
|
type_id: Ticket::Article::Type.lookup(name: 'phone').id,
|
|
|
|
sender_id: Ticket::Article::Sender.lookup(name: 'Customer').id,
|
|
|
|
from: 'Unit Test <unittest@example.com>',
|
|
|
|
body: 'Unit Test 123',
|
|
|
|
internal: false,
|
2016-02-22 07:58:33 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
# remember ticket
|
|
|
|
tickets.push ticket3
|
|
|
|
|
2016-04-14 07:17:13 +00:00
|
|
|
# execute object transaction
|
|
|
|
Observer::Transaction.commit
|
2016-04-26 09:30:46 +00:00
|
|
|
Scheduler.worker(true)
|
2016-02-22 07:58:33 +00:00
|
|
|
|
|
|
|
# because it's already new
|
2018-10-09 06:17:41 +00:00
|
|
|
assert_not(OnlineNotification.all_seen?('Ticket', ticket3.id))
|
|
|
|
assert_not(OnlineNotification.exists?(@agent_user1, 'Ticket', ticket3.id, 'create', @agent_user1, false))
|
|
|
|
assert_not(OnlineNotification.exists?(@agent_user1, 'Ticket', ticket3.id, 'create', @agent_user1, true))
|
2017-06-14 15:25:45 +00:00
|
|
|
assert(OnlineNotification.exists?(@agent_user2, 'Ticket', ticket3.id, 'create', @agent_user1, false))
|
2018-10-09 06:17:41 +00:00
|
|
|
assert_not(OnlineNotification.exists?(@agent_user2, 'Ticket', ticket3.id, 'create', @agent_user1, true))
|
2016-02-22 07:58:33 +00:00
|
|
|
|
2017-09-11 11:16:08 +00:00
|
|
|
ticket3.update!(
|
2018-12-19 17:31:51 +00:00
|
|
|
title: 'Unit Test 2 (äöüß) - update!',
|
|
|
|
state_id: Ticket::State.lookup(name: 'closed').id,
|
|
|
|
priority_id: Ticket::Priority.lookup(name: '1 low').id,
|
2017-06-14 15:25:45 +00:00
|
|
|
updated_by_id: @customer_user.id,
|
2016-02-22 07:58:33 +00:00
|
|
|
)
|
|
|
|
|
2016-04-14 07:17:13 +00:00
|
|
|
# execute object transaction
|
|
|
|
Observer::Transaction.commit
|
2016-04-26 09:30:46 +00:00
|
|
|
Scheduler.worker(true)
|
2016-02-22 07:58:33 +00:00
|
|
|
|
|
|
|
# because it's already closed
|
|
|
|
assert(OnlineNotification.all_seen?('Ticket', ticket3.id))
|
2017-06-14 15:25:45 +00:00
|
|
|
assert_equal(1, NotificationFactory::Mailer.already_sent?(ticket3, @agent_user1, 'update'))
|
|
|
|
assert_equal(1, NotificationFactory::Mailer.already_sent?(ticket3, @agent_user2, 'update'))
|
2018-10-09 06:17:41 +00:00
|
|
|
assert_not(OnlineNotification.exists?(@agent_user1, 'Ticket', ticket3.id, 'update', @customer_user, false))
|
2017-06-14 15:25:45 +00:00
|
|
|
assert(OnlineNotification.exists?(@agent_user1, 'Ticket', ticket3.id, 'update', @customer_user, true))
|
2018-10-09 06:17:41 +00:00
|
|
|
assert_not(OnlineNotification.exists?(@agent_user2, 'Ticket', ticket3.id, 'update', @customer_user, false))
|
2017-06-14 15:25:45 +00:00
|
|
|
assert(OnlineNotification.exists?(@agent_user2, 'Ticket', ticket3.id, 'update', @customer_user, true))
|
2016-02-22 07:58:33 +00:00
|
|
|
|
|
|
|
article3 = Ticket::Article.create(
|
2018-12-19 17:31:51 +00:00
|
|
|
ticket_id: ticket3.id,
|
2017-06-14 15:25:45 +00:00
|
|
|
updated_by_id: @customer_user.id,
|
|
|
|
created_by_id: @customer_user.id,
|
2018-12-19 17:31:51 +00:00
|
|
|
type_id: Ticket::Article::Type.lookup(name: 'phone').id,
|
|
|
|
sender_id: Ticket::Article::Sender.lookup(name: 'Customer').id,
|
|
|
|
from: 'Unit Test <unittest@example.com>',
|
|
|
|
body: 'Unit Test 123 # 2',
|
|
|
|
internal: false
|
2016-02-22 07:58:33 +00:00
|
|
|
)
|
|
|
|
|
2016-04-14 07:17:13 +00:00
|
|
|
# execute object transaction
|
|
|
|
Observer::Transaction.commit
|
2016-04-26 09:30:46 +00:00
|
|
|
Scheduler.worker(true)
|
2016-02-22 07:58:33 +00:00
|
|
|
|
|
|
|
# because it's already closed but an follow up arrived later
|
2018-10-09 06:17:41 +00:00
|
|
|
assert_not(OnlineNotification.all_seen?('Ticket', ticket3.id))
|
2017-06-14 15:25:45 +00:00
|
|
|
assert(OnlineNotification.exists?(@agent_user1, 'Ticket', ticket3.id, 'update', @customer_user, false))
|
|
|
|
assert(OnlineNotification.exists?(@agent_user1, 'Ticket', ticket3.id, 'update', @customer_user, true))
|
|
|
|
assert(OnlineNotification.exists?(@agent_user2, 'Ticket', ticket3.id, 'update', @customer_user, false))
|
|
|
|
assert(OnlineNotification.exists?(@agent_user2, 'Ticket', ticket3.id, 'update', @customer_user, true))
|
|
|
|
assert_equal(2, NotificationFactory::Mailer.already_sent?(ticket3, @agent_user1, 'update'))
|
|
|
|
assert_equal(2, NotificationFactory::Mailer.already_sent?(ticket3, @agent_user2, 'update'))
|
2016-02-22 07:58:33 +00:00
|
|
|
|
|
|
|
# case #4
|
|
|
|
ticket4 = Ticket.create(
|
2018-12-19 17:31:51 +00:00
|
|
|
group: @group,
|
|
|
|
customer_id: @customer_user.id,
|
|
|
|
owner_id: @agent_user1.id,
|
|
|
|
title: 'Unit Test 3 (äöüß)!',
|
|
|
|
state_id: Ticket::State.lookup(name: 'new').id,
|
|
|
|
priority_id: Ticket::Priority.lookup(name: '2 normal').id,
|
2017-06-14 15:25:45 +00:00
|
|
|
updated_by_id: @customer_user.id,
|
|
|
|
created_by_id: @customer_user.id,
|
2016-02-22 07:58:33 +00:00
|
|
|
)
|
|
|
|
article4 = Ticket::Article.create(
|
2018-12-19 17:31:51 +00:00
|
|
|
ticket_id: ticket4.id,
|
2017-06-14 15:25:45 +00:00
|
|
|
updated_by_id: @customer_user.id,
|
|
|
|
created_by_id: @customer_user.id,
|
2018-12-19 17:31:51 +00:00
|
|
|
type_id: Ticket::Article::Type.lookup(name: 'phone').id,
|
|
|
|
sender_id: Ticket::Article::Sender.lookup(name: 'Customer').id,
|
|
|
|
from: 'Unit Test <unittest@example.com>',
|
|
|
|
body: 'Unit Test 123',
|
|
|
|
internal: false,
|
2016-02-22 07:58:33 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
# remember ticket
|
|
|
|
tickets.push ticket4
|
|
|
|
|
2016-04-14 07:17:13 +00:00
|
|
|
# execute object transaction
|
|
|
|
Observer::Transaction.commit
|
2016-04-26 09:30:46 +00:00
|
|
|
Scheduler.worker(true)
|
2016-02-22 07:58:33 +00:00
|
|
|
|
|
|
|
# because it's already new
|
2018-10-09 06:17:41 +00:00
|
|
|
assert_not(OnlineNotification.all_seen?('Ticket', ticket4.id))
|
2017-06-14 15:25:45 +00:00
|
|
|
assert(OnlineNotification.exists?(@agent_user1, 'Ticket', ticket4.id, 'create', @customer_user, false))
|
2018-10-09 06:17:41 +00:00
|
|
|
assert_not(OnlineNotification.exists?(@agent_user1, 'Ticket', ticket4.id, 'create', @customer_user, true))
|
|
|
|
assert_not(OnlineNotification.exists?(@agent_user2, 'Ticket', ticket4.id, 'create', @customer_user, false))
|
|
|
|
assert_not(OnlineNotification.exists?(@agent_user2, 'Ticket', ticket4.id, 'create', @customer_user, true))
|
2016-02-22 07:58:33 +00:00
|
|
|
|
2017-09-11 11:16:08 +00:00
|
|
|
ticket4.update!(
|
2018-12-19 17:31:51 +00:00
|
|
|
title: 'Unit Test 3 (äöüß) - update!',
|
|
|
|
state_id: Ticket::State.lookup(name: 'open').id,
|
|
|
|
priority_id: Ticket::Priority.lookup(name: '1 low').id,
|
2017-06-14 15:25:45 +00:00
|
|
|
updated_by_id: @customer_user.id,
|
2016-02-22 07:58:33 +00:00
|
|
|
)
|
|
|
|
|
2016-04-14 07:17:13 +00:00
|
|
|
# execute object transaction
|
|
|
|
Observer::Transaction.commit
|
2016-04-26 09:30:46 +00:00
|
|
|
Scheduler.worker(true)
|
2016-02-22 07:58:33 +00:00
|
|
|
|
|
|
|
# because it's already open
|
2018-10-09 06:17:41 +00:00
|
|
|
assert_not(OnlineNotification.all_seen?('Ticket', ticket4.id))
|
2017-06-14 15:25:45 +00:00
|
|
|
assert(OnlineNotification.exists?(@agent_user1, 'Ticket', ticket4.id, 'update', @customer_user, false))
|
2018-10-09 06:17:41 +00:00
|
|
|
assert_not(OnlineNotification.exists?(@agent_user1, 'Ticket', ticket4.id, 'update', @customer_user, true))
|
|
|
|
assert_not(OnlineNotification.exists?(@agent_user2, 'Ticket', ticket4.id, 'update', @customer_user, false))
|
|
|
|
assert_not(OnlineNotification.exists?(@agent_user2, 'Ticket', ticket4.id, 'update', @customer_user, true))
|
2016-02-22 07:58:33 +00:00
|
|
|
|
|
|
|
# case #5
|
|
|
|
ticket5 = Ticket.create(
|
2018-12-19 17:31:51 +00:00
|
|
|
group: @group,
|
|
|
|
customer_id: @customer_user.id,
|
|
|
|
owner_id: User.lookup(login: '-').id,
|
|
|
|
title: 'Unit Test 4 (äöüß)!',
|
|
|
|
state_id: Ticket::State.lookup(name: 'new').id,
|
|
|
|
priority_id: Ticket::Priority.lookup( name: '2 normal').id,
|
2017-06-14 15:25:45 +00:00
|
|
|
updated_by_id: @agent_user1.id,
|
|
|
|
created_by_id: @agent_user1.id,
|
2016-02-22 07:58:33 +00:00
|
|
|
)
|
|
|
|
article5 = Ticket::Article.create(
|
2018-12-19 17:31:51 +00:00
|
|
|
ticket_id: ticket5.id,
|
2017-06-14 15:25:45 +00:00
|
|
|
updated_by_id: @agent_user1.id,
|
|
|
|
created_by_id: @agent_user1.id,
|
2018-12-19 17:31:51 +00:00
|
|
|
type_id: Ticket::Article::Type.lookup(name: 'phone').id,
|
|
|
|
sender_id: Ticket::Article::Sender.lookup(name: 'Customer').id,
|
|
|
|
from: 'Unit Test <unittest@example.com>',
|
|
|
|
body: 'Unit Test 123',
|
|
|
|
internal: false,
|
2016-02-22 07:58:33 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
# remember ticket
|
|
|
|
tickets.push ticket5
|
|
|
|
|
2016-04-14 07:17:13 +00:00
|
|
|
# execute object transaction
|
|
|
|
Observer::Transaction.commit
|
2016-04-26 09:30:46 +00:00
|
|
|
Scheduler.worker(true)
|
2016-02-22 07:58:33 +00:00
|
|
|
|
|
|
|
# because it's already new
|
2018-10-09 06:17:41 +00:00
|
|
|
assert_not(OnlineNotification.all_seen?('Ticket', ticket5.id))
|
|
|
|
assert_not(OnlineNotification.exists?(@agent_user1, 'Ticket', ticket5.id, 'create', @agent_user1, true))
|
|
|
|
assert_not(OnlineNotification.exists?(@agent_user1, 'Ticket', ticket5.id, 'create', @agent_user1, false))
|
2017-06-14 15:25:45 +00:00
|
|
|
assert(OnlineNotification.exists?(@agent_user2, 'Ticket', ticket5.id, 'create', @agent_user1, false))
|
2018-10-09 06:17:41 +00:00
|
|
|
assert_not(OnlineNotification.exists?(@agent_user2, 'Ticket', ticket5.id, 'create', @agent_user1, true))
|
2016-02-22 07:58:33 +00:00
|
|
|
|
2017-09-11 11:16:08 +00:00
|
|
|
ticket5.update!(
|
2018-12-19 17:31:51 +00:00
|
|
|
title: 'Unit Test 4 (äöüß) - update!',
|
|
|
|
state_id: Ticket::State.lookup(name: 'open').id,
|
|
|
|
priority_id: Ticket::Priority.lookup(name: '1 low').id,
|
2017-06-14 15:25:45 +00:00
|
|
|
updated_by_id: @customer_user.id,
|
2016-02-22 07:58:33 +00:00
|
|
|
)
|
|
|
|
|
2016-04-14 07:17:13 +00:00
|
|
|
# execute object transaction
|
|
|
|
Observer::Transaction.commit
|
2016-04-26 09:30:46 +00:00
|
|
|
Scheduler.worker(true)
|
2016-02-22 07:58:33 +00:00
|
|
|
|
|
|
|
# because it's already open
|
2018-10-09 06:17:41 +00:00
|
|
|
assert_not(OnlineNotification.all_seen?('Ticket', ticket5.id))
|
2017-06-14 15:25:45 +00:00
|
|
|
assert(OnlineNotification.exists?(@agent_user1, 'Ticket', ticket5.id, 'update', @customer_user, false))
|
2018-10-09 06:17:41 +00:00
|
|
|
assert_not(OnlineNotification.exists?(@agent_user1, 'Ticket', ticket5.id, 'update', @customer_user, true))
|
2017-06-14 15:25:45 +00:00
|
|
|
assert(OnlineNotification.exists?(@agent_user2, 'Ticket', ticket5.id, 'update', @customer_user, false))
|
2018-10-09 06:17:41 +00:00
|
|
|
assert_not(OnlineNotification.exists?(@agent_user2, 'Ticket', ticket5.id, 'update', @customer_user, true))
|
2015-01-21 20:45:22 +00:00
|
|
|
|
2015-04-01 11:47:10 +00:00
|
|
|
# merge tickets - also remove notifications of merged tickets
|
2016-02-22 07:58:33 +00:00
|
|
|
tickets[0].merge_to(
|
|
|
|
ticket_id: tickets[1].id,
|
2018-12-19 17:31:51 +00:00
|
|
|
user_id: 1,
|
2015-04-01 11:47:10 +00:00
|
|
|
)
|
2016-04-26 09:30:46 +00:00
|
|
|
Scheduler.worker(true)
|
2015-04-01 11:47:10 +00:00
|
|
|
|
2016-02-22 07:58:33 +00:00
|
|
|
notifications = OnlineNotification.list_by_object('Ticket', tickets[0].id)
|
2017-11-23 08:09:44 +00:00
|
|
|
assert(notifications.present?, 'should have notifications')
|
2016-02-22 07:58:33 +00:00
|
|
|
assert(OnlineNotification.all_seen?('Ticket', tickets[0].id), 'still not seen notifications for merged ticket available')
|
|
|
|
|
|
|
|
notifications = OnlineNotification.list_by_object('Ticket', tickets[1].id)
|
2017-11-23 08:09:44 +00:00
|
|
|
assert(notifications.present?, 'should have notifications')
|
2018-10-09 06:17:41 +00:00
|
|
|
assert_not(OnlineNotification.all_seen?('Ticket', tickets[1].id), 'no notifications for master ticket available')
|
2015-04-01 11:47:10 +00:00
|
|
|
|
2015-01-21 20:45:22 +00:00
|
|
|
# delete tickets
|
2017-10-01 12:25:52 +00:00
|
|
|
tickets.each do |ticket|
|
2015-01-21 20:45:22 +00:00
|
|
|
ticket_id = ticket.id
|
|
|
|
ticket.destroy
|
2016-02-22 07:58:33 +00:00
|
|
|
found = Ticket.find_by(id: ticket_id)
|
2018-10-09 06:17:41 +00:00
|
|
|
assert_not(found, 'Ticket destroyed')
|
2015-04-01 11:14:46 +00:00
|
|
|
|
|
|
|
# check if notifications for ticket still exist
|
2016-04-26 09:30:46 +00:00
|
|
|
Scheduler.worker(true)
|
2016-02-22 07:58:33 +00:00
|
|
|
notifications = OnlineNotification.list_by_object('Ticket', ticket_id)
|
2017-11-23 08:09:44 +00:00
|
|
|
assert(notifications.blank?, 'still notifications for destroyed ticket available')
|
2017-10-01 12:25:52 +00:00
|
|
|
end
|
2015-01-21 20:45:22 +00:00
|
|
|
end
|
|
|
|
|
2015-09-03 09:14:09 +00:00
|
|
|
test 'ticket notification item check' do
|
|
|
|
ticket1 = Ticket.create(
|
2018-12-19 17:31:51 +00:00
|
|
|
title: 'some title',
|
|
|
|
group: @group,
|
|
|
|
customer_id: @customer_user.id,
|
|
|
|
state: Ticket::State.lookup(name: 'new'),
|
|
|
|
priority: Ticket::Priority.lookup(name: '2 normal'),
|
2015-09-03 09:14:09 +00:00
|
|
|
updated_by_id: 1,
|
|
|
|
created_by_id: 1,
|
|
|
|
)
|
2016-08-20 19:29:22 +00:00
|
|
|
assert(ticket1, 'ticket created')
|
2015-09-03 09:14:09 +00:00
|
|
|
article_inbound = 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 article_inbound',
|
|
|
|
internal: false,
|
|
|
|
sender: Ticket::Article::Sender.lookup(name: 'Customer'),
|
|
|
|
type: Ticket::Article::Type.lookup(name: 'email'),
|
2015-09-03 09:14:09 +00:00
|
|
|
updated_by_id: 1,
|
|
|
|
created_by_id: 1,
|
|
|
|
)
|
|
|
|
|
|
|
|
assert_equal(ticket1.online_notification_seen_state, false)
|
2017-06-14 15:25:45 +00:00
|
|
|
assert_equal(ticket1.online_notification_seen_state(@agent_user1), false)
|
|
|
|
assert_equal(ticket1.online_notification_seen_state(@agent_user2), false)
|
2015-09-03 09:14:09 +00:00
|
|
|
|
|
|
|
# pending reminder, just let new owner to unseed
|
2017-09-11 11:16:08 +00:00
|
|
|
ticket1.update!(
|
2018-12-19 17:31:51 +00:00
|
|
|
owner_id: @agent_user1.id,
|
|
|
|
state: Ticket::State.lookup(name: 'pending reminder'),
|
2017-06-14 15:25:45 +00:00
|
|
|
updated_by_id: @agent_user2.id,
|
2015-09-03 09:14:09 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
assert_equal(ticket1.online_notification_seen_state, true)
|
2017-06-14 15:25:45 +00:00
|
|
|
assert_equal(ticket1.online_notification_seen_state(@agent_user1.id), false)
|
|
|
|
assert_equal(ticket1.online_notification_seen_state(@agent_user2.id), true)
|
2015-09-03 09:14:09 +00:00
|
|
|
|
|
|
|
# pending reminder, just let new owner to unseed
|
2017-09-11 11:16:08 +00:00
|
|
|
ticket1.update!(
|
2018-12-19 17:31:51 +00:00
|
|
|
owner_id: 1,
|
|
|
|
state: Ticket::State.lookup(name: 'pending reminder'),
|
2017-06-14 15:25:45 +00:00
|
|
|
updated_by_id: @agent_user2.id,
|
2015-09-03 09:14:09 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
assert_equal(ticket1.online_notification_seen_state, true)
|
2017-06-14 15:25:45 +00:00
|
|
|
assert_equal(ticket1.online_notification_seen_state(@agent_user1.id), false)
|
|
|
|
assert_equal(ticket1.online_notification_seen_state(@agent_user2.id), false)
|
2015-09-03 09:14:09 +00:00
|
|
|
|
|
|
|
# pending reminder, self done, all to unseed
|
2017-09-11 11:16:08 +00:00
|
|
|
ticket1.update!(
|
2018-12-19 17:31:51 +00:00
|
|
|
owner_id: @agent_user1.id,
|
|
|
|
state: Ticket::State.lookup(name: 'pending reminder'),
|
2017-06-14 15:25:45 +00:00
|
|
|
updated_by_id: @agent_user1.id,
|
2015-09-03 09:14:09 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
assert_equal(ticket1.online_notification_seen_state, true)
|
2017-06-14 15:25:45 +00:00
|
|
|
assert_equal(ticket1.online_notification_seen_state(@agent_user1.id), true)
|
|
|
|
assert_equal(ticket1.online_notification_seen_state(@agent_user2.id), true)
|
2015-09-03 09:14:09 +00:00
|
|
|
|
|
|
|
# pending close, all to unseen
|
2017-09-11 11:16:08 +00:00
|
|
|
ticket1.update!(
|
2018-12-19 17:31:51 +00:00
|
|
|
owner_id: @agent_user1.id,
|
|
|
|
state: Ticket::State.lookup(name: 'pending close'),
|
2017-06-14 15:25:45 +00:00
|
|
|
updated_by_id: @agent_user2.id,
|
2015-09-03 09:14:09 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
assert_equal(ticket1.online_notification_seen_state, true)
|
2017-06-14 15:25:45 +00:00
|
|
|
assert_equal(ticket1.online_notification_seen_state(@agent_user1.id), false)
|
|
|
|
assert_equal(ticket1.online_notification_seen_state(@agent_user2.id), true)
|
2015-09-03 09:14:09 +00:00
|
|
|
|
|
|
|
# to open, all to seen
|
2017-09-11 11:16:08 +00:00
|
|
|
ticket1.update!(
|
2018-12-19 17:31:51 +00:00
|
|
|
owner_id: @agent_user1.id,
|
|
|
|
state: Ticket::State.lookup(name: 'open'),
|
2017-06-14 15:25:45 +00:00
|
|
|
updated_by_id: @agent_user2.id,
|
2015-09-03 09:14:09 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
assert_equal(ticket1.online_notification_seen_state, false)
|
2017-06-14 15:25:45 +00:00
|
|
|
assert_equal(ticket1.online_notification_seen_state(@agent_user1.id), false)
|
|
|
|
assert_equal(ticket1.online_notification_seen_state(@agent_user2.id), false)
|
2015-09-03 09:14:09 +00:00
|
|
|
|
2016-02-20 12:36:59 +00:00
|
|
|
# to closed, all only others to seen
|
2017-09-11 11:16:08 +00:00
|
|
|
ticket1.update!(
|
2018-12-19 17:31:51 +00:00
|
|
|
owner_id: @agent_user1.id,
|
|
|
|
state: Ticket::State.lookup(name: 'closed'),
|
2017-06-14 15:25:45 +00:00
|
|
|
updated_by_id: @agent_user2.id,
|
2016-02-20 12:36:59 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
assert_equal(ticket1.online_notification_seen_state, true)
|
2017-06-14 15:25:45 +00:00
|
|
|
assert_equal(ticket1.online_notification_seen_state(@agent_user1.id), false)
|
|
|
|
assert_equal(ticket1.online_notification_seen_state(@agent_user2.id), true)
|
2016-02-20 12:36:59 +00:00
|
|
|
|
|
|
|
# to closed by owner self, all to seen
|
2017-09-11 11:16:08 +00:00
|
|
|
ticket1.update!(
|
2018-12-19 17:31:51 +00:00
|
|
|
owner_id: @agent_user1.id,
|
|
|
|
state: Ticket::State.lookup(name: 'closed'),
|
2017-06-14 15:25:45 +00:00
|
|
|
updated_by_id: @agent_user1.id,
|
2016-02-20 12:36:59 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
assert_equal(ticket1.online_notification_seen_state, true)
|
2017-06-14 15:25:45 +00:00
|
|
|
assert_equal(ticket1.online_notification_seen_state(@agent_user1.id), true)
|
|
|
|
assert_equal(ticket1.online_notification_seen_state(@agent_user2.id), true)
|
2016-02-20 13:09:56 +00:00
|
|
|
|
|
|
|
# to closed by owner self, all to seen
|
2017-09-11 11:16:08 +00:00
|
|
|
ticket1.update!(
|
2018-12-19 17:31:51 +00:00
|
|
|
owner_id: @agent_user1.id,
|
|
|
|
state: Ticket::State.lookup(name: 'merged'),
|
2017-06-14 15:25:45 +00:00
|
|
|
updated_by_id: @agent_user2.id,
|
2016-02-20 13:09:56 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
assert_equal(ticket1.online_notification_seen_state, true)
|
2017-06-14 15:25:45 +00:00
|
|
|
assert_equal(ticket1.online_notification_seen_state(@agent_user1.id), true)
|
|
|
|
assert_equal(ticket1.online_notification_seen_state(@agent_user2.id), true)
|
2016-02-20 12:36:59 +00:00
|
|
|
|
2015-09-03 09:14:09 +00:00
|
|
|
end
|
|
|
|
|
2016-02-21 11:43:16 +00:00
|
|
|
test 'cleanup check' do
|
2018-12-18 07:33:54 +00:00
|
|
|
|
|
|
|
ticket1 = Ticket.create(
|
2018-12-19 17:31:51 +00:00
|
|
|
group: @group,
|
|
|
|
customer_id: @customer_user.id,
|
|
|
|
owner_id: User.lookup(login: '-').id,
|
|
|
|
title: 'Unit Test 1 (äöüß)!',
|
|
|
|
state_id: Ticket::State.lookup(name: 'closed').id,
|
|
|
|
priority_id: Ticket::Priority.lookup(name: '2 normal').id,
|
2018-12-18 07:33:54 +00:00
|
|
|
updated_by_id: @agent_user1.id,
|
|
|
|
created_by_id: @agent_user1.id,
|
|
|
|
)
|
|
|
|
|
2016-02-21 11:43:16 +00:00
|
|
|
online_notification1 = OnlineNotification.add(
|
|
|
|
type: 'create',
|
|
|
|
object: 'Ticket',
|
2018-12-18 07:33:54 +00:00
|
|
|
o_id: ticket1.id,
|
2016-02-21 11:43:16 +00:00
|
|
|
seen: false,
|
2017-06-14 15:25:45 +00:00
|
|
|
user_id: @agent_user1.id,
|
2016-02-21 11:43:16 +00:00
|
|
|
created_by_id: 1,
|
|
|
|
updated_by_id: 1,
|
2016-02-24 07:05:03 +00:00
|
|
|
created_at: Time.zone.now - 10.months,
|
|
|
|
updated_at: Time.zone.now - 10.months,
|
2016-02-21 11:43:16 +00:00
|
|
|
)
|
|
|
|
online_notification2 = OnlineNotification.add(
|
|
|
|
type: 'create',
|
|
|
|
object: 'Ticket',
|
2018-12-18 07:33:54 +00:00
|
|
|
o_id: ticket1.id,
|
2016-02-21 11:43:16 +00:00
|
|
|
seen: true,
|
2017-06-14 15:25:45 +00:00
|
|
|
user_id: @agent_user1.id,
|
2016-02-21 11:43:16 +00:00
|
|
|
created_by_id: 1,
|
|
|
|
updated_by_id: 1,
|
2016-02-24 07:05:03 +00:00
|
|
|
created_at: Time.zone.now - 10.months,
|
|
|
|
updated_at: Time.zone.now - 10.months,
|
2016-02-21 11:43:16 +00:00
|
|
|
)
|
|
|
|
online_notification3 = OnlineNotification.add(
|
|
|
|
type: 'create',
|
|
|
|
object: 'Ticket',
|
2018-12-18 07:33:54 +00:00
|
|
|
o_id: ticket1.id,
|
2016-02-21 11:43:16 +00:00
|
|
|
seen: false,
|
2017-06-14 15:25:45 +00:00
|
|
|
user_id: @agent_user1.id,
|
2016-02-21 11:43:16 +00:00
|
|
|
created_by_id: 1,
|
|
|
|
updated_by_id: 1,
|
|
|
|
created_at: Time.zone.now - 2.days,
|
|
|
|
updated_at: Time.zone.now - 2.days,
|
|
|
|
)
|
|
|
|
online_notification4 = OnlineNotification.add(
|
|
|
|
type: 'create',
|
|
|
|
object: 'Ticket',
|
2018-12-18 07:33:54 +00:00
|
|
|
o_id: ticket1.id,
|
2016-02-21 11:43:16 +00:00
|
|
|
seen: true,
|
2017-06-14 15:25:45 +00:00
|
|
|
user_id: @agent_user1.id,
|
|
|
|
created_by_id: @agent_user1.id,
|
|
|
|
updated_by_id: @agent_user1.id,
|
2016-02-21 11:43:16 +00:00
|
|
|
created_at: Time.zone.now - 2.days,
|
|
|
|
updated_at: Time.zone.now - 2.days,
|
|
|
|
)
|
|
|
|
online_notification5 = OnlineNotification.add(
|
|
|
|
type: 'create',
|
|
|
|
object: 'Ticket',
|
2018-12-18 07:33:54 +00:00
|
|
|
o_id: ticket1.id,
|
2016-02-21 11:43:16 +00:00
|
|
|
seen: true,
|
2017-06-14 15:25:45 +00:00
|
|
|
user_id: @agent_user1.id,
|
|
|
|
created_by_id: @agent_user2.id,
|
|
|
|
updated_by_id: @agent_user2.id,
|
2016-02-21 11:43:16 +00:00
|
|
|
created_at: Time.zone.now - 2.days,
|
|
|
|
updated_at: Time.zone.now - 2.days,
|
|
|
|
)
|
|
|
|
online_notification6 = OnlineNotification.add(
|
|
|
|
type: 'create',
|
|
|
|
object: 'Ticket',
|
2018-12-18 07:33:54 +00:00
|
|
|
o_id: ticket1.id,
|
2016-02-21 11:43:16 +00:00
|
|
|
seen: true,
|
2017-06-14 15:25:45 +00:00
|
|
|
user_id: @agent_user1.id,
|
|
|
|
created_by_id: @agent_user1.id,
|
|
|
|
updated_by_id: @agent_user1.id,
|
2016-02-24 05:27:47 +00:00
|
|
|
created_at: Time.zone.now - 5.minutes,
|
|
|
|
updated_at: Time.zone.now - 5.minutes,
|
2016-02-21 11:43:16 +00:00
|
|
|
)
|
|
|
|
online_notification7 = OnlineNotification.add(
|
|
|
|
type: 'create',
|
|
|
|
object: 'Ticket',
|
2018-12-18 07:33:54 +00:00
|
|
|
o_id: ticket1.id,
|
2016-02-21 11:43:16 +00:00
|
|
|
seen: true,
|
2017-06-14 15:25:45 +00:00
|
|
|
user_id: @agent_user1.id,
|
|
|
|
created_by_id: @agent_user2.id,
|
|
|
|
updated_by_id: @agent_user2.id,
|
2016-02-24 05:27:47 +00:00
|
|
|
created_at: Time.zone.now - 5.minutes,
|
|
|
|
updated_at: Time.zone.now - 5.minutes,
|
2016-02-21 11:43:16 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
OnlineNotification.cleanup
|
|
|
|
|
2018-10-09 06:17:41 +00:00
|
|
|
assert_not(OnlineNotification.find_by(id: online_notification1.id))
|
|
|
|
assert_not(OnlineNotification.find_by(id: online_notification2.id))
|
2016-02-21 11:43:16 +00:00
|
|
|
assert(OnlineNotification.find_by(id: online_notification3.id))
|
2018-10-09 06:17:41 +00:00
|
|
|
assert_not(OnlineNotification.find_by(id: online_notification4.id))
|
|
|
|
assert_not(OnlineNotification.find_by(id: online_notification5.id))
|
2016-02-21 11:43:16 +00:00
|
|
|
assert(OnlineNotification.find_by(id: online_notification6.id))
|
|
|
|
assert(OnlineNotification.find_by(id: online_notification7.id))
|
2016-02-21 11:54:27 +00:00
|
|
|
OnlineNotification.destroy_all
|
2016-02-21 11:43:16 +00:00
|
|
|
end
|
|
|
|
|
2018-12-18 07:33:54 +00:00
|
|
|
test 'not existing object ref' do
|
|
|
|
assert_raises(RuntimeError) do
|
|
|
|
OnlineNotification.add(
|
|
|
|
type: 'create',
|
|
|
|
object: 'TicketNotExisting',
|
|
|
|
o_id: 123,
|
|
|
|
seen: false,
|
|
|
|
user_id: @agent_user1.id,
|
|
|
|
created_by_id: 1,
|
|
|
|
updated_by_id: 1,
|
|
|
|
created_at: Time.zone.now - 10.months,
|
|
|
|
updated_at: Time.zone.now - 10.months,
|
|
|
|
)
|
|
|
|
end
|
|
|
|
assert_raises(ActiveRecord::RecordNotFound) do
|
|
|
|
OnlineNotification.add(
|
|
|
|
type: 'create',
|
|
|
|
object: 'Ticket',
|
|
|
|
o_id: 123,
|
|
|
|
seen: false,
|
|
|
|
user_id: @agent_user1.id,
|
|
|
|
created_by_id: 1,
|
|
|
|
updated_by_id: 1,
|
|
|
|
created_at: Time.zone.now - 10.months,
|
|
|
|
updated_at: Time.zone.now - 10.months,
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
2015-04-27 14:15:29 +00:00
|
|
|
end
|