2021-06-01 12:20:20 +00:00
|
|
|
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
|
|
|
|
|
2016-03-14 15:05:52 +00:00
|
|
|
require 'test_helper'
|
|
|
|
|
|
|
|
class TicketOverviewTest < ActiveSupport::TestCase
|
2017-06-14 15:25:45 +00:00
|
|
|
|
2021-07-09 13:05:05 +00:00
|
|
|
setup do
|
2016-06-20 08:55:45 +00:00
|
|
|
group = Group.create_or_update(
|
2018-12-19 17:31:51 +00:00
|
|
|
name: 'OverviewTest',
|
|
|
|
updated_at: '2015-02-05 16:37: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
|
|
|
roles = Role.where(name: 'Agent')
|
|
|
|
@agent1 = User.create_or_update(
|
2018-12-19 17:31:51 +00:00
|
|
|
login: 'ticket-overview-agent1@example.com',
|
|
|
|
firstname: 'Overview',
|
|
|
|
lastname: 'Agent1',
|
|
|
|
email: 'ticket-overview-agent1@example.com',
|
|
|
|
password: 'agentpw',
|
|
|
|
active: true,
|
|
|
|
roles: roles,
|
|
|
|
groups: [group],
|
|
|
|
updated_at: '2015-02-05 16:37: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-overview-agent2@example.com',
|
|
|
|
firstname: 'Overview',
|
|
|
|
lastname: 'Agent2',
|
|
|
|
email: 'ticket-overview-agent2@example.com',
|
|
|
|
password: 'agentpw',
|
|
|
|
active: true,
|
|
|
|
roles: roles,
|
2016-06-20 08:55:45 +00:00
|
|
|
#groups: groups,
|
2018-12-19 17:31:51 +00:00
|
|
|
updated_at: '2015-02-05 16:38:00',
|
2016-06-20 08:55:45 +00:00
|
|
|
updated_by_id: 1,
|
|
|
|
created_by_id: 1,
|
|
|
|
)
|
|
|
|
roles = Role.where(name: 'Customer')
|
|
|
|
organization1 = Organization.create_or_update(
|
2018-12-19 17:31:51 +00:00
|
|
|
name: 'Overview Org',
|
|
|
|
updated_at: '2015-02-05 16:37: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
|
|
|
@customer1 = User.create_or_update(
|
2018-12-19 17:31:51 +00:00
|
|
|
login: 'ticket-overview-customer1@example.com',
|
|
|
|
firstname: 'Overview',
|
|
|
|
lastname: 'Customer1',
|
|
|
|
email: 'ticket-overview-customer1@example.com',
|
|
|
|
password: 'customerpw',
|
|
|
|
active: true,
|
2016-06-20 08:55:45 +00:00
|
|
|
organization_id: organization1.id,
|
2018-12-19 17:31:51 +00:00
|
|
|
roles: roles,
|
|
|
|
updated_at: '2015-02-05 16:37:00',
|
|
|
|
updated_by_id: 1,
|
|
|
|
created_by_id: 1,
|
2016-06-20 08:55:45 +00:00
|
|
|
)
|
2017-06-14 15:25:45 +00:00
|
|
|
@customer2 = User.create_or_update(
|
2018-12-19 17:31:51 +00:00
|
|
|
login: 'ticket-overview-customer2@example.com',
|
|
|
|
firstname: 'Overview',
|
|
|
|
lastname: 'Customer2',
|
|
|
|
email: 'ticket-overview-customer2@example.com',
|
|
|
|
password: 'customerpw',
|
|
|
|
active: true,
|
2016-06-20 08:55:45 +00:00
|
|
|
organization_id: organization1.id,
|
2018-12-19 17:31:51 +00:00
|
|
|
roles: roles,
|
|
|
|
updated_at: '2015-02-05 16:37:00',
|
|
|
|
updated_by_id: 1,
|
|
|
|
created_by_id: 1,
|
2016-06-20 08:55:45 +00:00
|
|
|
)
|
2017-06-14 15:25:45 +00:00
|
|
|
@customer3 = User.create_or_update(
|
2018-12-19 17:31:51 +00:00
|
|
|
login: 'ticket-overview-customer3@example.com',
|
|
|
|
firstname: 'Overview',
|
|
|
|
lastname: 'Customer3',
|
|
|
|
email: 'ticket-overview-customer3@example.com',
|
|
|
|
password: 'customerpw',
|
|
|
|
active: true,
|
2016-06-20 08:55:45 +00:00
|
|
|
organization_id: nil,
|
2018-12-19 17:31:51 +00:00
|
|
|
roles: roles,
|
|
|
|
updated_at: '2015-02-05 16:37:00',
|
|
|
|
updated_by_id: 1,
|
|
|
|
created_by_id: 1,
|
2016-06-20 08:55:45 +00:00
|
|
|
)
|
|
|
|
Overview.destroy_all
|
|
|
|
UserInfo.current_user_id = 1
|
|
|
|
overview_role = Role.find_by(name: 'Agent')
|
2017-06-14 15:25:45 +00:00
|
|
|
@overview1 = Overview.create_or_update(
|
2018-12-19 17:31:51 +00:00
|
|
|
name: 'My assigned Tickets',
|
|
|
|
link: 'my_assigned',
|
|
|
|
prio: 1000,
|
|
|
|
role_ids: [overview_role.id],
|
2016-06-20 08:55:45 +00:00
|
|
|
condition: {
|
|
|
|
'ticket.state_id' => {
|
|
|
|
operator: 'is',
|
2018-12-19 17:31:51 +00:00
|
|
|
value: [1, 2, 3, 7],
|
2016-06-20 08:55:45 +00:00
|
|
|
},
|
|
|
|
'ticket.owner_id' => {
|
2018-12-19 17:31:51 +00:00
|
|
|
operator: 'is',
|
2016-06-20 08:55:45 +00:00
|
|
|
pre_condition: 'current_user.id',
|
|
|
|
},
|
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
order: {
|
|
|
|
by: 'created_at',
|
2016-06-20 08:55:45 +00:00
|
|
|
direction: 'ASC',
|
2016-03-14 15:05:52 +00:00
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
view: {
|
|
|
|
d: %w[title customer group created_at],
|
|
|
|
s: %w[title customer group created_at],
|
|
|
|
m: %w[number title customer group created_at],
|
2016-06-20 08:55:45 +00:00
|
|
|
view_mode_default: 's',
|
2016-03-14 15:05:52 +00:00
|
|
|
},
|
2016-06-20 08:55:45 +00:00
|
|
|
)
|
2016-03-14 15:05:52 +00:00
|
|
|
|
2017-06-14 15:25:45 +00:00
|
|
|
@overview2 = Overview.create_or_update(
|
2018-12-19 17:31:51 +00:00
|
|
|
name: 'Unassigned & Open',
|
|
|
|
link: 'all_unassigned',
|
|
|
|
prio: 1010,
|
|
|
|
role_ids: [overview_role.id],
|
2016-06-20 08:55:45 +00:00
|
|
|
condition: {
|
|
|
|
'ticket.state_id' => {
|
|
|
|
operator: 'is',
|
2018-12-19 17:31:51 +00:00
|
|
|
value: [1, 2, 3],
|
2016-06-20 08:55:45 +00:00
|
|
|
},
|
|
|
|
'ticket.owner_id' => {
|
|
|
|
operator: 'is',
|
2018-12-19 17:31:51 +00:00
|
|
|
value: 1,
|
2016-06-20 08:55:45 +00:00
|
|
|
},
|
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
order: {
|
|
|
|
by: 'created_at',
|
2016-06-20 08:55:45 +00:00
|
|
|
direction: 'ASC',
|
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
view: {
|
|
|
|
d: %w[title customer group created_at],
|
|
|
|
s: %w[title customer group created_at],
|
|
|
|
m: %w[number title customer group created_at],
|
2016-06-20 08:55:45 +00:00
|
|
|
view_mode_default: 's',
|
2016-03-14 15:05:52 +00:00
|
|
|
},
|
2016-06-20 08:55:45 +00:00
|
|
|
)
|
2017-06-14 15:25:45 +00:00
|
|
|
@overview3 = Overview.create_or_update(
|
2018-12-19 17:31:51 +00:00
|
|
|
name: 'My Tickets 2',
|
|
|
|
link: 'my_tickets_2',
|
|
|
|
prio: 1020,
|
|
|
|
role_ids: [overview_role.id],
|
|
|
|
user_ids: [@agent2.id],
|
2016-06-20 08:55:45 +00:00
|
|
|
condition: {
|
|
|
|
'ticket.state_id' => {
|
|
|
|
operator: 'is',
|
2018-12-19 17:31:51 +00:00
|
|
|
value: [1, 2, 3, 7],
|
2016-06-20 08:55:45 +00:00
|
|
|
},
|
|
|
|
'ticket.owner_id' => {
|
2018-12-19 17:31:51 +00:00
|
|
|
operator: 'is',
|
2016-06-20 08:55:45 +00:00
|
|
|
pre_condition: 'current_user.id',
|
|
|
|
},
|
2016-03-14 15:05:52 +00:00
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
order: {
|
|
|
|
by: 'created_at',
|
2016-06-20 08:55:45 +00:00
|
|
|
direction: 'ASC',
|
2016-03-14 15:05:52 +00:00
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
view: {
|
|
|
|
d: %w[title customer group created_at],
|
|
|
|
s: %w[title customer group created_at],
|
|
|
|
m: %w[number title customer group created_at],
|
2016-06-20 08:55:45 +00:00
|
|
|
view_mode_default: 's',
|
2016-03-14 15:05:52 +00:00
|
|
|
},
|
2016-06-20 08:55:45 +00:00
|
|
|
)
|
2017-06-14 15:25:45 +00:00
|
|
|
@overview4 = Overview.create_or_update(
|
2018-12-19 17:31:51 +00:00
|
|
|
name: 'My Tickets only with Note',
|
|
|
|
link: 'my_tickets_onyl_with_note',
|
|
|
|
prio: 1030,
|
|
|
|
role_ids: [overview_role.id],
|
|
|
|
user_ids: [@agent1.id],
|
2016-11-21 14:59:31 +00:00
|
|
|
condition: {
|
|
|
|
'article.type_id' => {
|
|
|
|
operator: 'is',
|
2018-12-19 17:31:51 +00:00
|
|
|
value: Ticket::Article::Type.find_by(name: 'note').id,
|
2016-11-21 14:59:31 +00:00
|
|
|
},
|
|
|
|
'ticket.owner_id' => {
|
2018-12-19 17:31:51 +00:00
|
|
|
operator: 'is',
|
2016-11-21 14:59:31 +00:00
|
|
|
pre_condition: 'current_user.id',
|
|
|
|
},
|
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
order: {
|
|
|
|
by: 'created_at',
|
2016-11-21 14:59:31 +00:00
|
|
|
direction: 'ASC',
|
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
view: {
|
|
|
|
d: %w[title customer group created_at],
|
|
|
|
s: %w[title customer group created_at],
|
|
|
|
m: %w[number title customer group created_at],
|
2016-11-21 14:59:31 +00:00
|
|
|
view_mode_default: 's',
|
|
|
|
},
|
|
|
|
)
|
2016-03-14 15:05:52 +00:00
|
|
|
|
2016-06-20 08:55:45 +00:00
|
|
|
overview_role = Role.find_by(name: 'Customer')
|
2017-06-14 15:25:45 +00:00
|
|
|
@overview5 = Overview.create_or_update(
|
2018-12-19 17:31:51 +00:00
|
|
|
name: 'My Tickets',
|
|
|
|
link: 'my_tickets',
|
|
|
|
prio: 1100,
|
|
|
|
role_ids: [overview_role.id],
|
2016-06-20 08:55:45 +00:00
|
|
|
condition: {
|
2018-12-19 17:31:51 +00:00
|
|
|
'ticket.state_id' => {
|
2016-06-20 08:55:45 +00:00
|
|
|
operator: 'is',
|
2018-12-19 17:31:51 +00:00
|
|
|
value: [1, 2, 3, 4, 6, 7],
|
2016-06-20 08:55:45 +00:00
|
|
|
},
|
|
|
|
'ticket.customer_id' => {
|
2018-12-19 17:31:51 +00:00
|
|
|
operator: 'is',
|
2016-06-20 08:55:45 +00:00
|
|
|
pre_condition: 'current_user.id',
|
|
|
|
},
|
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
order: {
|
|
|
|
by: 'created_at',
|
2016-06-20 08:55:45 +00:00
|
|
|
direction: 'DESC',
|
2016-03-14 15:05:52 +00:00
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
view: {
|
|
|
|
d: %w[title customer state created_at],
|
|
|
|
s: %w[number title state created_at],
|
|
|
|
m: %w[number title state created_at],
|
2016-06-20 08:55:45 +00:00
|
|
|
view_mode_default: 's',
|
2016-03-14 15:05:52 +00:00
|
|
|
},
|
2016-06-20 08:55:45 +00:00
|
|
|
)
|
2017-06-14 15:25:45 +00:00
|
|
|
@overview6 = Overview.create_or_update(
|
2018-12-19 17:31:51 +00:00
|
|
|
name: 'My Organization Tickets',
|
|
|
|
link: 'my_organization_tickets',
|
|
|
|
prio: 1200,
|
|
|
|
role_ids: [overview_role.id],
|
2016-06-20 08:55:45 +00:00
|
|
|
organization_shared: true,
|
2018-12-19 17:31:51 +00:00
|
|
|
condition: {
|
|
|
|
'ticket.state_id' => {
|
2016-06-20 08:55:45 +00:00
|
|
|
operator: 'is',
|
2018-12-19 17:31:51 +00:00
|
|
|
value: [1, 2, 3, 4, 6, 7],
|
2016-06-20 08:55:45 +00:00
|
|
|
},
|
|
|
|
'ticket.organization_id' => {
|
2018-12-19 17:31:51 +00:00
|
|
|
operator: 'is',
|
2016-06-20 08:55:45 +00:00
|
|
|
pre_condition: 'current_user.organization_id',
|
|
|
|
},
|
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
order: {
|
|
|
|
by: 'created_at',
|
2016-06-20 08:55:45 +00:00
|
|
|
direction: 'DESC',
|
2016-03-14 15:05:52 +00:00
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
view: {
|
|
|
|
d: %w[title customer state created_at],
|
|
|
|
s: %w[number title customer state created_at],
|
|
|
|
m: %w[number title customer state created_at],
|
2016-06-20 08:55:45 +00:00
|
|
|
view_mode_default: 's',
|
2016-03-14 15:05:52 +00:00
|
|
|
},
|
2016-06-20 08:55:45 +00:00
|
|
|
)
|
2017-06-14 15:25:45 +00:00
|
|
|
@overview7 = Overview.create_or_update(
|
2018-12-19 17:31:51 +00:00
|
|
|
name: 'My Organization Tickets (open)',
|
|
|
|
link: 'my_organization_tickets_open',
|
|
|
|
prio: 1200,
|
|
|
|
role_ids: [overview_role.id],
|
|
|
|
user_ids: [@customer2.id],
|
2016-06-20 08:55:45 +00:00
|
|
|
organization_shared: true,
|
2018-12-19 17:31:51 +00:00
|
|
|
condition: {
|
|
|
|
'ticket.state_id' => {
|
2016-06-20 08:55:45 +00:00
|
|
|
operator: 'is',
|
2018-12-19 17:31:51 +00:00
|
|
|
value: [1, 2, 3],
|
2016-06-20 08:55:45 +00:00
|
|
|
},
|
|
|
|
'ticket.organization_id' => {
|
2018-12-19 17:31:51 +00:00
|
|
|
operator: 'is',
|
2016-06-20 08:55:45 +00:00
|
|
|
pre_condition: 'current_user.organization_id',
|
|
|
|
},
|
2016-03-14 15:05:52 +00:00
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
order: {
|
|
|
|
by: 'created_at',
|
2016-06-20 08:55:45 +00:00
|
|
|
direction: 'DESC',
|
2016-03-14 15:05:52 +00:00
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
view: {
|
|
|
|
d: %w[title customer state created_at],
|
|
|
|
s: %w[number title customer state created_at],
|
|
|
|
m: %w[number title customer state created_at],
|
2016-06-20 08:55:45 +00:00
|
|
|
view_mode_default: 's',
|
|
|
|
},
|
|
|
|
)
|
2016-03-14 15:05:52 +00:00
|
|
|
|
2016-06-20 08:55:45 +00:00
|
|
|
overview_role = Role.find_by(name: 'Admin')
|
2017-06-14 15:25:45 +00:00
|
|
|
@overview8 = Overview.create_or_update(
|
2018-12-19 17:31:51 +00:00
|
|
|
name: 'Not Shown Admin',
|
|
|
|
link: 'not_shown_admin',
|
|
|
|
prio: 9900,
|
|
|
|
role_ids: [overview_role.id],
|
2016-06-20 08:55:45 +00:00
|
|
|
condition: {
|
|
|
|
'ticket.state_id' => {
|
|
|
|
operator: 'is',
|
2018-12-19 17:31:51 +00:00
|
|
|
value: [1, 2, 3],
|
2016-06-20 08:55:45 +00:00
|
|
|
},
|
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
order: {
|
|
|
|
by: 'created_at',
|
2016-06-20 08:55:45 +00:00
|
|
|
direction: 'DESC',
|
2016-03-14 15:05:52 +00:00
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
view: {
|
|
|
|
d: %w[title customer state created_at],
|
|
|
|
s: %w[number title customer state created_at],
|
|
|
|
m: %w[number title customer state created_at],
|
2016-06-20 08:55:45 +00:00
|
|
|
view_mode_default: 's',
|
|
|
|
},
|
|
|
|
)
|
|
|
|
end
|
2016-03-14 15:05:52 +00:00
|
|
|
|
2018-01-09 07:39:50 +00:00
|
|
|
test 'overview index' do
|
2016-03-14 15:05:52 +00:00
|
|
|
|
|
|
|
result = Ticket::Overviews.all(
|
2017-06-14 15:25:45 +00:00
|
|
|
current_user: @agent1,
|
2016-03-14 15:05:52 +00:00
|
|
|
)
|
2018-01-09 07:39:50 +00:00
|
|
|
|
2016-11-21 14:59:31 +00:00
|
|
|
assert_equal(3, result.count)
|
2016-03-14 15:05:52 +00:00
|
|
|
assert_equal('My assigned Tickets', result[0].name)
|
|
|
|
assert_equal('Unassigned & Open', result[1].name)
|
2016-11-21 14:59:31 +00:00
|
|
|
assert_equal('My Tickets only with Note', result[2].name)
|
2016-03-14 15:05:52 +00:00
|
|
|
|
|
|
|
result = Ticket::Overviews.all(
|
2017-06-14 15:25:45 +00:00
|
|
|
current_user: @agent2,
|
2016-03-14 15:05:52 +00:00
|
|
|
)
|
|
|
|
assert_equal(3, result.count)
|
|
|
|
assert_equal('My assigned Tickets', result[0].name)
|
|
|
|
assert_equal('Unassigned & Open', result[1].name)
|
|
|
|
assert_equal('My Tickets 2', result[2].name)
|
|
|
|
|
|
|
|
result = Ticket::Overviews.all(
|
2017-06-14 15:25:45 +00:00
|
|
|
current_user: @customer1,
|
2016-03-14 15:05:52 +00:00
|
|
|
)
|
|
|
|
assert_equal(2, result.count)
|
|
|
|
assert_equal('My Tickets', result[0].name)
|
|
|
|
assert_equal('My Organization Tickets', result[1].name)
|
|
|
|
|
|
|
|
result = Ticket::Overviews.all(
|
2017-06-14 15:25:45 +00:00
|
|
|
current_user: @customer2,
|
2016-03-14 15:05:52 +00:00
|
|
|
)
|
|
|
|
assert_equal(3, result.count)
|
|
|
|
assert_equal('My Tickets', result[0].name)
|
|
|
|
assert_equal('My Organization Tickets', result[1].name)
|
|
|
|
assert_equal('My Organization Tickets (open)', result[2].name)
|
|
|
|
|
|
|
|
result = Ticket::Overviews.all(
|
2017-06-14 15:25:45 +00:00
|
|
|
current_user: @customer3,
|
2016-03-14 15:05:52 +00:00
|
|
|
)
|
|
|
|
assert_equal(1, result.count)
|
|
|
|
assert_equal('My Tickets', result[0].name)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2018-01-09 07:39:50 +00:00
|
|
|
test 'missing role' do
|
|
|
|
Ticket.destroy_all
|
|
|
|
|
|
|
|
assert_raises(Exception) do
|
|
|
|
Overview.create!(
|
2018-12-19 17:31:51 +00:00
|
|
|
name: 'new overview',
|
|
|
|
link: 'new_overview',
|
|
|
|
prio: 1200,
|
|
|
|
user_ids: [@customer2.id],
|
2018-01-09 07:39:50 +00:00
|
|
|
organization_shared: true,
|
2018-12-19 17:31:51 +00:00
|
|
|
condition: {
|
|
|
|
'ticket.state_id' => {
|
2018-01-09 07:39:50 +00:00
|
|
|
operator: 'is',
|
2018-12-19 17:31:51 +00:00
|
|
|
value: [1, 2, 3],
|
2018-01-09 07:39:50 +00:00
|
|
|
},
|
|
|
|
'ticket.organization_id' => {
|
2018-12-19 17:31:51 +00:00
|
|
|
operator: 'is',
|
2018-01-09 07:39:50 +00:00
|
|
|
pre_condition: 'current_user.organization_id',
|
|
|
|
},
|
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
order: {
|
|
|
|
by: 'created_at',
|
2018-01-09 07:39:50 +00:00
|
|
|
direction: 'DESC',
|
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
view: {
|
|
|
|
d: %w[title customer state created_at],
|
|
|
|
s: %w[number title customer state created_at],
|
|
|
|
m: %w[number title customer state created_at],
|
2018-01-09 07:39:50 +00:00
|
|
|
view_mode_default: 's',
|
|
|
|
},
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
test 'overview content' do
|
2016-11-21 14:59:31 +00:00
|
|
|
|
|
|
|
Ticket.destroy_all
|
|
|
|
|
2017-06-14 15:25:45 +00:00
|
|
|
result = Ticket::Overviews.index(@agent1)
|
2016-11-21 14:59:31 +00:00
|
|
|
assert_equal(result[0][:overview][:name], 'My assigned Tickets')
|
|
|
|
assert_equal(result[0][:overview][:view], 'my_assigned')
|
|
|
|
assert_equal(result[0][:count], 0)
|
|
|
|
assert_equal(result[0][:tickets].class, Array)
|
2017-09-11 00:50:05 +00:00
|
|
|
assert(result[0][:tickets].blank?)
|
2016-11-21 14:59:31 +00:00
|
|
|
assert_equal(result[1][:overview][:name], 'Unassigned & Open')
|
|
|
|
assert_equal(result[1][:overview][:view], 'all_unassigned')
|
|
|
|
assert_equal(result[1][:tickets].class, Array)
|
2017-09-11 00:50:05 +00:00
|
|
|
assert(result[1][:tickets].blank?)
|
2016-11-21 14:59:31 +00:00
|
|
|
assert_equal(result[1][:count], 0)
|
|
|
|
assert_equal(result[2][:overview][:name], 'My Tickets only with Note')
|
|
|
|
assert_equal(result[2][:overview][:view], 'my_tickets_onyl_with_note')
|
|
|
|
assert_equal(result[2][:tickets].class, Array)
|
2017-09-11 00:50:05 +00:00
|
|
|
assert(result[2][:tickets].blank?)
|
2016-11-21 14:59:31 +00:00
|
|
|
assert_equal(result[2][:count], 0)
|
|
|
|
|
2017-06-14 15:25:45 +00:00
|
|
|
result = Ticket::Overviews.index(@agent2)
|
2016-11-21 14:59:31 +00:00
|
|
|
assert_equal(result[0][:overview][:name], 'My assigned Tickets')
|
|
|
|
assert_equal(result[0][:overview][:view], 'my_assigned')
|
|
|
|
assert_equal(result[0][:count], 0)
|
|
|
|
assert_equal(result[0][:tickets].class, Array)
|
2017-09-11 00:50:05 +00:00
|
|
|
assert(result[0][:tickets].blank?)
|
2016-11-21 14:59:31 +00:00
|
|
|
assert_equal(result[1][:overview][:name], 'Unassigned & Open')
|
|
|
|
assert_equal(result[1][:overview][:view], 'all_unassigned')
|
|
|
|
assert_equal(result[1][:tickets].class, Array)
|
2017-09-11 00:50:05 +00:00
|
|
|
assert(result[1][:tickets].blank?)
|
2016-11-21 14:59:31 +00:00
|
|
|
assert_equal(result[1][:count], 0)
|
|
|
|
assert_equal(result[2][:overview][:name], 'My Tickets 2')
|
|
|
|
assert_equal(result[2][:overview][:view], 'my_tickets_2')
|
|
|
|
assert_equal(result[2][:tickets].class, Array)
|
2017-09-11 00:50:05 +00:00
|
|
|
assert(result[2][:tickets].blank?)
|
2016-11-21 14:59:31 +00:00
|
|
|
|
2017-06-14 15:25:45 +00:00
|
|
|
ticket1 = Ticket.create!(
|
2018-12-19 17:31:51 +00:00
|
|
|
title: 'overview test 1',
|
|
|
|
group: Group.lookup(name: 'OverviewTest'),
|
|
|
|
customer_id: 2,
|
|
|
|
state: Ticket::State.lookup(name: 'new'),
|
|
|
|
priority: Ticket::Priority.lookup(name: '2 normal'),
|
2016-11-21 14:59:31 +00:00
|
|
|
updated_by_id: 1,
|
|
|
|
created_by_id: 1,
|
|
|
|
)
|
2019-06-28 11:38:49 +00:00
|
|
|
Ticket::Article.create!(
|
2018-12-19 17:31:51 +00:00
|
|
|
ticket_id: ticket1.id,
|
|
|
|
from: 'some_sender@example.com',
|
|
|
|
to: 'some_recipient@example.com',
|
|
|
|
subject: 'some subject',
|
|
|
|
message_id: 'some@id',
|
|
|
|
body: 'some message... 123',
|
|
|
|
internal: false,
|
|
|
|
sender: Ticket::Article::Sender.find_by(name: 'Customer'),
|
|
|
|
type: Ticket::Article::Type.find_by(name: 'email'),
|
2016-11-21 14:59:31 +00:00
|
|
|
updated_by_id: 1,
|
|
|
|
created_by_id: 1,
|
|
|
|
)
|
|
|
|
|
2017-06-14 15:25:45 +00:00
|
|
|
result = Ticket::Overviews.index(@agent1)
|
2016-11-21 14:59:31 +00:00
|
|
|
assert_equal(result[0][:overview][:name], 'My assigned Tickets')
|
|
|
|
assert_equal(result[0][:overview][:view], 'my_assigned')
|
|
|
|
assert_equal(result[0][:count], 0)
|
|
|
|
assert_equal(result[0][:tickets].class, Array)
|
2017-09-11 00:50:05 +00:00
|
|
|
assert(result[0][:tickets].blank?)
|
2016-11-21 14:59:31 +00:00
|
|
|
assert_equal(result[1][:overview][:name], 'Unassigned & Open')
|
|
|
|
assert_equal(result[1][:overview][:view], 'all_unassigned')
|
|
|
|
assert_equal(result[1][:tickets].class, Array)
|
2017-09-11 00:50:05 +00:00
|
|
|
assert_not(result[1][:tickets].blank?)
|
2016-11-21 14:59:31 +00:00
|
|
|
assert_equal(result[1][:tickets][0][:id], ticket1.id)
|
|
|
|
assert_equal(result[1][:count], 1)
|
|
|
|
assert_equal(result[2][:overview][:name], 'My Tickets only with Note')
|
|
|
|
assert_equal(result[2][:overview][:view], 'my_tickets_onyl_with_note')
|
|
|
|
assert_equal(result[2][:tickets].class, Array)
|
2017-09-11 00:50:05 +00:00
|
|
|
assert(result[2][:tickets].blank?)
|
2016-11-21 14:59:31 +00:00
|
|
|
assert_equal(result[2][:count], 0)
|
|
|
|
|
2017-06-14 15:25:45 +00:00
|
|
|
result = Ticket::Overviews.index(@agent2)
|
2016-11-21 14:59:31 +00:00
|
|
|
assert_equal(result[0][:overview][:name], 'My assigned Tickets')
|
|
|
|
assert_equal(result[0][:overview][:view], 'my_assigned')
|
|
|
|
assert_equal(result[0][:count], 0)
|
|
|
|
assert_equal(result[0][:tickets].class, Array)
|
2017-09-11 00:50:05 +00:00
|
|
|
assert(result[0][:tickets].blank?)
|
2016-11-21 14:59:31 +00:00
|
|
|
assert_equal(result[1][:overview][:name], 'Unassigned & Open')
|
|
|
|
assert_equal(result[1][:overview][:view], 'all_unassigned')
|
|
|
|
assert_equal(result[1][:tickets].class, Array)
|
2017-09-11 00:50:05 +00:00
|
|
|
assert(result[1][:tickets].blank?)
|
2016-11-21 14:59:31 +00:00
|
|
|
assert_equal(result[1][:count], 0)
|
|
|
|
assert_equal(result[2][:overview][:name], 'My Tickets 2')
|
|
|
|
assert_equal(result[2][:overview][:view], 'my_tickets_2')
|
|
|
|
assert_equal(result[2][:tickets].class, Array)
|
2017-09-11 00:50:05 +00:00
|
|
|
assert(result[2][:tickets].blank?)
|
2016-11-21 14:59:31 +00:00
|
|
|
|
2016-12-08 14:06:54 +00:00
|
|
|
travel 1.second # because of mysql millitime issues
|
2017-06-14 15:25:45 +00:00
|
|
|
ticket2 = Ticket.create!(
|
2018-12-19 17:31:51 +00:00
|
|
|
title: 'overview test 2',
|
|
|
|
group: Group.lookup(name: 'OverviewTest'),
|
|
|
|
customer_id: 2,
|
|
|
|
state: Ticket::State.lookup(name: 'new'),
|
|
|
|
priority: Ticket::Priority.lookup(name: '3 high'),
|
2016-11-21 14:59:31 +00:00
|
|
|
updated_by_id: 1,
|
|
|
|
created_by_id: 1,
|
|
|
|
)
|
2019-06-28 11:38:49 +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... 123',
|
|
|
|
internal: false,
|
|
|
|
sender: Ticket::Article::Sender.find_by(name: 'Agent'),
|
|
|
|
type: Ticket::Article::Type.find_by(name: 'note'),
|
2016-11-21 14:59:31 +00:00
|
|
|
updated_by_id: 1,
|
|
|
|
created_by_id: 1,
|
|
|
|
)
|
|
|
|
|
2017-06-14 15:25:45 +00:00
|
|
|
result = Ticket::Overviews.index(@agent1)
|
2016-11-21 14:59:31 +00:00
|
|
|
assert_equal(result[0][:overview][:name], 'My assigned Tickets')
|
|
|
|
assert_equal(result[0][:overview][:view], 'my_assigned')
|
|
|
|
assert_equal(result[0][:count], 0)
|
|
|
|
assert_equal(result[0][:tickets].class, Array)
|
2017-09-11 00:50:05 +00:00
|
|
|
assert(result[0][:tickets].blank?)
|
2016-11-21 14:59:31 +00:00
|
|
|
assert_equal(result[1][:overview][:name], 'Unassigned & Open')
|
|
|
|
assert_equal(result[1][:overview][:view], 'all_unassigned')
|
|
|
|
assert_equal(result[1][:tickets].class, Array)
|
2017-09-11 00:50:05 +00:00
|
|
|
assert_not(result[1][:tickets].blank?)
|
2016-11-21 14:59:31 +00:00
|
|
|
assert_equal(result[1][:tickets][0][:id], ticket1.id)
|
|
|
|
assert_equal(result[1][:tickets][1][:id], ticket2.id)
|
|
|
|
assert_equal(result[1][:count], 2)
|
|
|
|
assert_equal(result[2][:overview][:name], 'My Tickets only with Note')
|
|
|
|
assert_equal(result[2][:overview][:view], 'my_tickets_onyl_with_note')
|
|
|
|
assert_equal(result[2][:tickets].class, Array)
|
2017-09-11 00:50:05 +00:00
|
|
|
assert(result[2][:tickets].blank?)
|
2016-11-21 14:59:31 +00:00
|
|
|
assert_equal(result[2][:count], 0)
|
|
|
|
|
2017-06-14 15:25:45 +00:00
|
|
|
result = Ticket::Overviews.index(@agent2)
|
2016-11-21 14:59:31 +00:00
|
|
|
assert_equal(result[0][:overview][:name], 'My assigned Tickets')
|
|
|
|
assert_equal(result[0][:overview][:view], 'my_assigned')
|
|
|
|
assert_equal(result[0][:count], 0)
|
|
|
|
assert_equal(result[0][:tickets].class, Array)
|
2017-09-11 00:50:05 +00:00
|
|
|
assert(result[0][:tickets].blank?)
|
2016-11-21 14:59:31 +00:00
|
|
|
assert_equal(result[1][:overview][:name], 'Unassigned & Open')
|
|
|
|
assert_equal(result[1][:overview][:view], 'all_unassigned')
|
|
|
|
assert_equal(result[1][:tickets].class, Array)
|
2017-09-11 00:50:05 +00:00
|
|
|
assert(result[1][:tickets].blank?)
|
2016-11-21 14:59:31 +00:00
|
|
|
assert_equal(result[1][:count], 0)
|
|
|
|
assert_equal(result[2][:overview][:name], 'My Tickets 2')
|
|
|
|
assert_equal(result[2][:overview][:view], 'my_tickets_2')
|
|
|
|
assert_equal(result[2][:tickets].class, Array)
|
2017-09-11 00:50:05 +00:00
|
|
|
assert(result[2][:tickets].blank?)
|
2016-11-21 14:59:31 +00:00
|
|
|
|
2017-06-14 15:25:45 +00:00
|
|
|
ticket2.owner_id = @agent1.id
|
2016-11-21 14:59:31 +00:00
|
|
|
ticket2.save!
|
|
|
|
|
2017-06-14 15:25:45 +00:00
|
|
|
result = Ticket::Overviews.index(@agent1)
|
2016-11-21 14:59:31 +00:00
|
|
|
assert_equal(result[0][:overview][:name], 'My assigned Tickets')
|
|
|
|
assert_equal(result[0][:overview][:view], 'my_assigned')
|
|
|
|
assert_equal(result[0][:tickets].class, Array)
|
|
|
|
assert_equal(result[0][:tickets][0][:id], ticket2.id)
|
|
|
|
assert_equal(result[0][:count], 1)
|
|
|
|
assert_equal(result[0][:tickets].class, Array)
|
|
|
|
assert_equal(result[1][:overview][:name], 'Unassigned & Open')
|
|
|
|
assert_equal(result[1][:overview][:view], 'all_unassigned')
|
|
|
|
assert_equal(result[1][:tickets].class, Array)
|
2017-09-11 00:50:05 +00:00
|
|
|
assert_not(result[1][:tickets].blank?)
|
2016-11-21 14:59:31 +00:00
|
|
|
assert_equal(result[1][:tickets][0][:id], ticket1.id)
|
|
|
|
assert_equal(result[1][:count], 1)
|
|
|
|
assert_equal(result[2][:overview][:name], 'My Tickets only with Note')
|
|
|
|
assert_equal(result[2][:overview][:view], 'my_tickets_onyl_with_note')
|
|
|
|
assert_equal(result[2][:tickets].class, Array)
|
|
|
|
assert_equal(result[2][:tickets][0][:id], ticket2.id)
|
|
|
|
assert_equal(result[2][:count], 1)
|
|
|
|
|
2017-06-14 15:25:45 +00:00
|
|
|
result = Ticket::Overviews.index(@agent2)
|
2016-11-21 14:59:31 +00:00
|
|
|
assert_equal(result[0][:overview][:name], 'My assigned Tickets')
|
|
|
|
assert_equal(result[0][:overview][:view], 'my_assigned')
|
|
|
|
assert_equal(result[0][:count], 0)
|
|
|
|
assert_equal(result[0][:tickets].class, Array)
|
2017-09-11 00:50:05 +00:00
|
|
|
assert(result[0][:tickets].blank?)
|
2016-11-21 14:59:31 +00:00
|
|
|
assert_equal(result[1][:overview][:name], 'Unassigned & Open')
|
|
|
|
assert_equal(result[1][:overview][:view], 'all_unassigned')
|
|
|
|
assert_equal(result[1][:tickets].class, Array)
|
2017-09-11 00:50:05 +00:00
|
|
|
assert(result[1][:tickets].blank?)
|
2016-11-21 14:59:31 +00:00
|
|
|
assert_equal(result[1][:count], 0)
|
|
|
|
assert_equal(result[2][:overview][:name], 'My Tickets 2')
|
|
|
|
assert_equal(result[2][:overview][:view], 'my_tickets_2')
|
|
|
|
assert_equal(result[2][:tickets].class, Array)
|
2017-09-11 00:50:05 +00:00
|
|
|
assert(result[2][:tickets].blank?)
|
2016-11-21 14:59:31 +00:00
|
|
|
|
2016-12-08 14:06:54 +00:00
|
|
|
travel 1.second # because of mysql millitime issues
|
2017-06-14 15:25:45 +00:00
|
|
|
ticket3 = Ticket.create!(
|
2018-12-19 17:31:51 +00:00
|
|
|
title: 'overview test 3',
|
|
|
|
group: Group.lookup(name: 'OverviewTest'),
|
|
|
|
customer_id: 2,
|
|
|
|
state: Ticket::State.lookup(name: 'new'),
|
|
|
|
priority: Ticket::Priority.lookup(name: '1 low'),
|
2016-11-21 14:59:31 +00:00
|
|
|
updated_by_id: 1,
|
|
|
|
created_by_id: 1,
|
|
|
|
)
|
2019-06-28 11:38:49 +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... 123',
|
|
|
|
internal: false,
|
|
|
|
sender: Ticket::Article::Sender.find_by(name: 'Customer'),
|
|
|
|
type: Ticket::Article::Type.find_by(name: 'email'),
|
2016-11-21 14:59:31 +00:00
|
|
|
updated_by_id: 1,
|
|
|
|
created_by_id: 1,
|
|
|
|
)
|
2016-12-02 11:24:00 +00:00
|
|
|
travel_back
|
2016-11-21 14:59:31 +00:00
|
|
|
|
2017-06-14 15:25:45 +00:00
|
|
|
result = Ticket::Overviews.index(@agent1)
|
|
|
|
assert_equal(result[0][:overview][:id], @overview1.id)
|
2016-11-21 14:59:31 +00:00
|
|
|
assert_equal(result[0][:overview][:name], 'My assigned Tickets')
|
|
|
|
assert_equal(result[0][:overview][:view], 'my_assigned')
|
|
|
|
assert_equal(result[0][:tickets].class, Array)
|
|
|
|
assert_equal(result[0][:tickets][0][:id], ticket2.id)
|
|
|
|
assert_equal(result[0][:count], 1)
|
|
|
|
assert_equal(result[0][:tickets].class, Array)
|
2017-06-14 15:25:45 +00:00
|
|
|
assert_equal(result[1][:overview][:id], @overview2.id)
|
2016-11-21 14:59:31 +00:00
|
|
|
assert_equal(result[1][:overview][:name], 'Unassigned & Open')
|
|
|
|
assert_equal(result[1][:overview][:view], 'all_unassigned')
|
|
|
|
assert_equal(result[1][:tickets].class, Array)
|
2017-09-11 00:50:05 +00:00
|
|
|
assert_not(result[1][:tickets].blank?)
|
2016-11-21 14:59:31 +00:00
|
|
|
assert_equal(result[1][:tickets][0][:id], ticket1.id)
|
|
|
|
assert_equal(result[1][:tickets][1][:id], ticket3.id)
|
|
|
|
assert_equal(result[1][:count], 2)
|
2017-06-14 15:25:45 +00:00
|
|
|
assert_equal(result[2][:overview][:id], @overview4.id)
|
2016-11-21 14:59:31 +00:00
|
|
|
assert_equal(result[2][:overview][:name], 'My Tickets only with Note')
|
|
|
|
assert_equal(result[2][:overview][:view], 'my_tickets_onyl_with_note')
|
|
|
|
assert_equal(result[2][:tickets].class, Array)
|
|
|
|
assert_equal(result[2][:tickets][0][:id], ticket2.id)
|
|
|
|
assert_equal(result[2][:count], 1)
|
|
|
|
|
2017-06-14 15:25:45 +00:00
|
|
|
result = Ticket::Overviews.index(@agent2)
|
|
|
|
assert_equal(result[0][:overview][:id], @overview1.id)
|
2016-11-21 14:59:31 +00:00
|
|
|
assert_equal(result[0][:overview][:name], 'My assigned Tickets')
|
|
|
|
assert_equal(result[0][:overview][:view], 'my_assigned')
|
|
|
|
assert_equal(result[0][:count], 0)
|
|
|
|
assert_equal(result[0][:tickets].class, Array)
|
2017-09-11 00:50:05 +00:00
|
|
|
assert(result[0][:tickets].blank?)
|
2017-06-14 15:25:45 +00:00
|
|
|
assert_equal(result[1][:overview][:id], @overview2.id)
|
2016-11-21 14:59:31 +00:00
|
|
|
assert_equal(result[1][:overview][:name], 'Unassigned & Open')
|
|
|
|
assert_equal(result[1][:overview][:view], 'all_unassigned')
|
|
|
|
assert_equal(result[1][:tickets].class, Array)
|
2017-09-11 00:50:05 +00:00
|
|
|
assert(result[1][:tickets].blank?)
|
2016-11-21 14:59:31 +00:00
|
|
|
assert_equal(result[1][:count], 0)
|
2017-06-14 15:25:45 +00:00
|
|
|
assert_equal(result[2][:overview][:id], @overview3.id)
|
2016-11-21 14:59:31 +00:00
|
|
|
assert_equal(result[2][:overview][:name], 'My Tickets 2')
|
|
|
|
assert_equal(result[2][:overview][:view], 'my_tickets_2')
|
|
|
|
assert_equal(result[2][:tickets].class, Array)
|
2017-09-11 00:50:05 +00:00
|
|
|
assert(result[2][:tickets].blank?)
|
2016-11-21 14:59:31 +00:00
|
|
|
|
2017-06-14 15:25:45 +00:00
|
|
|
@overview2.order = {
|
2018-12-19 17:31:51 +00:00
|
|
|
by: 'created_at',
|
2016-11-21 14:59:31 +00:00
|
|
|
direction: 'DESC',
|
|
|
|
}
|
2017-06-14 15:25:45 +00:00
|
|
|
@overview2.save!
|
2016-11-21 14:59:31 +00:00
|
|
|
|
2017-06-14 15:25:45 +00:00
|
|
|
result = Ticket::Overviews.index(@agent1)
|
|
|
|
assert_equal(result[0][:overview][:id], @overview1.id)
|
2016-11-21 14:59:31 +00:00
|
|
|
assert_equal(result[0][:overview][:name], 'My assigned Tickets')
|
|
|
|
assert_equal(result[0][:overview][:view], 'my_assigned')
|
|
|
|
assert_equal(result[0][:tickets].class, Array)
|
|
|
|
assert_equal(result[0][:tickets][0][:id], ticket2.id)
|
|
|
|
assert_equal(result[0][:count], 1)
|
|
|
|
assert_equal(result[0][:tickets].class, Array)
|
2017-06-14 15:25:45 +00:00
|
|
|
assert_equal(result[1][:overview][:id], @overview2.id)
|
2016-11-21 14:59:31 +00:00
|
|
|
assert_equal(result[1][:overview][:name], 'Unassigned & Open')
|
|
|
|
assert_equal(result[1][:overview][:view], 'all_unassigned')
|
|
|
|
assert_equal(result[1][:tickets].class, Array)
|
2017-09-11 00:50:05 +00:00
|
|
|
assert_not(result[1][:tickets].blank?)
|
2016-11-21 14:59:31 +00:00
|
|
|
assert_equal(result[1][:tickets][0][:id], ticket3.id)
|
|
|
|
assert_equal(result[1][:tickets][1][:id], ticket1.id)
|
|
|
|
assert_equal(result[1][:count], 2)
|
2017-06-14 15:25:45 +00:00
|
|
|
assert_equal(result[2][:overview][:id], @overview4.id)
|
2016-11-21 14:59:31 +00:00
|
|
|
assert_equal(result[2][:overview][:name], 'My Tickets only with Note')
|
|
|
|
assert_equal(result[2][:overview][:view], 'my_tickets_onyl_with_note')
|
|
|
|
assert_equal(result[2][:tickets].class, Array)
|
|
|
|
assert_equal(result[2][:tickets][0][:id], ticket2.id)
|
|
|
|
assert_equal(result[2][:count], 1)
|
|
|
|
|
2017-06-14 15:25:45 +00:00
|
|
|
result = Ticket::Overviews.index(@agent2)
|
|
|
|
assert_equal(result[0][:overview][:id], @overview1.id)
|
2016-11-21 14:59:31 +00:00
|
|
|
assert_equal(result[0][:overview][:name], 'My assigned Tickets')
|
|
|
|
assert_equal(result[0][:overview][:view], 'my_assigned')
|
|
|
|
assert_equal(result[0][:count], 0)
|
|
|
|
assert_equal(result[0][:tickets].class, Array)
|
2017-09-11 00:50:05 +00:00
|
|
|
assert(result[0][:tickets].blank?)
|
2017-06-14 15:25:45 +00:00
|
|
|
assert_equal(result[1][:overview][:id], @overview2.id)
|
2016-11-21 14:59:31 +00:00
|
|
|
assert_equal(result[1][:overview][:name], 'Unassigned & Open')
|
|
|
|
assert_equal(result[1][:overview][:view], 'all_unassigned')
|
|
|
|
assert_equal(result[1][:tickets].class, Array)
|
2017-09-11 00:50:05 +00:00
|
|
|
assert(result[1][:tickets].blank?)
|
2016-11-21 14:59:31 +00:00
|
|
|
assert_equal(result[1][:count], 0)
|
2017-06-14 15:25:45 +00:00
|
|
|
assert_equal(result[2][:overview][:id], @overview3.id)
|
2016-11-21 14:59:31 +00:00
|
|
|
assert_equal(result[2][:overview][:name], 'My Tickets 2')
|
|
|
|
assert_equal(result[2][:overview][:view], 'my_tickets_2')
|
|
|
|
assert_equal(result[2][:tickets].class, Array)
|
2017-09-11 00:50:05 +00:00
|
|
|
assert(result[2][:tickets].blank?)
|
2016-11-21 14:59:31 +00:00
|
|
|
|
2017-06-14 15:25:45 +00:00
|
|
|
@overview2.order = {
|
2018-12-19 17:31:51 +00:00
|
|
|
by: 'priority_id',
|
2016-11-21 14:59:31 +00:00
|
|
|
direction: 'DESC',
|
|
|
|
}
|
2017-06-14 15:25:45 +00:00
|
|
|
@overview2.save!
|
2016-11-21 14:59:31 +00:00
|
|
|
|
2017-06-14 15:25:45 +00:00
|
|
|
result = Ticket::Overviews.index(@agent1)
|
|
|
|
assert_equal(result[0][:overview][:id], @overview1.id)
|
2016-11-21 14:59:31 +00:00
|
|
|
assert_equal(result[0][:overview][:name], 'My assigned Tickets')
|
|
|
|
assert_equal(result[0][:overview][:view], 'my_assigned')
|
|
|
|
assert_equal(result[0][:tickets].class, Array)
|
|
|
|
assert_equal(result[0][:tickets][0][:id], ticket2.id)
|
|
|
|
assert_equal(result[0][:count], 1)
|
|
|
|
assert_equal(result[0][:tickets].class, Array)
|
2017-06-14 15:25:45 +00:00
|
|
|
assert_equal(result[1][:overview][:id], @overview2.id)
|
2016-11-21 14:59:31 +00:00
|
|
|
assert_equal(result[1][:overview][:name], 'Unassigned & Open')
|
|
|
|
assert_equal(result[1][:overview][:view], 'all_unassigned')
|
|
|
|
assert_equal(result[1][:tickets].class, Array)
|
2017-09-11 00:50:05 +00:00
|
|
|
assert_not(result[1][:tickets].blank?)
|
2016-11-21 14:59:31 +00:00
|
|
|
assert_equal(result[1][:tickets][0][:id], ticket1.id)
|
|
|
|
assert_equal(result[1][:tickets][1][:id], ticket3.id)
|
|
|
|
assert_equal(result[1][:count], 2)
|
2017-06-14 15:25:45 +00:00
|
|
|
assert_equal(result[2][:overview][:id], @overview4.id)
|
2016-11-21 14:59:31 +00:00
|
|
|
assert_equal(result[2][:overview][:name], 'My Tickets only with Note')
|
|
|
|
assert_equal(result[2][:overview][:view], 'my_tickets_onyl_with_note')
|
|
|
|
assert_equal(result[2][:tickets].class, Array)
|
|
|
|
assert_equal(result[2][:tickets][0][:id], ticket2.id)
|
|
|
|
assert_equal(result[2][:count], 1)
|
|
|
|
|
2017-06-14 15:25:45 +00:00
|
|
|
result = Ticket::Overviews.index(@agent2)
|
|
|
|
assert_equal(result[0][:overview][:id], @overview1.id)
|
2016-11-21 14:59:31 +00:00
|
|
|
assert_equal(result[0][:overview][:name], 'My assigned Tickets')
|
|
|
|
assert_equal(result[0][:overview][:view], 'my_assigned')
|
|
|
|
assert_equal(result[0][:count], 0)
|
|
|
|
assert_equal(result[0][:tickets].class, Array)
|
2017-09-11 00:50:05 +00:00
|
|
|
assert(result[0][:tickets].blank?)
|
2017-06-14 15:25:45 +00:00
|
|
|
assert_equal(result[1][:overview][:id], @overview2.id)
|
2016-11-21 14:59:31 +00:00
|
|
|
assert_equal(result[1][:overview][:name], 'Unassigned & Open')
|
|
|
|
assert_equal(result[1][:overview][:view], 'all_unassigned')
|
|
|
|
assert_equal(result[1][:tickets].class, Array)
|
2017-09-11 00:50:05 +00:00
|
|
|
assert(result[1][:tickets].blank?)
|
2016-11-21 14:59:31 +00:00
|
|
|
assert_equal(result[1][:count], 0)
|
2017-06-14 15:25:45 +00:00
|
|
|
assert_equal(result[2][:overview][:id], @overview3.id)
|
2016-11-21 14:59:31 +00:00
|
|
|
assert_equal(result[2][:overview][:name], 'My Tickets 2')
|
|
|
|
assert_equal(result[2][:overview][:view], 'my_tickets_2')
|
|
|
|
assert_equal(result[2][:tickets].class, Array)
|
2017-09-11 00:50:05 +00:00
|
|
|
assert(result[2][:tickets].blank?)
|
2016-11-21 14:59:31 +00:00
|
|
|
|
2017-06-14 15:25:45 +00:00
|
|
|
@overview2.order = {
|
2018-12-19 17:31:51 +00:00
|
|
|
by: 'priority_id',
|
2016-11-21 14:59:31 +00:00
|
|
|
direction: 'ASC',
|
|
|
|
}
|
2017-06-14 15:25:45 +00:00
|
|
|
@overview2.save!
|
2016-11-21 14:59:31 +00:00
|
|
|
|
2017-06-14 15:25:45 +00:00
|
|
|
result = Ticket::Overviews.index(@agent1)
|
|
|
|
assert_equal(result[0][:overview][:id], @overview1.id)
|
2016-11-21 14:59:31 +00:00
|
|
|
assert_equal(result[0][:overview][:name], 'My assigned Tickets')
|
|
|
|
assert_equal(result[0][:overview][:view], 'my_assigned')
|
|
|
|
assert_equal(result[0][:tickets].class, Array)
|
|
|
|
assert_equal(result[0][:tickets][0][:id], ticket2.id)
|
|
|
|
assert_equal(result[0][:count], 1)
|
|
|
|
assert_equal(result[0][:tickets].class, Array)
|
2017-06-14 15:25:45 +00:00
|
|
|
assert_equal(result[1][:overview][:id], @overview2.id)
|
2016-11-21 14:59:31 +00:00
|
|
|
assert_equal(result[1][:overview][:name], 'Unassigned & Open')
|
|
|
|
assert_equal(result[1][:overview][:view], 'all_unassigned')
|
|
|
|
assert_equal(result[1][:tickets].class, Array)
|
2017-09-11 00:50:05 +00:00
|
|
|
assert_not(result[1][:tickets].blank?)
|
2016-11-21 14:59:31 +00:00
|
|
|
assert_equal(result[1][:tickets][0][:id], ticket3.id)
|
|
|
|
assert_equal(result[1][:tickets][1][:id], ticket1.id)
|
|
|
|
assert_equal(result[1][:count], 2)
|
2017-06-14 15:25:45 +00:00
|
|
|
assert_equal(result[2][:overview][:id], @overview4.id)
|
2016-11-21 14:59:31 +00:00
|
|
|
assert_equal(result[2][:overview][:name], 'My Tickets only with Note')
|
|
|
|
assert_equal(result[2][:overview][:view], 'my_tickets_onyl_with_note')
|
|
|
|
assert_equal(result[2][:tickets].class, Array)
|
|
|
|
assert_equal(result[2][:tickets][0][:id], ticket2.id)
|
|
|
|
assert_equal(result[2][:count], 1)
|
|
|
|
|
2017-06-14 15:25:45 +00:00
|
|
|
result = Ticket::Overviews.index(@agent2)
|
|
|
|
assert_equal(result[0][:overview][:id], @overview1.id)
|
2016-11-21 14:59:31 +00:00
|
|
|
assert_equal(result[0][:overview][:name], 'My assigned Tickets')
|
|
|
|
assert_equal(result[0][:overview][:view], 'my_assigned')
|
|
|
|
assert_equal(result[0][:count], 0)
|
|
|
|
assert_equal(result[0][:tickets].class, Array)
|
2017-09-11 00:50:05 +00:00
|
|
|
assert(result[0][:tickets].blank?)
|
2017-06-14 15:25:45 +00:00
|
|
|
assert_equal(result[1][:overview][:id], @overview2.id)
|
2016-11-21 14:59:31 +00:00
|
|
|
assert_equal(result[1][:overview][:name], 'Unassigned & Open')
|
|
|
|
assert_equal(result[1][:overview][:view], 'all_unassigned')
|
|
|
|
assert_equal(result[1][:tickets].class, Array)
|
2017-09-11 00:50:05 +00:00
|
|
|
assert(result[1][:tickets].blank?)
|
2016-11-21 14:59:31 +00:00
|
|
|
assert_equal(result[1][:count], 0)
|
2017-06-14 15:25:45 +00:00
|
|
|
assert_equal(result[2][:overview][:id], @overview3.id)
|
2016-11-21 14:59:31 +00:00
|
|
|
assert_equal(result[2][:overview][:name], 'My Tickets 2')
|
|
|
|
assert_equal(result[2][:overview][:view], 'my_tickets_2')
|
|
|
|
assert_equal(result[2][:tickets].class, Array)
|
2017-09-11 00:50:05 +00:00
|
|
|
assert(result[2][:tickets].blank?)
|
2016-11-21 14:59:31 +00:00
|
|
|
|
2017-06-14 15:25:45 +00:00
|
|
|
@overview2.order = {
|
2018-12-19 17:31:51 +00:00
|
|
|
by: 'priority',
|
2016-11-21 14:59:31 +00:00
|
|
|
direction: 'DESC',
|
|
|
|
}
|
2017-06-14 15:25:45 +00:00
|
|
|
@overview2.save!
|
2016-11-21 14:59:31 +00:00
|
|
|
|
2017-06-14 15:25:45 +00:00
|
|
|
result = Ticket::Overviews.index(@agent1)
|
|
|
|
assert_equal(result[0][:overview][:id], @overview1.id)
|
2016-11-21 14:59:31 +00:00
|
|
|
assert_equal(result[0][:overview][:name], 'My assigned Tickets')
|
|
|
|
assert_equal(result[0][:overview][:view], 'my_assigned')
|
|
|
|
assert_equal(result[0][:tickets].class, Array)
|
|
|
|
assert_equal(result[0][:tickets][0][:id], ticket2.id)
|
|
|
|
assert_equal(result[0][:count], 1)
|
|
|
|
assert_equal(result[0][:tickets].class, Array)
|
2017-06-14 15:25:45 +00:00
|
|
|
assert_equal(result[1][:overview][:id], @overview2.id)
|
2016-11-21 14:59:31 +00:00
|
|
|
assert_equal(result[1][:overview][:name], 'Unassigned & Open')
|
|
|
|
assert_equal(result[1][:overview][:view], 'all_unassigned')
|
|
|
|
assert_equal(result[1][:tickets].class, Array)
|
2017-09-11 00:50:05 +00:00
|
|
|
assert_not(result[1][:tickets].blank?)
|
2016-11-21 14:59:31 +00:00
|
|
|
assert_equal(result[1][:tickets][0][:id], ticket1.id)
|
|
|
|
assert_equal(result[1][:tickets][1][:id], ticket3.id)
|
|
|
|
assert_equal(result[1][:count], 2)
|
2017-06-14 15:25:45 +00:00
|
|
|
assert_equal(result[2][:overview][:id], @overview4.id)
|
2016-11-21 14:59:31 +00:00
|
|
|
assert_equal(result[2][:overview][:name], 'My Tickets only with Note')
|
|
|
|
assert_equal(result[2][:overview][:view], 'my_tickets_onyl_with_note')
|
|
|
|
assert_equal(result[2][:tickets].class, Array)
|
|
|
|
assert_equal(result[2][:tickets][0][:id], ticket2.id)
|
|
|
|
assert_equal(result[2][:count], 1)
|
|
|
|
|
2017-06-14 15:25:45 +00:00
|
|
|
result = Ticket::Overviews.index(@agent2)
|
|
|
|
assert_equal(result[0][:overview][:id], @overview1.id)
|
2016-11-21 14:59:31 +00:00
|
|
|
assert_equal(result[0][:overview][:name], 'My assigned Tickets')
|
|
|
|
assert_equal(result[0][:overview][:view], 'my_assigned')
|
|
|
|
assert_equal(result[0][:count], 0)
|
|
|
|
assert_equal(result[0][:tickets].class, Array)
|
2017-09-11 00:50:05 +00:00
|
|
|
assert(result[0][:tickets].blank?)
|
2017-06-14 15:25:45 +00:00
|
|
|
assert_equal(result[1][:overview][:id], @overview2.id)
|
2016-11-21 14:59:31 +00:00
|
|
|
assert_equal(result[1][:overview][:name], 'Unassigned & Open')
|
|
|
|
assert_equal(result[1][:overview][:view], 'all_unassigned')
|
|
|
|
assert_equal(result[1][:tickets].class, Array)
|
2017-09-11 00:50:05 +00:00
|
|
|
assert(result[1][:tickets].blank?)
|
2016-11-21 14:59:31 +00:00
|
|
|
assert_equal(result[1][:count], 0)
|
2017-06-14 15:25:45 +00:00
|
|
|
assert_equal(result[2][:overview][:id], @overview3.id)
|
2016-11-21 14:59:31 +00:00
|
|
|
assert_equal(result[2][:overview][:name], 'My Tickets 2')
|
|
|
|
assert_equal(result[2][:overview][:view], 'my_tickets_2')
|
|
|
|
assert_equal(result[2][:tickets].class, Array)
|
2017-09-11 00:50:05 +00:00
|
|
|
assert(result[2][:tickets].blank?)
|
2016-11-21 14:59:31 +00:00
|
|
|
|
2017-06-14 15:25:45 +00:00
|
|
|
@overview2.order = {
|
2018-12-19 17:31:51 +00:00
|
|
|
by: 'priority',
|
2016-11-21 14:59:31 +00:00
|
|
|
direction: 'ASC',
|
|
|
|
}
|
2017-06-14 15:25:45 +00:00
|
|
|
@overview2.save!
|
2016-11-21 14:59:31 +00:00
|
|
|
|
2017-06-14 15:25:45 +00:00
|
|
|
result = Ticket::Overviews.index(@agent1)
|
|
|
|
assert_equal(result[0][:overview][:id], @overview1.id)
|
2016-11-21 14:59:31 +00:00
|
|
|
assert_equal(result[0][:overview][:name], 'My assigned Tickets')
|
|
|
|
assert_equal(result[0][:overview][:view], 'my_assigned')
|
|
|
|
assert_equal(result[0][:tickets].class, Array)
|
|
|
|
assert_equal(result[0][:tickets][0][:id], ticket2.id)
|
|
|
|
assert_equal(result[0][:count], 1)
|
|
|
|
assert_equal(result[0][:tickets].class, Array)
|
2017-06-14 15:25:45 +00:00
|
|
|
assert_equal(result[1][:overview][:id], @overview2.id)
|
2016-11-21 14:59:31 +00:00
|
|
|
assert_equal(result[1][:overview][:name], 'Unassigned & Open')
|
|
|
|
assert_equal(result[1][:overview][:view], 'all_unassigned')
|
|
|
|
assert_equal(result[1][:tickets].class, Array)
|
2017-09-11 00:50:05 +00:00
|
|
|
assert_not(result[1][:tickets].blank?)
|
2016-11-21 14:59:31 +00:00
|
|
|
assert_equal(result[1][:tickets][0][:id], ticket3.id)
|
|
|
|
assert_equal(result[1][:tickets][1][:id], ticket1.id)
|
|
|
|
assert_equal(result[1][:count], 2)
|
2017-06-14 15:25:45 +00:00
|
|
|
assert_equal(result[2][:overview][:id], @overview4.id)
|
2016-11-21 14:59:31 +00:00
|
|
|
assert_equal(result[2][:overview][:name], 'My Tickets only with Note')
|
|
|
|
assert_equal(result[2][:overview][:view], 'my_tickets_onyl_with_note')
|
|
|
|
assert_equal(result[2][:tickets].class, Array)
|
|
|
|
assert_equal(result[2][:tickets][0][:id], ticket2.id)
|
|
|
|
assert_equal(result[2][:count], 1)
|
|
|
|
|
2017-06-14 15:25:45 +00:00
|
|
|
result = Ticket::Overviews.index(@agent2)
|
|
|
|
assert_equal(result[0][:overview][:id], @overview1.id)
|
2016-11-21 14:59:31 +00:00
|
|
|
assert_equal(result[0][:overview][:name], 'My assigned Tickets')
|
|
|
|
assert_equal(result[0][:overview][:view], 'my_assigned')
|
|
|
|
assert_equal(result[0][:count], 0)
|
|
|
|
assert_equal(result[0][:tickets].class, Array)
|
2017-09-11 00:50:05 +00:00
|
|
|
assert(result[0][:tickets].blank?)
|
2017-06-14 15:25:45 +00:00
|
|
|
assert_equal(result[1][:overview][:id], @overview2.id)
|
2016-11-21 14:59:31 +00:00
|
|
|
assert_equal(result[1][:overview][:name], 'Unassigned & Open')
|
|
|
|
assert_equal(result[1][:overview][:view], 'all_unassigned')
|
|
|
|
assert_equal(result[1][:tickets].class, Array)
|
2017-09-11 00:50:05 +00:00
|
|
|
assert(result[1][:tickets].blank?)
|
2016-11-21 14:59:31 +00:00
|
|
|
assert_equal(result[1][:count], 0)
|
2017-06-14 15:25:45 +00:00
|
|
|
assert_equal(result[2][:overview][:id], @overview3.id)
|
2016-11-21 14:59:31 +00:00
|
|
|
assert_equal(result[2][:overview][:name], 'My Tickets 2')
|
|
|
|
assert_equal(result[2][:overview][:view], 'my_tickets_2')
|
|
|
|
assert_equal(result[2][:tickets].class, Array)
|
2017-09-11 00:50:05 +00:00
|
|
|
assert(result[2][:tickets].blank?)
|
2016-11-21 14:59:31 +00:00
|
|
|
|
|
|
|
end
|
|
|
|
|
2018-08-06 17:36:27 +00:00
|
|
|
test 'overview any owner / no owner is set' do
|
|
|
|
|
|
|
|
Ticket.destroy_all
|
|
|
|
Overview.destroy_all
|
|
|
|
|
|
|
|
UserInfo.current_user_id = 1
|
|
|
|
overview_role = Role.find_by(name: 'Agent')
|
|
|
|
overview1 = Overview.create_or_update(
|
2018-12-19 17:31:51 +00:00
|
|
|
name: 'not owned',
|
|
|
|
prio: 1000,
|
|
|
|
role_ids: [overview_role.id],
|
2018-08-06 17:36:27 +00:00
|
|
|
condition: {
|
|
|
|
'ticket.owner_id' => {
|
2018-12-19 17:31:51 +00:00
|
|
|
operator: 'is',
|
2018-08-06 17:36:27 +00:00
|
|
|
pre_condition: 'not_set',
|
|
|
|
},
|
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
order: {
|
|
|
|
by: 'created_at',
|
2018-08-06 17:36:27 +00:00
|
|
|
direction: 'ASC',
|
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
view: {
|
|
|
|
d: %w[title customer group created_at],
|
|
|
|
s: %w[title customer group created_at],
|
|
|
|
m: %w[number title customer group created_at],
|
2018-08-06 17:36:27 +00:00
|
|
|
view_mode_default: 's',
|
|
|
|
},
|
|
|
|
)
|
|
|
|
|
|
|
|
overview2 = Overview.create_or_update(
|
2018-12-19 17:31:51 +00:00
|
|
|
name: 'not owned by somebody',
|
|
|
|
prio: 2000,
|
|
|
|
role_ids: [overview_role.id],
|
2018-08-06 17:36:27 +00:00
|
|
|
condition: {
|
|
|
|
'ticket.owner_id' => {
|
2018-12-19 17:31:51 +00:00
|
|
|
operator: 'is not',
|
2018-08-06 17:36:27 +00:00
|
|
|
pre_condition: 'not_set',
|
|
|
|
},
|
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
order: {
|
|
|
|
by: 'created_at',
|
2018-08-06 17:36:27 +00:00
|
|
|
direction: 'ASC',
|
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
view: {
|
|
|
|
d: %w[title customer group created_at],
|
|
|
|
s: %w[title customer group created_at],
|
|
|
|
m: %w[number title customer group created_at],
|
2018-08-06 17:36:27 +00:00
|
|
|
view_mode_default: 's',
|
|
|
|
},
|
|
|
|
)
|
|
|
|
|
|
|
|
ticket1 = Ticket.create!(
|
2018-12-19 17:31:51 +00:00
|
|
|
title: 'overview test 1',
|
|
|
|
group: Group.lookup(name: 'OverviewTest'),
|
2018-08-06 17:36:27 +00:00
|
|
|
customer_id: 2,
|
2018-12-19 17:31:51 +00:00
|
|
|
owner_id: 1,
|
|
|
|
state: Ticket::State.lookup(name: 'new'),
|
|
|
|
priority: Ticket::Priority.lookup(name: '2 normal'),
|
2018-08-06 17:36:27 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
travel 2.seconds
|
|
|
|
ticket2 = Ticket.create!(
|
2018-12-19 17:31:51 +00:00
|
|
|
title: 'overview test 2',
|
|
|
|
group: Group.lookup(name: 'OverviewTest'),
|
2018-08-06 17:36:27 +00:00
|
|
|
customer_id: 2,
|
2018-12-19 17:31:51 +00:00
|
|
|
owner_id: nil,
|
|
|
|
state: Ticket::State.lookup(name: 'new'),
|
|
|
|
priority: Ticket::Priority.lookup(name: '2 normal'),
|
2018-08-06 17:36:27 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
travel 2.seconds
|
|
|
|
ticket3 = Ticket.create!(
|
2018-12-19 17:31:51 +00:00
|
|
|
title: 'overview test 3',
|
|
|
|
group: Group.lookup(name: 'OverviewTest'),
|
2018-08-06 17:36:27 +00:00
|
|
|
customer_id: 2,
|
2018-12-19 17:31:51 +00:00
|
|
|
owner_id: @agent1.id,
|
|
|
|
state: Ticket::State.lookup(name: 'new'),
|
|
|
|
priority: Ticket::Priority.lookup(name: '2 normal'),
|
2018-08-06 17:36:27 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
result = Ticket::Overviews.index(@agent1)
|
|
|
|
assert_equal(result[0][:overview][:id], overview1.id)
|
|
|
|
assert_equal(result[0][:overview][:name], 'not owned')
|
|
|
|
assert_equal(result[0][:overview][:view], 'not_owned')
|
|
|
|
assert_equal(result[0][:tickets].class, Array)
|
|
|
|
|
|
|
|
assert_equal(result[0][:tickets][0][:id], ticket1.id)
|
|
|
|
assert_equal(result[0][:tickets][1][:id], ticket2.id)
|
|
|
|
assert_equal(result[0][:count], 2)
|
|
|
|
|
|
|
|
assert_equal(result[1][:overview][:id], overview2.id)
|
|
|
|
assert_equal(result[1][:overview][:name], 'not owned by somebody')
|
|
|
|
assert_equal(result[1][:overview][:view], 'not_owned_by_somebody')
|
|
|
|
assert_equal(result[1][:tickets].class, Array)
|
|
|
|
assert_equal(result[1][:tickets][0][:id], ticket3.id)
|
|
|
|
assert_equal(result[1][:count], 1)
|
|
|
|
|
|
|
|
end
|
2016-03-14 15:05:52 +00:00
|
|
|
end
|