Added calendar subscription tests.
This commit is contained in:
parent
d4def003ba
commit
9084c99d4b
5 changed files with 611 additions and 159 deletions
|
@ -414,6 +414,10 @@ condition example
|
|||
pre_condition: 'specific',
|
||||
value: 4711,
|
||||
},
|
||||
'ticket.escalation_time' => {
|
||||
operator: 'is not', # not
|
||||
value: nil,
|
||||
}
|
||||
}
|
||||
|
||||
=end
|
||||
|
@ -463,8 +467,8 @@ condition example
|
|||
selector = selector_raw.stringify_keys
|
||||
fail "Invalid selector, operator missing #{selector.inspect}" if !selector['operator']
|
||||
|
||||
# validate value / allow empty but only if pre_condition eyists
|
||||
if selector['value'].nil? || (selector['value'].respond_to?(:empty?) && selector['value'].empty?)
|
||||
# validate value / allow empty but only if pre_condition exists
|
||||
if (selector['value'].class == String || selector['value'].class == Array) && (selector['value'].respond_to?(:empty?) && selector['value'].empty?)
|
||||
return nil if selector['pre_condition'].nil? || (selector['pre_condition'].respond_to?(:empty?) && selector['pre_condition'].empty?)
|
||||
end
|
||||
|
||||
|
@ -496,10 +500,16 @@ condition example
|
|||
query += "#{attribute} IN (?)"
|
||||
user = User.lookup(id: current_user_id)
|
||||
bind_params.push user.organization_id
|
||||
else
|
||||
# rubocop:disable Style/IfInsideElse
|
||||
if selector['value'].nil?
|
||||
query += "#{attribute} NOT NULL"
|
||||
else
|
||||
query += "#{attribute} IN (?)"
|
||||
bind_params.push selector['value']
|
||||
end
|
||||
# rubocop:enable Style/IfInsideElse
|
||||
end
|
||||
elsif selector['operator'] == 'is not'
|
||||
if selector['pre_condition'] == 'set'
|
||||
if attributes[1] =~ /^(created_by|updated_by|owner|customer|user)_id/
|
||||
|
@ -515,10 +525,16 @@ condition example
|
|||
query += "#{attribute} NOT IN (?)"
|
||||
user = User.lookup(id: current_user_id)
|
||||
bind_params.push user.organization_id
|
||||
else
|
||||
# rubocop:disable Style/IfInsideElse
|
||||
if selector['value'].nil?
|
||||
query += "#{attribute} IS NOT NULL"
|
||||
else
|
||||
query += "#{attribute} NOT IN (?)"
|
||||
bind_params.push selector['value']
|
||||
end
|
||||
# rubocop:enable Style/IfInsideElse
|
||||
end
|
||||
elsif selector['operator'] == 'contains'
|
||||
query += "#{attribute} #{like} (?)"
|
||||
value = "%#{selector['value']}%"
|
||||
|
|
396
test/unit/calendar_subscription_test.rb
Normal file
396
test/unit/calendar_subscription_test.rb
Normal file
|
@ -0,0 +1,396 @@
|
|||
# encoding: utf-8
|
||||
require 'test_helper'
|
||||
|
||||
class CalendarSubscriptionTest < ActiveSupport::TestCase
|
||||
test 'default test' do
|
||||
|
||||
# create base
|
||||
group_default = Group.lookup(name: 'Users')
|
||||
group_calendar = Group.create_or_update(
|
||||
name: 'CalendarSubscription',
|
||||
updated_by_id: 1,
|
||||
created_by_id: 1,
|
||||
)
|
||||
roles = Role.where(name: 'Agent')
|
||||
agent1 = User.create_or_update(
|
||||
login: 'ticket-calendar-subscription-agent1@example.com',
|
||||
firstname: 'Notification',
|
||||
lastname: 'Agent1',
|
||||
email: 'ticket-calendar-subscription-agent1@example.com',
|
||||
password: 'agentpw',
|
||||
active: true,
|
||||
roles: roles,
|
||||
groups: [group_calendar],
|
||||
preferences: {},
|
||||
updated_by_id: 1,
|
||||
created_by_id: 1,
|
||||
)
|
||||
agent2 = User.create_or_update(
|
||||
login: 'ticket-calendar-subscription-agent2@example.com',
|
||||
firstname: 'Notification',
|
||||
lastname: 'Agent2',
|
||||
email: 'ticket-calendar-subscription-agent2@example.com',
|
||||
password: 'agentpw',
|
||||
active: true,
|
||||
roles: roles,
|
||||
groups: [group_default],
|
||||
preferences: {},
|
||||
updated_at: '2016-02-05 16:38:00',
|
||||
updated_by_id: 1,
|
||||
created_by_id: 1,
|
||||
)
|
||||
roles = Role.where(name: 'Customer')
|
||||
organization1 = Organization.create_if_not_exists(
|
||||
name: 'Selector Org',
|
||||
updated_at: '2016-02-05 16:37:00',
|
||||
updated_by_id: 1,
|
||||
created_by_id: 1,
|
||||
)
|
||||
customer1 = User.create_or_update(
|
||||
login: 'ticket-calendar-subscription-customer1@example.com',
|
||||
firstname: 'Notification',
|
||||
lastname: 'Customer1',
|
||||
email: 'ticket-calendar-subscription-customer1@example.com',
|
||||
password: 'customerpw',
|
||||
active: true,
|
||||
organization_id: organization1.id,
|
||||
roles: roles,
|
||||
preferences: {},
|
||||
updated_at: '2016-02-05 16:37:00',
|
||||
updated_by_id: 1,
|
||||
created_by_id: 1,
|
||||
)
|
||||
customer2 = User.create_or_update(
|
||||
login: 'ticket-calendar-subscription-customer2@example.com',
|
||||
firstname: 'Notification',
|
||||
lastname: 'Customer2',
|
||||
email: 'ticket-calendar-subscription-customer2@example.com',
|
||||
password: 'customerpw',
|
||||
active: true,
|
||||
organization_id: nil,
|
||||
roles: roles,
|
||||
preferences: {},
|
||||
updated_at: '2016-02-05 16:37:00',
|
||||
updated_by_id: 1,
|
||||
created_by_id: 1,
|
||||
)
|
||||
|
||||
Ticket.destroy_all
|
||||
|
||||
ticket1 = Ticket.create(
|
||||
title: 'some title1 - new - group_calendar',
|
||||
group: group_calendar,
|
||||
customer_id: customer1.id,
|
||||
owner_id: agent1.id,
|
||||
state: Ticket::State.lookup(name: 'new'),
|
||||
priority: Ticket::Priority.lookup(name: '2 normal'),
|
||||
created_at: '2016-02-05 16:37:00',
|
||||
updated_by_id: 1,
|
||||
created_by_id: 1,
|
||||
)
|
||||
ticket2 = Ticket.create(
|
||||
title: 'some title1 - new - group_default',
|
||||
group: group_default,
|
||||
customer_id: customer1.id,
|
||||
owner_id: agent2.id,
|
||||
state: Ticket::State.lookup(name: 'new'),
|
||||
priority: Ticket::Priority.lookup(name: '2 normal'),
|
||||
created_at: '2016-02-05 16:37:00',
|
||||
updated_by_id: 1,
|
||||
created_by_id: 1,
|
||||
)
|
||||
ticket3 = Ticket.create(
|
||||
title: 'some title1 - pending - group_calendar',
|
||||
group: group_calendar,
|
||||
customer_id: customer1.id,
|
||||
owner_id: agent1.id,
|
||||
state: Ticket::State.lookup(name: 'pending reminder'),
|
||||
pending_time: '2016-02-07 16:37:00',
|
||||
priority: Ticket::Priority.lookup(name: '2 normal'),
|
||||
created_at: '2016-02-05 16:37:00',
|
||||
updated_by_id: 1,
|
||||
created_by_id: 1,
|
||||
)
|
||||
ticket4 = Ticket.create(
|
||||
title: 'some title1 - pending - group_default',
|
||||
group: group_default,
|
||||
customer_id: customer1.id,
|
||||
owner_id: agent2.id,
|
||||
state: Ticket::State.lookup(name: 'pending reminder'),
|
||||
pending_time: '2016-02-07 16:37:00',
|
||||
priority: Ticket::Priority.lookup(name: '2 normal'),
|
||||
created_at: '2016-02-05 16:37:00',
|
||||
updated_by_id: 1,
|
||||
created_by_id: 1,
|
||||
)
|
||||
ticket5 = Ticket.create(
|
||||
title: 'some title1 - escalation - group_calendar',
|
||||
group: group_calendar,
|
||||
customer_id: customer1.id,
|
||||
owner_id: agent1.id,
|
||||
state: Ticket::State.lookup(name: 'new'),
|
||||
escalation_time: '2016-02-07 17:37:00',
|
||||
priority: Ticket::Priority.lookup(name: '2 normal'),
|
||||
created_at: '2016-02-05 16:37:00',
|
||||
updated_by_id: 1,
|
||||
created_by_id: 1,
|
||||
)
|
||||
ticket6 = Ticket.create(
|
||||
title: 'some title1 - escalation - group_default',
|
||||
group: group_default,
|
||||
customer_id: customer1.id,
|
||||
owner_id: agent2.id,
|
||||
state: Ticket::State.lookup(name: 'new'),
|
||||
escalation_time: '2016-02-07 16:37:00',
|
||||
priority: Ticket::Priority.lookup(name: '2 normal'),
|
||||
created_at: '2016-02-05 16:37:00',
|
||||
updated_by_id: 1,
|
||||
created_by_id: 1,
|
||||
)
|
||||
|
||||
ticket7 = Ticket.create(
|
||||
title: 'some title2 - new - group_calendar',
|
||||
group: group_calendar,
|
||||
customer_id: customer1.id,
|
||||
owner_id: 1,
|
||||
state: Ticket::State.lookup(name: 'new'),
|
||||
priority: Ticket::Priority.lookup(name: '2 normal'),
|
||||
created_at: '2016-02-05 17:37:00',
|
||||
updated_by_id: 1,
|
||||
created_by_id: 1,
|
||||
)
|
||||
ticket8 = Ticket.create(
|
||||
title: 'some title2 - new - group_default',
|
||||
group: group_default,
|
||||
customer_id: customer1.id,
|
||||
owner_id: 1,
|
||||
state: Ticket::State.lookup(name: 'new'),
|
||||
priority: Ticket::Priority.lookup(name: '2 normal'),
|
||||
created_at: '2016-02-05 17:37:00',
|
||||
updated_by_id: 1,
|
||||
created_by_id: 1,
|
||||
)
|
||||
ticket9 = Ticket.create(
|
||||
title: 'some title2 - pending - group_calendar',
|
||||
group: group_calendar,
|
||||
customer_id: customer1.id,
|
||||
owner_id: 1,
|
||||
state: Ticket::State.lookup(name: 'pending reminder'),
|
||||
pending_time: '2016-02-08 16:37:00',
|
||||
priority: Ticket::Priority.lookup(name: '2 normal'),
|
||||
created_at: '2016-02-05 17:37:00',
|
||||
updated_by_id: 1,
|
||||
created_by_id: 1,
|
||||
)
|
||||
ticket10 = Ticket.create(
|
||||
title: 'some title2 - pending - group_default',
|
||||
group: group_default,
|
||||
customer_id: customer1.id,
|
||||
owner_id: 1,
|
||||
state: Ticket::State.lookup(name: 'pending reminder'),
|
||||
pending_time: '2016-02-08 16:37:00',
|
||||
priority: Ticket::Priority.lookup(name: '2 normal'),
|
||||
created_at: '2016-02-05 17:37:00',
|
||||
updated_by_id: 1,
|
||||
created_by_id: 1,
|
||||
)
|
||||
ticket11 = Ticket.create(
|
||||
title: 'some title2 - escalation - group_calendar',
|
||||
group: group_calendar,
|
||||
customer_id: customer1.id,
|
||||
owner_id: 1,
|
||||
state: Ticket::State.lookup(name: 'new'),
|
||||
escalation_time: '2016-02-08 17:37:00',
|
||||
priority: Ticket::Priority.lookup(name: '2 normal'),
|
||||
created_at: '2016-02-05 17:37:00',
|
||||
updated_by_id: 1,
|
||||
created_by_id: 1,
|
||||
)
|
||||
ticket12 = Ticket.create(
|
||||
title: 'some title2 - escalation - group_default',
|
||||
group: group_default,
|
||||
customer_id: customer1.id,
|
||||
owner_id: 1,
|
||||
state: Ticket::State.lookup(name: 'new'),
|
||||
escalation_time: '2016-02-08 16:37:00',
|
||||
priority: Ticket::Priority.lookup(name: '2 normal'),
|
||||
created_at: '2016-02-05 17:37:00',
|
||||
updated_by_id: 1,
|
||||
created_by_id: 1,
|
||||
)
|
||||
|
||||
# check agent 1
|
||||
calendar_subscriptions = CalendarSubscriptions.new(agent1)
|
||||
|
||||
ical_file = calendar_subscriptions.all
|
||||
cals = Icalendar.parse(ical_file)
|
||||
assert_equal(cals.count, 1)
|
||||
cal = cals.first
|
||||
assert_equal(cals.count, 1)
|
||||
assert_equal(cal.events.count, 4)
|
||||
|
||||
assert_equal(cal.events[0].dtstart, Time.zone.today)
|
||||
assert_equal(cal.events[0].summary, 'new ticket: \'some title1 - new - group_calendar\'')
|
||||
assert_equal(cal.events[0].description, "T##{ticket1.number}")
|
||||
|
||||
assert_equal(cal.events[1].dtstart, Time.zone.today)
|
||||
assert_equal(cal.events[1].summary, 'new ticket: \'some title1 - escalation - group_calendar\'')
|
||||
assert_equal(cal.events[1].description, "T##{ticket5.number}")
|
||||
|
||||
assert_equal(cal.events[2].dtstart, Time.zone.today)
|
||||
assert_equal(cal.events[2].summary, 'pending reminder ticket: \'some title1 - pending - group_calendar\' customer: Notification Customer1 (Selector Org)')
|
||||
assert_equal(cal.events[2].description, "T##{ticket3.number}")
|
||||
|
||||
assert_equal(cal.events[3].dtstart, Time.zone.today)
|
||||
assert_equal(cal.events[3].summary, 'ticket escalation: \'some title1 - escalation - group_calendar\' customer: Notification Customer1 (Selector Org)')
|
||||
assert_equal(cal.events[3].description, "T##{ticket5.number}")
|
||||
|
||||
if !agent1.preferences[:calendar_subscriptions]
|
||||
agent1.preferences[:calendar_subscriptions] = {}
|
||||
end
|
||||
agent1.preferences[:calendar_subscriptions][:tickets] = {
|
||||
escalation: {
|
||||
own: true,
|
||||
not_assigned: true,
|
||||
},
|
||||
new_open: {
|
||||
own: true,
|
||||
not_assigned: true,
|
||||
},
|
||||
pending: {
|
||||
own: true,
|
||||
not_assigned: true,
|
||||
}
|
||||
}
|
||||
agent1.save!
|
||||
|
||||
calendar_subscriptions = CalendarSubscriptions.new(agent1)
|
||||
|
||||
ical_file = calendar_subscriptions.all
|
||||
cals = Icalendar.parse(ical_file)
|
||||
assert_equal(cals.count, 1)
|
||||
cal = cals.first
|
||||
assert_equal(cals.count, 1)
|
||||
assert_equal(cal.events.count, 8)
|
||||
|
||||
assert_equal(cal.events[0].dtstart, Time.zone.today)
|
||||
assert_equal(cal.events[0].summary, 'new ticket: \'some title2 - new - group_calendar\'')
|
||||
assert_equal(cal.events[0].description, "T##{ticket7.number}")
|
||||
|
||||
assert_equal(cal.events[1].dtstart, Time.zone.today)
|
||||
assert_equal(cal.events[1].summary, 'new ticket: \'some title2 - escalation - group_calendar\'')
|
||||
assert_equal(cal.events[1].description, "T##{ticket11.number}")
|
||||
|
||||
assert_equal(cal.events[2].dtstart, Time.zone.today)
|
||||
assert_equal(cal.events[2].summary, 'new ticket: \'some title1 - new - group_calendar\'')
|
||||
assert_equal(cal.events[2].description, "T##{ticket1.number}")
|
||||
|
||||
assert_equal(cal.events[3].dtstart, Time.zone.today)
|
||||
assert_equal(cal.events[3].summary, 'new ticket: \'some title1 - escalation - group_calendar\'')
|
||||
assert_equal(cal.events[3].description, "T##{ticket5.number}")
|
||||
|
||||
assert_equal(cal.events[4].dtstart, Time.zone.today)
|
||||
assert_equal(cal.events[4].summary, 'pending reminder ticket: \'some title2 - pending - group_calendar\' customer: Notification Customer1 (Selector Org)')
|
||||
assert_equal(cal.events[4].description, "T##{ticket9.number}")
|
||||
|
||||
assert_equal(cal.events[5].dtstart, Time.zone.today)
|
||||
assert_equal(cal.events[5].summary, 'pending reminder ticket: \'some title1 - pending - group_calendar\' customer: Notification Customer1 (Selector Org)')
|
||||
assert_equal(cal.events[5].description, "T##{ticket3.number}")
|
||||
|
||||
assert_equal(cal.events[6].dtstart, Time.zone.today)
|
||||
assert_equal(cal.events[6].summary, 'ticket escalation: \'some title2 - escalation - group_calendar\' customer: Notification Customer1 (Selector Org)')
|
||||
assert_equal(cal.events[6].description, "T##{ticket11.number}")
|
||||
|
||||
assert_equal(cal.events[7].dtstart, Time.zone.today)
|
||||
assert_equal(cal.events[7].summary, 'ticket escalation: \'some title1 - escalation - group_calendar\' customer: Notification Customer1 (Selector Org)')
|
||||
assert_equal(cal.events[7].description, "T##{ticket5.number}")
|
||||
|
||||
# check agent 2
|
||||
calendar_subscriptions = CalendarSubscriptions.new(agent2)
|
||||
|
||||
ical_file = calendar_subscriptions.all
|
||||
cals = Icalendar.parse(ical_file)
|
||||
assert_equal(cals.count, 1)
|
||||
cal = cals.first
|
||||
assert_equal(cals.count, 1)
|
||||
assert_equal(cal.events.count, 4)
|
||||
|
||||
assert_equal(cal.events[0].dtstart, Time.zone.today)
|
||||
assert_equal(cal.events[0].summary, 'new ticket: \'some title1 - new - group_default\'')
|
||||
assert_equal(cal.events[0].description, "T##{ticket2.number}")
|
||||
|
||||
assert_equal(cal.events[1].dtstart, Time.zone.today)
|
||||
assert_equal(cal.events[1].summary, 'new ticket: \'some title1 - escalation - group_default\'')
|
||||
assert_equal(cal.events[1].description, "T##{ticket6.number}")
|
||||
|
||||
assert_equal(cal.events[2].dtstart, Time.zone.today)
|
||||
assert_equal(cal.events[2].summary, 'pending reminder ticket: \'some title1 - pending - group_default\' customer: Notification Customer1 (Selector Org)')
|
||||
assert_equal(cal.events[2].description, "T##{ticket4.number}")
|
||||
|
||||
assert_equal(cal.events[3].dtstart, Time.zone.today)
|
||||
assert_equal(cal.events[3].summary, 'ticket escalation: \'some title1 - escalation - group_default\' customer: Notification Customer1 (Selector Org)')
|
||||
assert_equal(cal.events[3].description, "T##{ticket6.number}")
|
||||
|
||||
if !agent2.preferences[:calendar_subscriptions]
|
||||
agent2.preferences[:calendar_subscriptions] = {}
|
||||
end
|
||||
agent2.preferences[:calendar_subscriptions][:tickets] = {
|
||||
escalation: {
|
||||
own: true,
|
||||
not_assigned: true,
|
||||
},
|
||||
new_open: {
|
||||
own: true,
|
||||
not_assigned: true,
|
||||
},
|
||||
pending: {
|
||||
own: true,
|
||||
not_assigned: true,
|
||||
}
|
||||
}
|
||||
agent2.save!
|
||||
|
||||
calendar_subscriptions = CalendarSubscriptions.new(agent2)
|
||||
|
||||
ical_file = calendar_subscriptions.all
|
||||
cals = Icalendar.parse(ical_file)
|
||||
assert_equal(cals.count, 1)
|
||||
cal = cals.first
|
||||
assert_equal(cals.count, 1)
|
||||
assert_equal(cal.events.count, 8)
|
||||
|
||||
assert_equal(cal.events[0].dtstart, Time.zone.today)
|
||||
assert_equal(cal.events[0].summary, 'new ticket: \'some title2 - new - group_default\'')
|
||||
assert_equal(cal.events[0].description, "T##{ticket8.number}")
|
||||
|
||||
assert_equal(cal.events[1].dtstart, Time.zone.today)
|
||||
assert_equal(cal.events[1].summary, 'new ticket: \'some title2 - escalation - group_default\'')
|
||||
assert_equal(cal.events[1].description, "T##{ticket12.number}")
|
||||
|
||||
assert_equal(cal.events[2].dtstart, Time.zone.today)
|
||||
assert_equal(cal.events[2].summary, 'new ticket: \'some title1 - new - group_default\'')
|
||||
assert_equal(cal.events[2].description, "T##{ticket2.number}")
|
||||
|
||||
assert_equal(cal.events[3].dtstart, Time.zone.today)
|
||||
assert_equal(cal.events[3].summary, 'new ticket: \'some title1 - escalation - group_default\'')
|
||||
assert_equal(cal.events[3].description, "T##{ticket6.number}")
|
||||
|
||||
assert_equal(cal.events[4].dtstart, Time.zone.today)
|
||||
assert_equal(cal.events[4].summary, 'pending reminder ticket: \'some title2 - pending - group_default\' customer: Notification Customer1 (Selector Org)')
|
||||
assert_equal(cal.events[4].description, "T##{ticket10.number}")
|
||||
|
||||
assert_equal(cal.events[5].dtstart, Time.zone.today)
|
||||
assert_equal(cal.events[5].summary, 'pending reminder ticket: \'some title1 - pending - group_default\' customer: Notification Customer1 (Selector Org)')
|
||||
assert_equal(cal.events[5].description, "T##{ticket4.number}")
|
||||
|
||||
assert_equal(cal.events[6].dtstart, Time.zone.today)
|
||||
assert_equal(cal.events[6].summary, 'ticket escalation: \'some title2 - escalation - group_default\' customer: Notification Customer1 (Selector Org)')
|
||||
assert_equal(cal.events[6].description, "T##{ticket12.number}")
|
||||
|
||||
assert_equal(cal.events[7].dtstart, Time.zone.today)
|
||||
assert_equal(cal.events[7].summary, 'ticket escalation: \'some title1 - escalation - group_default\' customer: Notification Customer1 (Selector Org)')
|
||||
assert_equal(cal.events[7].description, "T##{ticket6.number}")
|
||||
|
||||
end
|
||||
|
||||
end
|
|
@ -75,6 +75,8 @@ class TicketSelectorTest < ActiveSupport::TestCase
|
|||
|
||||
test 'ticket create' do
|
||||
|
||||
Ticket.destroy_all
|
||||
|
||||
ticket1 = Ticket.create(
|
||||
title: 'some title1',
|
||||
group: group,
|
||||
|
@ -108,6 +110,23 @@ class TicketSelectorTest < ActiveSupport::TestCase
|
|||
assert_equal(ticket2.organization_id, nil)
|
||||
sleep 1
|
||||
|
||||
ticket3 = Ticket.create(
|
||||
title: 'some title3',
|
||||
group: group,
|
||||
customer_id: customer2.id,
|
||||
state: Ticket::State.lookup(name: 'open'),
|
||||
priority: Ticket::Priority.lookup(name: '2 normal'),
|
||||
escalation_time: '2015-02-06 10:00:00',
|
||||
created_at: '2015-02-05 16:37:00',
|
||||
#updated_at: '2015-02-05 17:37:00',
|
||||
updated_by_id: 1,
|
||||
created_by_id: 1,
|
||||
)
|
||||
assert(ticket3, 'ticket created')
|
||||
assert_equal(ticket3.customer.id, customer2.id)
|
||||
assert_equal(ticket3.organization_id, nil)
|
||||
sleep 1
|
||||
|
||||
# search not matching
|
||||
condition = {
|
||||
'ticket.state_id' => {
|
||||
|
@ -179,6 +198,27 @@ class TicketSelectorTest < ActiveSupport::TestCase
|
|||
ticket_count, tickets = Ticket.selectors(condition, 10, customer2)
|
||||
assert_equal(ticket_count, 1)
|
||||
|
||||
condition = {
|
||||
'ticket.escalation_time' => {
|
||||
operator: 'is not',
|
||||
value: nil,
|
||||
}
|
||||
}
|
||||
ticket_count, tickets = Ticket.selectors(condition, 10)
|
||||
assert_equal(ticket_count, 1)
|
||||
|
||||
ticket_count, tickets = Ticket.selectors(condition, 10, agent1)
|
||||
assert_equal(ticket_count, 1)
|
||||
|
||||
ticket_count, tickets = Ticket.selectors(condition, 10, agent2)
|
||||
assert_equal(ticket_count, 0)
|
||||
|
||||
ticket_count, tickets = Ticket.selectors(condition, 10, customer1)
|
||||
assert_equal(ticket_count, 0)
|
||||
|
||||
ticket_count, tickets = Ticket.selectors(condition, 10, customer2)
|
||||
assert_equal(ticket_count, 1)
|
||||
|
||||
# search - created_at
|
||||
condition = {
|
||||
'ticket.group_id' => {
|
||||
|
@ -191,7 +231,7 @@ class TicketSelectorTest < ActiveSupport::TestCase
|
|||
},
|
||||
}
|
||||
ticket_count, tickets = Ticket.selectors(condition, 10, agent1)
|
||||
assert_equal( ticket_count, 2 )
|
||||
assert_equal(ticket_count, 3)
|
||||
|
||||
ticket_count, tickets = Ticket.selectors(condition, 10, agent2)
|
||||
assert_equal(ticket_count, 0)
|
||||
|
@ -200,7 +240,7 @@ class TicketSelectorTest < ActiveSupport::TestCase
|
|||
assert_equal(ticket_count, 1)
|
||||
|
||||
ticket_count, tickets = Ticket.selectors(condition, 10, customer2)
|
||||
assert_equal( ticket_count, 1 )
|
||||
assert_equal(ticket_count, 2)
|
||||
|
||||
condition = {
|
||||
'ticket.group_id' => {
|
||||
|
@ -235,7 +275,7 @@ class TicketSelectorTest < ActiveSupport::TestCase
|
|||
},
|
||||
}
|
||||
ticket_count, tickets = Ticket.selectors(condition, 10, agent1)
|
||||
assert_equal( ticket_count, 2 )
|
||||
assert_equal(ticket_count, 3)
|
||||
|
||||
ticket_count, tickets = Ticket.selectors(condition, 10, agent2)
|
||||
assert_equal(ticket_count, 0)
|
||||
|
@ -244,7 +284,7 @@ class TicketSelectorTest < ActiveSupport::TestCase
|
|||
assert_equal(ticket_count, 1)
|
||||
|
||||
ticket_count, tickets = Ticket.selectors(condition, 10, customer2)
|
||||
assert_equal( ticket_count, 1 )
|
||||
assert_equal(ticket_count, 2)
|
||||
|
||||
condition = {
|
||||
'ticket.group_id' => {
|
||||
|
@ -280,7 +320,7 @@ class TicketSelectorTest < ActiveSupport::TestCase
|
|||
},
|
||||
}
|
||||
ticket_count, tickets = Ticket.selectors(condition, 10, agent1)
|
||||
assert_equal( ticket_count, 2 )
|
||||
assert_equal(ticket_count, 3)
|
||||
|
||||
ticket_count, tickets = Ticket.selectors(condition, 10, agent2)
|
||||
assert_equal(ticket_count, 0)
|
||||
|
@ -289,7 +329,7 @@ class TicketSelectorTest < ActiveSupport::TestCase
|
|||
assert_equal(ticket_count, 1)
|
||||
|
||||
ticket_count, tickets = Ticket.selectors(condition, 10, customer2)
|
||||
assert_equal( ticket_count, 1 )
|
||||
assert_equal(ticket_count, 2)
|
||||
|
||||
condition = {
|
||||
'ticket.group_id' => {
|
||||
|
@ -303,7 +343,7 @@ class TicketSelectorTest < ActiveSupport::TestCase
|
|||
},
|
||||
}
|
||||
ticket_count, tickets = Ticket.selectors(condition, 10, agent1)
|
||||
assert_equal( ticket_count, 2 )
|
||||
assert_equal(ticket_count, 3)
|
||||
|
||||
ticket_count, tickets = Ticket.selectors(condition, 10, agent2)
|
||||
assert_equal(ticket_count, 0)
|
||||
|
@ -312,7 +352,7 @@ class TicketSelectorTest < ActiveSupport::TestCase
|
|||
assert_equal(ticket_count, 1)
|
||||
|
||||
ticket_count, tickets = Ticket.selectors(condition, 10, customer2)
|
||||
assert_equal( ticket_count, 1 )
|
||||
assert_equal(ticket_count, 2)
|
||||
|
||||
condition = {
|
||||
'ticket.group_id' => {
|
||||
|
@ -326,7 +366,7 @@ class TicketSelectorTest < ActiveSupport::TestCase
|
|||
},
|
||||
}
|
||||
ticket_count, tickets = Ticket.selectors(condition, 10, agent1)
|
||||
assert_equal( ticket_count, 2 )
|
||||
assert_equal(ticket_count, 3)
|
||||
|
||||
ticket_count, tickets = Ticket.selectors(condition, 10, agent2)
|
||||
assert_equal(ticket_count, 0)
|
||||
|
@ -335,7 +375,7 @@ class TicketSelectorTest < ActiveSupport::TestCase
|
|||
assert_equal(ticket_count, 1)
|
||||
|
||||
ticket_count, tickets = Ticket.selectors(condition, 10, customer2)
|
||||
assert_equal( ticket_count, 1 )
|
||||
assert_equal(ticket_count, 2)
|
||||
|
||||
# search - updated_at
|
||||
condition = {
|
||||
|
@ -349,7 +389,7 @@ class TicketSelectorTest < ActiveSupport::TestCase
|
|||
},
|
||||
}
|
||||
ticket_count, tickets = Ticket.selectors(condition, 10, agent1)
|
||||
assert_equal( ticket_count, 2 )
|
||||
assert_equal(ticket_count, 3)
|
||||
|
||||
ticket_count, tickets = Ticket.selectors(condition, 10, agent2)
|
||||
assert_equal(ticket_count, 0)
|
||||
|
@ -358,7 +398,7 @@ class TicketSelectorTest < ActiveSupport::TestCase
|
|||
assert_equal(ticket_count, 1)
|
||||
|
||||
ticket_count, tickets = Ticket.selectors(condition, 10, customer2)
|
||||
assert_equal( ticket_count, 1 )
|
||||
assert_equal(ticket_count, 2)
|
||||
|
||||
condition = {
|
||||
'ticket.group_id' => {
|
||||
|
@ -415,7 +455,7 @@ class TicketSelectorTest < ActiveSupport::TestCase
|
|||
},
|
||||
}
|
||||
ticket_count, tickets = Ticket.selectors(condition, 10, agent1)
|
||||
assert_equal( ticket_count, 2 )
|
||||
assert_equal(ticket_count, 3)
|
||||
|
||||
ticket_count, tickets = Ticket.selectors(condition, 10, agent2)
|
||||
assert_equal(ticket_count, 0)
|
||||
|
@ -424,7 +464,7 @@ class TicketSelectorTest < ActiveSupport::TestCase
|
|||
assert_equal(ticket_count, 1)
|
||||
|
||||
ticket_count, tickets = Ticket.selectors(condition, 10, customer2)
|
||||
assert_equal( ticket_count, 1 )
|
||||
assert_equal(ticket_count, 2)
|
||||
|
||||
condition = {
|
||||
'ticket.group_id' => {
|
||||
|
@ -461,7 +501,7 @@ class TicketSelectorTest < ActiveSupport::TestCase
|
|||
},
|
||||
}
|
||||
ticket_count, tickets = Ticket.selectors(condition, 10, agent1)
|
||||
assert_equal( ticket_count, 2 )
|
||||
assert_equal(ticket_count, 3)
|
||||
|
||||
ticket_count, tickets = Ticket.selectors(condition, 10, agent2)
|
||||
assert_equal(ticket_count, 0)
|
||||
|
@ -470,7 +510,7 @@ class TicketSelectorTest < ActiveSupport::TestCase
|
|||
assert_equal(ticket_count, 1)
|
||||
|
||||
ticket_count, tickets = Ticket.selectors(condition, 10, customer2)
|
||||
assert_equal( ticket_count, 1 )
|
||||
assert_equal(ticket_count, 2)
|
||||
|
||||
condition = {
|
||||
'ticket.group_id' => {
|
||||
|
@ -484,7 +524,7 @@ class TicketSelectorTest < ActiveSupport::TestCase
|
|||
},
|
||||
}
|
||||
ticket_count, tickets = Ticket.selectors(condition, 10, agent1)
|
||||
assert_equal( ticket_count, 2 )
|
||||
assert_equal(ticket_count, 3)
|
||||
|
||||
ticket_count, tickets = Ticket.selectors(condition, 10, agent2)
|
||||
assert_equal(ticket_count, 0)
|
||||
|
@ -493,7 +533,7 @@ class TicketSelectorTest < ActiveSupport::TestCase
|
|||
assert_equal(ticket_count, 1)
|
||||
|
||||
ticket_count, tickets = Ticket.selectors(condition, 10, customer2)
|
||||
assert_equal( ticket_count, 1 )
|
||||
assert_equal(ticket_count, 2)
|
||||
|
||||
# invalid conditions
|
||||
assert_raise RuntimeError do
|
||||
|
@ -534,7 +574,7 @@ class TicketSelectorTest < ActiveSupport::TestCase
|
|||
},
|
||||
}
|
||||
ticket_count, tickets = Ticket.selectors(condition, 10, agent1)
|
||||
assert_equal( ticket_count, 2 )
|
||||
assert_equal(ticket_count, 3)
|
||||
|
||||
ticket_count, tickets = Ticket.selectors(condition, 10, agent2)
|
||||
assert_equal(ticket_count, 0)
|
||||
|
@ -543,7 +583,7 @@ class TicketSelectorTest < ActiveSupport::TestCase
|
|||
assert_equal(ticket_count, 1)
|
||||
|
||||
ticket_count, tickets = Ticket.selectors(condition, 10, customer2)
|
||||
assert_equal( ticket_count, 1 )
|
||||
assert_equal(ticket_count, 2)
|
||||
|
||||
# search with organizations
|
||||
condition = {
|
||||
|
@ -678,7 +718,7 @@ class TicketSelectorTest < ActiveSupport::TestCase
|
|||
},
|
||||
}
|
||||
ticket_count, tickets = Ticket.selectors(condition, 10, agent1)
|
||||
assert_equal( ticket_count, 1 )
|
||||
assert_equal(ticket_count, 2)
|
||||
|
||||
ticket_count, tickets = Ticket.selectors(condition, 10, agent2)
|
||||
assert_equal(ticket_count, 0)
|
||||
|
@ -687,7 +727,7 @@ class TicketSelectorTest < ActiveSupport::TestCase
|
|||
assert_equal(ticket_count, 0)
|
||||
|
||||
ticket_count, tickets = Ticket.selectors(condition, 10, customer2)
|
||||
assert_equal( ticket_count, 1 )
|
||||
assert_equal(ticket_count, 2)
|
||||
|
||||
UserInfo.current_user_id = agent1.id
|
||||
condition = {
|
||||
|
@ -765,7 +805,7 @@ class TicketSelectorTest < ActiveSupport::TestCase
|
|||
assert_equal(ticket_count, 1)
|
||||
|
||||
ticket_count, tickets = Ticket.selectors(condition, 10, customer2)
|
||||
assert_equal( ticket_count, 1 )
|
||||
assert_equal(ticket_count, 2)
|
||||
|
||||
UserInfo.current_user_id = customer2.id
|
||||
condition = {
|
||||
|
@ -788,10 +828,10 @@ class TicketSelectorTest < ActiveSupport::TestCase
|
|||
assert_equal(ticket_count, 1)
|
||||
|
||||
ticket_count, tickets = Ticket.selectors(condition, 10, customer2)
|
||||
assert_equal( ticket_count, 1 )
|
||||
assert_equal(ticket_count, 2)
|
||||
|
||||
ticket_count, tickets = Ticket.selectors(condition, 10)
|
||||
assert_equal( ticket_count, 1 )
|
||||
assert_equal(ticket_count, 2)
|
||||
|
||||
UserInfo.current_user_id = customer1.id
|
||||
condition = {
|
||||
|
|
Loading…
Reference in a new issue