Refactoring search index backend.

This commit is contained in:
Martin Edenhofer 2016-07-06 08:13:44 +02:00
parent f6d0fb3596
commit 7f1ecaa67e
10 changed files with 473 additions and 375 deletions

View file

@ -17,27 +17,8 @@ returns
def search_index_update_backend
return if !self.class.search_index_support_config
# default ignored attributes
ignore_attributes = {}
if self.class.search_index_support_config[:ignore_attributes]
self.class.search_index_support_config[:ignore_attributes].each { |key, value|
ignore_attributes[key] = value
}
end
# for performance reasons, Model.search_index_reload will only collect if of object
# get whole data here
data = self.class.find(id)
# remove ignored attributes
attributes = data.attributes
ignore_attributes.each { |key, value|
next if value != true
attributes.delete(key.to_s)
}
# fill up with search data
attributes = search_index_attribute_lookup(attributes, data)
attributes = search_index_attribute_lookup
return if !attributes
# update backend
@ -53,16 +34,20 @@ get data to store in search index
returns
result = true # false
result = {
attribute1: 'some value',
attribute2: ['value 1', 'value 2'],
...
}
=end
def search_index_data
attributes = {}
%w(name note).each { |key|
if self[key] && !self[key].empty?
next if !self[key]
next if self[key].respond_to?('empty?') && self[key].empty?
attributes[key] = self[key]
end
}
return if attributes.empty?
attributes
@ -74,8 +59,8 @@ returns
lookup name of ref. objects
ticket = Ticket.find(123)
attributes = ticket.search_index_attribute_lookup(attributes, Ticket)
ticket = Ticket.find(3)
attributes = ticket.search_index_attribute_lookup
returns
@ -83,10 +68,10 @@ returns
=end
def search_index_attribute_lookup(attributes, ref_object)
def search_index_attribute_lookup
attributes_new = {}
attributes.each { |key, value|
attributes = self.attributes
self.attributes.each { |key, value|
next if !value
# get attribute name
@ -96,10 +81,10 @@ returns
attribute_name = attribute_name[ 0, attribute_name.length - 3 ]
# check if attribute method exists
next if !ref_object.respond_to?(attribute_name)
next if !respond_to?(attribute_name)
# check if method has own class
relation_class = ref_object.send(attribute_name).class
relation_class = send(attribute_name).class
next if !relation_class
# lookup ref object
@ -111,11 +96,34 @@ returns
if relation_model.respond_to?('search_index_data')
value = relation_model.send('search_index_data')
end
if relation_model.respond_to?('name')
value = relation_model.send('name')
end
next if !value
# save name of ref object
attributes_new[ attribute_name ] = value
attributes[ attribute_name ] = value
}
attributes_new.merge(attributes)
# default ignored attributes
config = self.class.search_index_support_config
if config
ignore_attributes = {}
if config[:ignore_attributes]
config[:ignore_attributes].each { |key, value|
ignore_attributes[key] = value
}
end
# remove ignored attributes
ignore_attributes.each { |key, value|
next if value != true
attributes.delete(key.to_s)
}
end
attributes
end
end

View file

@ -1,7 +1,7 @@
# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
class Observer::Transaction < ActiveRecord::Observer
observe :ticket, 'ticket::_article', :user, :organization
observe :ticket, 'ticket::_article', :user, :organization, :tag
def self.commit(params = {})
@ -206,13 +206,20 @@ class Observer::Transaction < ActiveRecord::Observer
# do not send anything if nothing has changed
return if real_changes.empty?
changed_by_id = nil
if record.respond_to?('updated_by_id')
changed_by_id = record.updated_by_id
else
changed_by_id = record.created_by_id
end
e = {
object: record.class.name,
type: 'update',
data: record,
changes: real_changes,
id: record.id,
user_id: record.updated_by_id,
user_id: changed_by_id,
}
EventBuffer.add('transaction', e)
end

View file

@ -5,6 +5,7 @@ class Organization < ApplicationModel
load 'organization/assets.rb'
include Organization::Assets
extend Organization::Search
load 'organization/search_index.rb'
include Organization::SearchIndex
has_and_belongs_to_many :users

View file

@ -8,7 +8,7 @@ class Organization
lookup name of ref. objects
organization = Organization.find(123)
attributes = organization.search_index_attribute_lookup(attributes, Organization)
attributes = organization.search_index_attribute_lookup
returns
@ -16,47 +16,17 @@ returns
=end
def search_index_attribute_lookup(attributes, ref_object)
attributes_new = {}
attributes.each { |key, value|
next if !value
def search_index_attribute_lookup
attributes = super
# get attribute name
attribute_name = key.to_s
next if attribute_name[-3, 3] != '_id'
attribute_name = attribute_name[ 0, attribute_name.length - 3 ]
# check if attribute method exists
next if !ref_object.respond_to?(attribute_name)
# check if method has own class
relation_class = ref_object.send(attribute_name).class
next if !relation_class
# lookup ref object
relation_model = relation_class.lookup(id: value)
next if !relation_model
# get name of ref object
value = nil
if relation_model.respond_to?('search_index_data')
value = relation_model.send('search_index_data')
end
next if !value
# save name of ref object
attributes_new[ attribute_name ] = value
attributes.delete(key)
}
# add org member for search index data
attributes['member'] = []
# add org members for search index data
attributes['members'] = []
users = User.where(organization_id: id)
users.each { |user|
attributes['member'].push user.search_index_data
attributes['members'].push user.search_index_data
}
attributes_new.merge(attributes)
attributes
end
end
end

View file

@ -108,10 +108,10 @@ returns
.where('groups.active = ?', true)
group_condition = []
groups.each { |group|
group_condition.push group.name
group_condition.push group.id
}
access_condition = {
'query_string' => { 'default_field' => 'Ticket.group.name', 'query' => "\"#{group_condition.join('" OR "')}\"" }
'query_string' => { 'default_field' => 'Ticket.group_id', 'query' => "\"#{group_condition.join('" OR "')}\"" }
}
else
access_condition = if !current_user.organization || ( !current_user.organization.shared || current_user.organization.shared == false )

View file

@ -3,48 +3,28 @@ module Ticket::SearchIndex
=begin
build and send data for search index to backend
lookup name of ref. objects
ticket = Ticket.find(123)
result = ticket.search_index_update_backend
result = ticket.search_index_attribute_lookup
returns
result = true # false
attributes # object with lookup data
=end
def search_index_update_backend
return if !self.class.search_index_support_config
# default ignored attributes
ignore_attributes = {}
if self.class.search_index_support_config[:ignore_attributes]
self.class.search_index_support_config[:ignore_attributes].each { |key, value|
ignore_attributes[key] = value
}
end
# for performance reasons, Model.search_index_reload will only collect if of object
# get whole data here
ticket = self.class.find(id)
# remove ignored attributes
attributes = ticket.attributes
ignore_attributes.each { |key, value|
next if value != true
attributes.delete( key.to_s )
}
def search_index_attribute_lookup
attributes = super
return if !attributes
# collect article data
# add tags
tags = Tag.tag_list( object: 'Ticket', o_id: id )
tags = Tag.tag_list(object: 'Ticket', o_id: id)
if tags && !tags.empty?
attributes[:tag] = tags
end
# lookup attributes of ref. objects (normally name and note)
attributes = search_index_attribute_lookup( attributes, ticket )
# list ignored file extentions
attachments_ignore = Setting.get('es_attachment_ignore') || [ '.png', '.jpg', '.jpeg', '.mpeg', '.mpg', '.mov', '.bin', '.exe' ]
@ -52,7 +32,7 @@ returns
attachment_max_size_in_mb = Setting.get('es_attachment_max_size_in_mb') || 40
# collect article data
articles = Ticket::Article.where( ticket_id: id )
articles = Ticket::Article.where(ticket_id: id)
attributes['articles'] = []
articles.each { |article|
article_attributes = article.attributes
@ -60,11 +40,11 @@ returns
# remove note needed attributes
ignore = %w(message_id_md5)
ignore.each { |attribute|
article_attributes.delete( attribute )
article_attributes.delete(attribute)
}
# lookup attributes of ref. objects (normally name and note)
article_attributes = search_index_attribute_lookup( article_attributes, article )
article_attributes = article.search_index_attribute_lookup
# index raw text body
if article_attributes['content_type'] && article_attributes['content_type'] == 'text/html' && article_attributes['body']
@ -87,18 +67,18 @@ returns
filename_extention = attachment.filename.downcase
filename_extention.gsub!(/^.*(\..+?)$/, '\\1')
next if attachments_ignore.include?( filename_extention.downcase )
next if attachments_ignore.include?(filename_extention.downcase)
data = {
'_name' => attachment.filename,
'_content' => Base64.encode64( attachment.content )
'_content' => Base64.encode64(attachment.content)
}
article_attributes['attachments'].push data
}
attributes['articles'].push article_attributes
}
return if !attributes
SearchIndexBackend.add(self.class.to_s, attributes)
attributes
end
end

View file

@ -28,6 +28,8 @@ class User < ApplicationModel
load 'user/assets.rb'
include User::Assets
extend User::Search
load 'user/search_index.rb'
include User::SearchIndex
before_create :check_name, :check_email, :check_login, :check_password, :check_preferences_default
before_update :check_password, :check_email, :check_login, :check_preferences_default

View file

@ -0,0 +1,50 @@
# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
class User
module SearchIndex
=begin
get data to store in search index
user = User.find(2)
result = user.search_index_data
returns
result = {
attribute1: 'some value',
attribute2: ['value 1', 'value 2'],
...
}
=end
def search_index_data
attributes = {}
self.attributes.each { |key, value|
next if key == 'created_at'
next if key == 'updated_at'
next if key == 'created_by_id'
next if key == 'updated_by_id'
next if key == 'preferences'
next if key == 'password'
next if !value
next if value.respond_to?('empty?') && value.empty?
attributes[key] = value
}
return if attributes.empty?
if attributes['organization_id']
organization = Organization.lookup(id: attributes['organization_id'])
if organization
attributes['organization'] = organization.name
attributes['organization_ref'] = organization.search_index_data
end
end
attributes
end
end
end

View file

@ -52,6 +52,7 @@ class ElasticsearchTest < ActiveSupport::TestCase
roles = Role.where(name: 'Customer')
organization1 = Organization.create_if_not_exists(
name: 'Customer Organization Update',
note: 'some note',
updated_by_id: 1,
created_by_id: 1,
)
@ -93,8 +94,87 @@ class ElasticsearchTest < ActiveSupport::TestCase
created_by_id: 1,
)
# check search attributes
test 'a - objects' do
# user
attributes = agent.search_index_data
assert_equal('E', attributes['firstname'])
assert_equal('S', attributes['lastname'])
assert_equal('es-agent@example.com', attributes['email'])
assert_not(attributes['password'])
assert_not(attributes['organization'])
attributes = agent.search_index_attribute_lookup
assert_equal('E', attributes['firstname'])
assert_equal('S', attributes['lastname'])
assert_equal('es-agent@example.com', attributes['email'])
assert_not(attributes['password'])
assert_not(attributes['organization'])
# organization
attributes = organization1.search_index_data
assert_equal('Customer Organization Update', attributes['name'])
assert_equal('some note', attributes['note'])
assert_not(attributes['members'])
attributes = organization1.search_index_attribute_lookup
assert_equal('Customer Organization Update', attributes['name'])
assert_equal('some note', attributes['note'])
assert(attributes['members'])
# ticket/article
ticket1 = Ticket.create(
title: 'some title äöüß',
group: Group.lookup(name: 'Users'),
customer_id: customer1.id,
state: Ticket::State.lookup(name: 'new'),
priority: Ticket::Priority.lookup(name: '2 normal'),
updated_by_id: 1,
created_by_id: 1,
)
article1 = Ticket::Article.create(
ticket_id: ticket1.id,
from: 'some_sender@example.com',
to: 'some_recipient@example.com',
subject: 'some subject',
message_id: 'some@id',
body: 'some message',
internal: false,
sender: Ticket::Article::Sender.where(name: 'Customer').first,
type: Ticket::Article::Type.where(name: 'email').first,
updated_by_id: 1,
created_by_id: 1,
)
attributes = ticket1.search_index_attribute_lookup
assert_equal('Users', attributes['group'])
assert_equal('new', attributes['state'])
assert_equal('2 normal', attributes['priority'])
assert_equal('ES', attributes['customer']['firstname'])
assert_equal('Customer1', attributes['customer']['lastname'])
assert_equal('es-customer1@example.com', attributes['customer']['email'])
assert_not(attributes['customer']['password'])
assert_equal('Customer Organization Update', attributes['customer']['organization'])
assert_equal('-', attributes['owner']['login'])
assert_equal('-', attributes['owner']['firstname'])
assert_not(attributes['owner']['password'])
assert_not(attributes['owner']['organization'])
ticket1.destroy
# execute background jobs
Scheduler.worker(true)
end
# check tickets and search it
test 'a - tickets' do
test 'b - tickets' do
system('rake searchindex:rebuild')
ticket1 = Ticket.create(
title: "some title\n äöüß",
@ -398,7 +478,7 @@ class ElasticsearchTest < ActiveSupport::TestCase
end
# check users and search it
test 'b - users' do
test 'c - users' do
# search as agent
result = User.search(

View file

@ -7,23 +7,23 @@ class TicketSlaTest < ActiveSupport::TestCase
# cleanup
delete = Sla.destroy_all
assert( delete, 'sla destroy_all' )
assert(delete, 'sla destroy_all')
delete = Ticket.destroy_all
assert( delete, 'ticket destroy_all' )
assert(delete, 'ticket destroy_all')
ticket = Ticket.create(
title: 'some title äöüß',
group: Group.lookup( name: 'Users'),
customer_id: 2,
state: Ticket::State.lookup( name: 'new' ),
priority: Ticket::Priority.lookup( name: '2 normal' ),
state: Ticket::State.lookup( name: 'new'),
priority: Ticket::Priority.lookup( name: '2 normal'),
created_at: '2013-03-21 09:30:00 UTC',
updated_at: '2013-03-21 09:30:00 UTC',
updated_by_id: 1,
created_by_id: 1,
)
assert( ticket, 'ticket created' )
assert_equal( ticket.escalation_time, nil, 'ticket.escalation_time verify' )
assert(ticket, 'ticket created')
assert_equal(ticket.escalation_time, nil, 'ticket.escalation_time verify')
calendar1 = Calendar.create_or_update(
name: 'EU 1',
@ -76,10 +76,10 @@ class TicketSlaTest < ActiveSupport::TestCase
)
Scheduler.worker(true)
ticket = Ticket.find(ticket.id)
assert_equal( ticket.escalation_time.gmtime.to_s, '2013-03-21 10:30:00 UTC', 'ticket.escalation_time verify 1' )
assert_equal( ticket.first_response_escal_date.gmtime.to_s, '2013-03-21 10:30:00 UTC', 'ticket.first_response_escal_date verify 1' )
assert_equal( ticket.update_time_escal_date.gmtime.to_s, '2013-03-21 12:30:00 UTC', 'ticket.update_time_escal_date verify 1' )
assert_equal( ticket.close_time_escal_date.gmtime.to_s, '2013-03-21 13:30:00 UTC', 'ticket.close_time_escal_date verify 1' )
assert_equal(ticket.escalation_time.gmtime.to_s, '2013-03-21 10:30:00 UTC', 'ticket.escalation_time verify 1')
assert_equal(ticket.first_response_escal_date.gmtime.to_s, '2013-03-21 10:30:00 UTC', 'ticket.first_response_escal_date verify 1')
assert_equal(ticket.update_time_escal_date.gmtime.to_s, '2013-03-21 12:30:00 UTC', 'ticket.update_time_escal_date verify 1')
assert_equal(ticket.close_time_escal_date.gmtime.to_s, '2013-03-21 13:30:00 UTC', 'ticket.close_time_escal_date verify 1')
sla = Sla.create_or_update(
name: 'test sla 1',
@ -93,12 +93,12 @@ class TicketSlaTest < ActiveSupport::TestCase
)
Scheduler.worker(true)
ticket = Ticket.find(ticket.id)
assert_equal( ticket.escalation_time.gmtime.to_s, '2013-03-21 11:30:00 UTC', 'ticket.escalation_time verify 1' )
assert_equal( ticket.first_response_escal_date.gmtime.to_s, '2013-03-21 11:30:00 UTC', 'ticket.first_response_escal_date verify 1' )
assert_equal( ticket.update_time_escal_date.gmtime.to_s, '2013-03-21 12:30:00 UTC', 'ticket.update_time_escal_date verify 1' )
assert_equal( ticket.close_time_escal_date.gmtime.to_s, '2013-03-21 13:30:00 UTC', 'ticket.close_time_escal_date verify 1' )
assert_equal(ticket.escalation_time.gmtime.to_s, '2013-03-21 11:30:00 UTC', 'ticket.escalation_time verify 1')
assert_equal(ticket.first_response_escal_date.gmtime.to_s, '2013-03-21 11:30:00 UTC', 'ticket.first_response_escal_date verify 1')
assert_equal(ticket.update_time_escal_date.gmtime.to_s, '2013-03-21 12:30:00 UTC', 'ticket.update_time_escal_date verify 1')
assert_equal(ticket.close_time_escal_date.gmtime.to_s, '2013-03-21 13:30:00 UTC', 'ticket.close_time_escal_date verify 1')
delete = sla.destroy
assert( delete, 'sla destroy 1' )
assert(delete, 'sla destroy 1')
calendar2 = Calendar.create_or_update(
name: 'EU 2',
@ -155,210 +155,210 @@ class TicketSlaTest < ActiveSupport::TestCase
)
Scheduler.worker(true)
ticket = Ticket.find(ticket.id)
assert_equal( ticket.escalation_time.gmtime.to_s, '2013-03-21 10:30:00 UTC', 'ticket.escalation_time verify 2' )
assert_equal( ticket.first_response_escal_date.gmtime.to_s, '2013-03-21 10:30:00 UTC', 'ticket.first_response_escal_date verify 2' )
assert_equal( ticket.first_response, nil, 'ticket.first_response verify 2' )
assert_equal( ticket.first_response_in_min, nil, 'ticket.first_response_in_min verify 2' )
assert_equal( ticket.first_response_diff_in_min, nil, 'ticket.first_response_diff_in_min verify 2' )
assert_equal(ticket.escalation_time.gmtime.to_s, '2013-03-21 10:30:00 UTC', 'ticket.escalation_time verify 2')
assert_equal(ticket.first_response_escal_date.gmtime.to_s, '2013-03-21 10:30:00 UTC', 'ticket.first_response_escal_date verify 2')
assert_equal(ticket.first_response, nil, 'ticket.first_response verify 2')
assert_equal(ticket.first_response_in_min, nil, 'ticket.first_response_in_min verify 2')
assert_equal(ticket.first_response_diff_in_min, nil, 'ticket.first_response_diff_in_min verify 2')
assert_equal( ticket.update_time_escal_date.gmtime.to_s, '2013-03-21 11:30:00 UTC', 'ticket.update_time_escal_date verify 2' )
assert_equal( ticket.update_time_in_min, nil, 'ticket.update_time_in_min verify 2' )
assert_equal( ticket.update_time_diff_in_min, nil, 'ticket.update_time_diff_in_min verify 2' )
assert_equal(ticket.update_time_escal_date.gmtime.to_s, '2013-03-21 11:30:00 UTC', 'ticket.update_time_escal_date verify 2')
assert_equal(ticket.update_time_in_min, nil, 'ticket.update_time_in_min verify 2')
assert_equal(ticket.update_time_diff_in_min, nil, 'ticket.update_time_diff_in_min verify 2')
assert_equal( ticket.close_time_escal_date.gmtime.to_s, '2013-03-21 12:30:00 UTC', 'ticket.close_time_escal_date verify 2' )
assert_equal( ticket.close_time_in_min, nil, 'ticket.close_time_in_min verify 2' )
assert_equal( ticket.close_time_diff_in_min, nil, 'ticket.close_time_diff_in_min verify 2' )
assert_equal(ticket.close_time_escal_date.gmtime.to_s, '2013-03-21 12:30:00 UTC', 'ticket.close_time_escal_date verify 2')
assert_equal(ticket.close_time_in_min, nil, 'ticket.close_time_in_min verify 2')
assert_equal(ticket.close_time_diff_in_min, nil, 'ticket.close_time_diff_in_min verify 2')
# set first response in time
ticket.update_attributes(
first_response: '2013-03-21 10:00:00 UTC',
)
assert_equal( ticket.escalation_time.gmtime.to_s, '2013-03-21 11:30:00 UTC', 'ticket.escalation_time verify 3' )
assert_equal( ticket.first_response_escal_date.gmtime.to_s, '2013-03-21 10:30:00 UTC', 'ticket.first_response_escal_date verify 3' )
assert_equal( ticket.first_response.gmtime.to_s, '2013-03-21 10:00:00 UTC', 'ticket.first_response verify 3' )
assert_equal( ticket.first_response_in_min, 30, 'ticket.first_response_in_min verify 3' )
assert_equal( ticket.first_response_diff_in_min, 30, 'ticket.first_response_diff_in_min verify 3' )
assert_equal(ticket.escalation_time.gmtime.to_s, '2013-03-21 11:30:00 UTC', 'ticket.escalation_time verify 3')
assert_equal(ticket.first_response_escal_date.gmtime.to_s, '2013-03-21 10:30:00 UTC', 'ticket.first_response_escal_date verify 3')
assert_equal(ticket.first_response.gmtime.to_s, '2013-03-21 10:00:00 UTC', 'ticket.first_response verify 3')
assert_equal(ticket.first_response_in_min, 30, 'ticket.first_response_in_min verify 3')
assert_equal(ticket.first_response_diff_in_min, 30, 'ticket.first_response_diff_in_min verify 3')
assert_equal( ticket.update_time_escal_date.gmtime.to_s, '2013-03-21 11:30:00 UTC', 'ticket.update_time_escal_date verify 3' )
assert_equal( ticket.update_time_in_min, nil, 'ticket.update_time_in_min verify 3' )
assert_equal( ticket.update_time_diff_in_min, nil, 'ticket.update_time_diff_in_min verify 3' )
assert_equal(ticket.update_time_escal_date.gmtime.to_s, '2013-03-21 11:30:00 UTC', 'ticket.update_time_escal_date verify 3')
assert_equal(ticket.update_time_in_min, nil, 'ticket.update_time_in_min verify 3')
assert_equal(ticket.update_time_diff_in_min, nil, 'ticket.update_time_diff_in_min verify 3')
assert_equal( ticket.close_time_escal_date.gmtime.to_s, '2013-03-21 12:30:00 UTC', 'ticket.close_time_escal_date verify 3' )
assert_equal( ticket.close_time_in_min, nil, 'ticket.close_time_in_min verify 3' )
assert_equal( ticket.close_time_diff_in_min, nil, 'ticket.close_time_diff_in_min verify 3' )
assert_equal(ticket.close_time_escal_date.gmtime.to_s, '2013-03-21 12:30:00 UTC', 'ticket.close_time_escal_date verify 3')
assert_equal(ticket.close_time_in_min, nil, 'ticket.close_time_in_min verify 3')
assert_equal(ticket.close_time_diff_in_min, nil, 'ticket.close_time_diff_in_min verify 3')
# set first reponse over time
ticket.update_attributes(
first_response: '2013-03-21 14:00:00 UTC',
)
assert_equal( ticket.escalation_time.gmtime.to_s, '2013-03-21 11:30:00 UTC', 'ticket.escalation_time verify 4' )
assert_equal( ticket.first_response_escal_date.gmtime.to_s, '2013-03-21 10:30:00 UTC', 'ticket.first_response_escal_date verify 4' )
assert_equal( ticket.first_response.gmtime.to_s, '2013-03-21 14:00:00 UTC', 'ticket.first_response verify 4' )
assert_equal( ticket.first_response_in_min, 270, 'ticket.first_response_in_min verify 4' )
assert_equal( ticket.first_response_diff_in_min, -210, 'ticket.first_response_diff_in_min verify 4' )
assert_equal(ticket.escalation_time.gmtime.to_s, '2013-03-21 11:30:00 UTC', 'ticket.escalation_time verify 4')
assert_equal(ticket.first_response_escal_date.gmtime.to_s, '2013-03-21 10:30:00 UTC', 'ticket.first_response_escal_date verify 4')
assert_equal(ticket.first_response.gmtime.to_s, '2013-03-21 14:00:00 UTC', 'ticket.first_response verify 4')
assert_equal(ticket.first_response_in_min, 270, 'ticket.first_response_in_min verify 4')
assert_equal(ticket.first_response_diff_in_min, -210, 'ticket.first_response_diff_in_min verify 4')
assert_equal( ticket.update_time_escal_date.gmtime.to_s, '2013-03-21 11:30:00 UTC', 'ticket.update_time_escal_date verify 4' )
assert_equal( ticket.update_time_in_min, nil, 'ticket.update_time_in_min verify 4' )
assert_equal( ticket.update_time_diff_in_min, nil, 'ticket.update_time_diff_in_min verify 4' )
assert_equal(ticket.update_time_escal_date.gmtime.to_s, '2013-03-21 11:30:00 UTC', 'ticket.update_time_escal_date verify 4')
assert_equal(ticket.update_time_in_min, nil, 'ticket.update_time_in_min verify 4')
assert_equal(ticket.update_time_diff_in_min, nil, 'ticket.update_time_diff_in_min verify 4')
assert_equal( ticket.close_time_escal_date.gmtime.to_s, '2013-03-21 12:30:00 UTC', 'ticket.close_time_escal_date verify 4' )
assert_equal( ticket.close_time_in_min, nil, 'ticket.close_time_in_min verify 4' )
assert_equal( ticket.close_time_diff_in_min, nil, 'ticket.close_time_diff_in_min verify 4' )
assert_equal(ticket.close_time_escal_date.gmtime.to_s, '2013-03-21 12:30:00 UTC', 'ticket.close_time_escal_date verify 4')
assert_equal(ticket.close_time_in_min, nil, 'ticket.close_time_in_min verify 4')
assert_equal(ticket.close_time_diff_in_min, nil, 'ticket.close_time_diff_in_min verify 4')
# set update time in time
ticket.update_attributes(
last_contact_agent: '2013-03-21 11:00:00 UTC',
)
assert_equal( ticket.escalation_time.gmtime.to_s, '2013-03-21 12:30:00 UTC', 'ticket.escalation_time verify 5' )
assert_equal(ticket.escalation_time.gmtime.to_s, '2013-03-21 12:30:00 UTC', 'ticket.escalation_time verify 5')
assert_equal( ticket.first_response_escal_date.gmtime.to_s, '2013-03-21 10:30:00 UTC', 'ticket.first_response_escal_date verify 5' )
assert_equal( ticket.first_response.gmtime.to_s, '2013-03-21 14:00:00 UTC', 'ticket.first_response verify 5' )
assert_equal( ticket.first_response_in_min, 270, 'ticket.first_response_in_min verify 5' )
assert_equal( ticket.first_response_diff_in_min, -210, 'ticket.first_response_diff_in_min verify 5' )
assert_equal(ticket.first_response_escal_date.gmtime.to_s, '2013-03-21 10:30:00 UTC', 'ticket.first_response_escal_date verify 5')
assert_equal(ticket.first_response.gmtime.to_s, '2013-03-21 14:00:00 UTC', 'ticket.first_response verify 5')
assert_equal(ticket.first_response_in_min, 270, 'ticket.first_response_in_min verify 5')
assert_equal(ticket.first_response_diff_in_min, -210, 'ticket.first_response_diff_in_min verify 5')
assert_equal( ticket.update_time_escal_date.gmtime.to_s, '2013-03-21 13:00:00 UTC', 'ticket.update_time_escal_date verify 5' )
assert_equal( ticket.update_time_in_min, 90, 'ticket.update_time_in_min verify 5' )
assert_equal( ticket.update_time_diff_in_min, 30, 'ticket.update_time_diff_in_min verify 5' )
assert_equal(ticket.update_time_escal_date.gmtime.to_s, '2013-03-21 13:00:00 UTC', 'ticket.update_time_escal_date verify 5')
assert_equal(ticket.update_time_in_min, 90, 'ticket.update_time_in_min verify 5')
assert_equal(ticket.update_time_diff_in_min, 30, 'ticket.update_time_diff_in_min verify 5')
assert_equal( ticket.close_time_escal_date.gmtime.to_s, '2013-03-21 12:30:00 UTC', 'ticket.close_time_escal_date verify 5' )
assert_equal( ticket.close_time_in_min, nil, 'ticket.close_time_in_min verify 5' )
assert_equal( ticket.close_time_diff_in_min, nil, 'ticket.close_time_diff_in_min verify 5' )
assert_equal(ticket.close_time_escal_date.gmtime.to_s, '2013-03-21 12:30:00 UTC', 'ticket.close_time_escal_date verify 5')
assert_equal(ticket.close_time_in_min, nil, 'ticket.close_time_in_min verify 5')
assert_equal(ticket.close_time_diff_in_min, nil, 'ticket.close_time_diff_in_min verify 5')
# set update time over time
ticket.update_attributes(
last_contact_agent: '2013-03-21 12:00:00 UTC',
)
assert_equal( ticket.escalation_time.gmtime.to_s, '2013-03-21 12:30:00 UTC', 'ticket.escalation_time verify 6' )
assert_equal(ticket.escalation_time.gmtime.to_s, '2013-03-21 12:30:00 UTC', 'ticket.escalation_time verify 6')
assert_equal( ticket.first_response_escal_date.gmtime.to_s, '2013-03-21 10:30:00 UTC', 'ticket.first_response_escal_date verify 6' )
assert_equal( ticket.first_response.gmtime.to_s, '2013-03-21 14:00:00 UTC', 'ticket.first_response verify 6' )
assert_equal( ticket.first_response_in_min, 270, 'ticket.first_response_in_min verify 6' )
assert_equal( ticket.first_response_diff_in_min, -210, 'ticket.first_response_diff_in_min verify 6' )
assert_equal(ticket.first_response_escal_date.gmtime.to_s, '2013-03-21 10:30:00 UTC', 'ticket.first_response_escal_date verify 6')
assert_equal(ticket.first_response.gmtime.to_s, '2013-03-21 14:00:00 UTC', 'ticket.first_response verify 6')
assert_equal(ticket.first_response_in_min, 270, 'ticket.first_response_in_min verify 6')
assert_equal(ticket.first_response_diff_in_min, -210, 'ticket.first_response_diff_in_min verify 6')
assert_equal( ticket.update_time_escal_date.gmtime.to_s, '2013-03-21 14:00:00 UTC', 'ticket.update_time_escal_date verify 6' )
assert_equal( ticket.update_time_in_min, 150, 'ticket.update_time_in_min verify 6' )
assert_equal( ticket.update_time_diff_in_min, -30, 'ticket.update_time_diff_in_min verify 6' )
assert_equal(ticket.update_time_escal_date.gmtime.to_s, '2013-03-21 14:00:00 UTC', 'ticket.update_time_escal_date verify 6')
assert_equal(ticket.update_time_in_min, 150, 'ticket.update_time_in_min verify 6')
assert_equal(ticket.update_time_diff_in_min, -30, 'ticket.update_time_diff_in_min verify 6')
assert_equal( ticket.close_time_escal_date.gmtime.to_s, '2013-03-21 12:30:00 UTC', 'ticket.close_time_escal_date verify 6' )
assert_equal( ticket.close_time_in_min, nil, 'ticket.close_time_in_min verify 6' )
assert_equal( ticket.close_time_diff_in_min, nil, 'ticket.close_time_diff_in_min verify 6' )
assert_equal(ticket.close_time_escal_date.gmtime.to_s, '2013-03-21 12:30:00 UTC', 'ticket.close_time_escal_date verify 6')
assert_equal(ticket.close_time_in_min, nil, 'ticket.close_time_in_min verify 6')
assert_equal(ticket.close_time_diff_in_min, nil, 'ticket.close_time_diff_in_min verify 6')
# set update time over time
ticket.update_attributes(
last_contact_customer: '2013-03-21 12:05:00 UTC',
)
assert_equal( ticket.escalation_time.gmtime.to_s, '2013-03-21 12:30:00 UTC', 'ticket.escalation_time verify 6' )
assert_equal(ticket.escalation_time.gmtime.to_s, '2013-03-21 12:30:00 UTC', 'ticket.escalation_time verify 6')
assert_equal( ticket.first_response_escal_date.gmtime.to_s, '2013-03-21 10:30:00 UTC', 'ticket.first_response_escal_date verify 6' )
assert_equal( ticket.first_response.gmtime.to_s, '2013-03-21 14:00:00 UTC', 'ticket.first_response verify 6' )
assert_equal( ticket.first_response_in_min, 270, 'ticket.first_response_in_min verify 6' )
assert_equal( ticket.first_response_diff_in_min, -210, 'ticket.first_response_diff_in_min verify 6' )
assert_equal(ticket.first_response_escal_date.gmtime.to_s, '2013-03-21 10:30:00 UTC', 'ticket.first_response_escal_date verify 6')
assert_equal(ticket.first_response.gmtime.to_s, '2013-03-21 14:00:00 UTC', 'ticket.first_response verify 6')
assert_equal(ticket.first_response_in_min, 270, 'ticket.first_response_in_min verify 6')
assert_equal(ticket.first_response_diff_in_min, -210, 'ticket.first_response_diff_in_min verify 6')
assert_equal( ticket.update_time_escal_date.gmtime.to_s, '2013-03-21 14:05:00 UTC', 'ticket.update_time_escal_date verify 6' )
assert_equal( ticket.update_time_in_min, 155, 'ticket.update_time_in_min verify 6' )
assert_equal( ticket.update_time_diff_in_min, -35, 'ticket.update_time_diff_in_min verify 6' )
assert_equal(ticket.update_time_escal_date.gmtime.to_s, '2013-03-21 14:05:00 UTC', 'ticket.update_time_escal_date verify 6')
assert_equal(ticket.update_time_in_min, 155, 'ticket.update_time_in_min verify 6')
assert_equal(ticket.update_time_diff_in_min, -35, 'ticket.update_time_diff_in_min verify 6')
assert_equal( ticket.close_time_escal_date.gmtime.to_s, '2013-03-21 12:30:00 UTC', 'ticket.close_time_escal_date verify 6' )
assert_equal( ticket.close_time_in_min, nil, 'ticket.close_time_in_min verify 6' )
assert_equal( ticket.close_time_diff_in_min, nil, 'ticket.close_time_diff_in_min verify 6' )
assert_equal(ticket.close_time_escal_date.gmtime.to_s, '2013-03-21 12:30:00 UTC', 'ticket.close_time_escal_date verify 6')
assert_equal(ticket.close_time_in_min, nil, 'ticket.close_time_in_min verify 6')
assert_equal(ticket.close_time_diff_in_min, nil, 'ticket.close_time_diff_in_min verify 6')
# set update time over time
ticket.update_attributes(
last_contact_agent: '2013-03-21 12:10:00 UTC',
)
assert_equal( ticket.escalation_time.gmtime.to_s, '2013-03-21 12:30:00 UTC', 'ticket.escalation_time verify 6' )
assert_equal(ticket.escalation_time.gmtime.to_s, '2013-03-21 12:30:00 UTC', 'ticket.escalation_time verify 6')
assert_equal( ticket.first_response_escal_date.gmtime.to_s, '2013-03-21 10:30:00 UTC', 'ticket.first_response_escal_date verify 6' )
assert_equal( ticket.first_response.gmtime.to_s, '2013-03-21 14:00:00 UTC', 'ticket.first_response verify 6' )
assert_equal( ticket.first_response_in_min, 270, 'ticket.first_response_in_min verify 6' )
assert_equal( ticket.first_response_diff_in_min, -210, 'ticket.first_response_diff_in_min verify 6' )
assert_equal(ticket.first_response_escal_date.gmtime.to_s, '2013-03-21 10:30:00 UTC', 'ticket.first_response_escal_date verify 6')
assert_equal(ticket.first_response.gmtime.to_s, '2013-03-21 14:00:00 UTC', 'ticket.first_response verify 6')
assert_equal(ticket.first_response_in_min, 270, 'ticket.first_response_in_min verify 6')
assert_equal(ticket.first_response_diff_in_min, -210, 'ticket.first_response_diff_in_min verify 6')
assert_equal( ticket.update_time_escal_date.gmtime.to_s, '2013-03-21 14:10:00 UTC', 'ticket.update_time_escal_date verify 6' )
assert_equal( ticket.update_time_in_min, 160, 'ticket.update_time_in_min verify 6' )
assert_equal( ticket.update_time_diff_in_min, -40, 'ticket.update_time_diff_in_min verify 6' )
assert_equal(ticket.update_time_escal_date.gmtime.to_s, '2013-03-21 14:10:00 UTC', 'ticket.update_time_escal_date verify 6')
assert_equal(ticket.update_time_in_min, 160, 'ticket.update_time_in_min verify 6')
assert_equal(ticket.update_time_diff_in_min, -40, 'ticket.update_time_diff_in_min verify 6')
assert_equal( ticket.close_time_escal_date.gmtime.to_s, '2013-03-21 12:30:00 UTC', 'ticket.close_time_escal_date verify 6' )
assert_equal( ticket.close_time_in_min, nil, 'ticket.close_time_in_min verify 6' )
assert_equal( ticket.close_time_diff_in_min, nil, 'ticket.close_time_diff_in_min verify 6' )
assert_equal(ticket.close_time_escal_date.gmtime.to_s, '2013-03-21 12:30:00 UTC', 'ticket.close_time_escal_date verify 6')
assert_equal(ticket.close_time_in_min, nil, 'ticket.close_time_in_min verify 6')
assert_equal(ticket.close_time_diff_in_min, nil, 'ticket.close_time_diff_in_min verify 6')
# set close time in time
ticket.update_attributes(
close_time: '2013-03-21 11:30:00 UTC',
)
assert_equal( ticket.escalation_time.gmtime.to_s, '2013-03-21 14:10:00 UTC', 'ticket.escalation_time verify 7' )
assert_equal(ticket.escalation_time.gmtime.to_s, '2013-03-21 14:10:00 UTC', 'ticket.escalation_time verify 7')
assert_equal( ticket.first_response_escal_date.gmtime.to_s, '2013-03-21 10:30:00 UTC', 'ticket.first_response_escal_date verify 7' )
assert_equal( ticket.first_response.gmtime.to_s, '2013-03-21 14:00:00 UTC', 'ticket.first_response verify 7' )
assert_equal( ticket.first_response_in_min, 270, 'ticket.first_response_in_min verify 7' )
assert_equal( ticket.first_response_diff_in_min, -210, 'ticket.first_response_diff_in_min verify 7' )
assert_equal(ticket.first_response_escal_date.gmtime.to_s, '2013-03-21 10:30:00 UTC', 'ticket.first_response_escal_date verify 7')
assert_equal(ticket.first_response.gmtime.to_s, '2013-03-21 14:00:00 UTC', 'ticket.first_response verify 7')
assert_equal(ticket.first_response_in_min, 270, 'ticket.first_response_in_min verify 7')
assert_equal(ticket.first_response_diff_in_min, -210, 'ticket.first_response_diff_in_min verify 7')
assert_equal( ticket.update_time_escal_date.gmtime.to_s, '2013-03-21 14:10:00 UTC', 'ticket.update_time_escal_date verify 7' )
assert_equal( ticket.update_time_in_min, 160, 'ticket.update_time_in_min verify 7' )
assert_equal( ticket.update_time_diff_in_min, -40, 'ticket.update_time_diff_in_min verify 7' )
assert_equal(ticket.update_time_escal_date.gmtime.to_s, '2013-03-21 14:10:00 UTC', 'ticket.update_time_escal_date verify 7')
assert_equal(ticket.update_time_in_min, 160, 'ticket.update_time_in_min verify 7')
assert_equal(ticket.update_time_diff_in_min, -40, 'ticket.update_time_diff_in_min verify 7')
assert_equal( ticket.close_time_escal_date.gmtime.to_s, '2013-03-21 12:30:00 UTC', 'ticket.close_time_escal_date verify 7' )
assert_equal( ticket.close_time_in_min, 120, 'ticket.close_time_in_min verify 7' )
assert_equal( ticket.close_time_diff_in_min, 60, 'ticket.close_time_diff_in_min verify 7' )
assert_equal(ticket.close_time_escal_date.gmtime.to_s, '2013-03-21 12:30:00 UTC', 'ticket.close_time_escal_date verify 7')
assert_equal(ticket.close_time_in_min, 120, 'ticket.close_time_in_min verify 7')
assert_equal(ticket.close_time_diff_in_min, 60, 'ticket.close_time_diff_in_min verify 7')
# set close time over time
ticket.update_attributes(
close_time: '2013-03-21 13:00:00 UTC',
)
assert_equal( ticket.escalation_time.gmtime.to_s, '2013-03-21 14:10:00 UTC', 'ticket.escalation_time verify 8' )
assert_equal(ticket.escalation_time.gmtime.to_s, '2013-03-21 14:10:00 UTC', 'ticket.escalation_time verify 8')
assert_equal( ticket.first_response_escal_date.gmtime.to_s, '2013-03-21 10:30:00 UTC', 'ticket.first_response_escal_date verify 8' )
assert_equal( ticket.first_response.gmtime.to_s, '2013-03-21 14:00:00 UTC', 'ticket.first_response verify 8' )
assert_equal( ticket.first_response_in_min, 270, 'ticket.first_response_in_min verify 8' )
assert_equal( ticket.first_response_diff_in_min, -210, 'ticket.first_response_diff_in_min verify 8' )
assert_equal(ticket.first_response_escal_date.gmtime.to_s, '2013-03-21 10:30:00 UTC', 'ticket.first_response_escal_date verify 8')
assert_equal(ticket.first_response.gmtime.to_s, '2013-03-21 14:00:00 UTC', 'ticket.first_response verify 8')
assert_equal(ticket.first_response_in_min, 270, 'ticket.first_response_in_min verify 8')
assert_equal(ticket.first_response_diff_in_min, -210, 'ticket.first_response_diff_in_min verify 8')
assert_equal( ticket.update_time_escal_date.gmtime.to_s, '2013-03-21 14:10:00 UTC', 'ticket.update_time_escal_date verify 8' )
assert_equal( ticket.update_time_in_min, 160, 'ticket.update_time_in_min verify 8' )
assert_equal( ticket.update_time_diff_in_min, -40, 'ticket.update_time_diff_in_min verify 8' )
assert_equal(ticket.update_time_escal_date.gmtime.to_s, '2013-03-21 14:10:00 UTC', 'ticket.update_time_escal_date verify 8')
assert_equal(ticket.update_time_in_min, 160, 'ticket.update_time_in_min verify 8')
assert_equal(ticket.update_time_diff_in_min, -40, 'ticket.update_time_diff_in_min verify 8')
assert_equal( ticket.close_time_escal_date.gmtime.to_s, '2013-03-21 12:30:00 UTC', 'ticket.close_time_escal_date verify 8' )
assert_equal( ticket.close_time_in_min, 210, 'ticket.close_time_in_min verify 8' )
assert_equal( ticket.close_time_diff_in_min, -30, 'ticket.close_time_diff_in_min verify 8' )
assert_equal(ticket.close_time_escal_date.gmtime.to_s, '2013-03-21 12:30:00 UTC', 'ticket.close_time_escal_date verify 8')
assert_equal(ticket.close_time_in_min, 210, 'ticket.close_time_in_min verify 8')
assert_equal(ticket.close_time_diff_in_min, -30, 'ticket.close_time_diff_in_min verify 8')
# set close time over time
ticket.update_attributes(
state: Ticket::State.lookup( name: 'closed' )
state: Ticket::State.lookup( name: 'closed')
)
assert_equal( ticket.escalation_time, nil, 'ticket.escalation_time verify 9' )
assert_equal(ticket.escalation_time, nil, 'ticket.escalation_time verify 9')
assert_equal( ticket.first_response_escal_date.gmtime.to_s, '2013-03-21 10:30:00 UTC', 'ticket.first_response_escal_date verify 9' )
assert_equal( ticket.first_response.gmtime.to_s, '2013-03-21 14:00:00 UTC', 'ticket.first_response verify 9' )
assert_equal( ticket.first_response_in_min, 270, 'ticket.first_response_in_min verify 9' )
assert_equal( ticket.first_response_diff_in_min, -210, 'ticket.first_response_diff_in_min verify 9' )
assert_equal(ticket.first_response_escal_date.gmtime.to_s, '2013-03-21 10:30:00 UTC', 'ticket.first_response_escal_date verify 9')
assert_equal(ticket.first_response.gmtime.to_s, '2013-03-21 14:00:00 UTC', 'ticket.first_response verify 9')
assert_equal(ticket.first_response_in_min, 270, 'ticket.first_response_in_min verify 9')
assert_equal(ticket.first_response_diff_in_min, -210, 'ticket.first_response_diff_in_min verify 9')
assert_equal( ticket.update_time_escal_date.gmtime.to_s, '2013-03-21 14:10:00 UTC', 'ticket.update_time_escal_date verify 9' )
assert_equal( ticket.update_time_in_min, 160, 'ticket.update_time_in_min verify 9' )
assert_equal( ticket.update_time_diff_in_min, -40, 'ticket.update_time_diff_in_min verify 9' )
assert_equal(ticket.update_time_escal_date.gmtime.to_s, '2013-03-21 14:10:00 UTC', 'ticket.update_time_escal_date verify 9')
assert_equal(ticket.update_time_in_min, 160, 'ticket.update_time_in_min verify 9')
assert_equal(ticket.update_time_diff_in_min, -40, 'ticket.update_time_diff_in_min verify 9')
assert_equal( ticket.close_time_escal_date.gmtime.to_s, '2013-03-21 12:30:00 UTC', 'ticket.close_time_escal_date verify 9' )
assert_equal( ticket.close_time_in_min, 210, 'ticket.close_time_in_min verify 9' )
assert_equal( ticket.close_time_diff_in_min, -30, 'ticket.close_time_diff_in_min verify 9' )
assert_equal(ticket.close_time_escal_date.gmtime.to_s, '2013-03-21 12:30:00 UTC', 'ticket.close_time_escal_date verify 9')
assert_equal(ticket.close_time_in_min, 210, 'ticket.close_time_in_min verify 9')
assert_equal(ticket.close_time_diff_in_min, -30, 'ticket.close_time_diff_in_min verify 9')
delete = ticket.destroy
assert( delete, 'ticket destroy' )
assert(delete, 'ticket destroy')
ticket = Ticket.create(
title: 'some title äöüß',
group: Group.lookup( name: 'Users'),
customer_id: 2,
state: Ticket::State.lookup( name: 'new' ),
priority: Ticket::Priority.lookup( name: '2 normal' ),
state: Ticket::State.lookup( name: 'new'),
priority: Ticket::Priority.lookup( name: '2 normal'),
updated_by_id: 1,
created_by_id: 1,
created_at: '2013-03-28 23:49:00 UTC',
updated_at: '2013-03-28 23:49:00 UTC',
)
assert( ticket, 'ticket created' )
assert(ticket, 'ticket created')
assert_equal( ticket.title, 'some title äöüß', 'ticket.title verify' )
assert_equal( ticket.group.name, 'Users', 'ticket.group verify' )
assert_equal( ticket.state.name, 'new', 'ticket.state verify' )
assert_equal(ticket.title, 'some title äöüß', 'ticket.title verify')
assert_equal(ticket.group.name, 'Users', 'ticket.group verify')
assert_equal(ticket.state.name, 'new', 'ticket.state verify')
# create inbound article
article_inbound = Ticket::Article.create(
@ -377,12 +377,12 @@ class TicketSlaTest < ActiveSupport::TestCase
updated_at: '2013-03-28 23:49:00 UTC',
)
ticket = Ticket.find(ticket.id)
assert_equal( ticket.article_count, 1, 'ticket.article_count verify - inbound' )
assert_equal( ticket.last_contact.to_s, article_inbound.created_at.to_s, 'ticket.last_contact verify - inbound' )
assert_equal( ticket.last_contact_customer.to_s, article_inbound.created_at.to_s, 'ticket.last_contact_customer verify - inbound' )
assert_equal( ticket.last_contact_agent, nil, 'ticket.last_contact_agent verify - inbound' )
assert_equal( ticket.first_response, nil, 'ticket.first_response verify - inbound' )
assert_equal( ticket.close_time, nil, 'ticket.close_time verify - inbound' )
assert_equal(ticket.article_count, 1, 'ticket.article_count verify - inbound')
assert_equal(ticket.last_contact.to_s, article_inbound.created_at.to_s, 'ticket.last_contact verify - inbound')
assert_equal(ticket.last_contact_customer.to_s, article_inbound.created_at.to_s, 'ticket.last_contact_customer verify - inbound')
assert_equal(ticket.last_contact_agent, nil, 'ticket.last_contact_agent verify - inbound')
assert_equal(ticket.first_response, nil, 'ticket.first_response verify - inbound')
assert_equal(ticket.close_time, nil, 'ticket.close_time verify - inbound')
# create outbound article
article_outbound = Ticket::Article.create(
@ -402,34 +402,34 @@ class TicketSlaTest < ActiveSupport::TestCase
)
ticket = Ticket.find(ticket.id)
assert_equal( ticket.article_count, 2, 'ticket.article_count verify - outbound' )
assert_equal( ticket.last_contact.to_s, article_outbound.created_at.to_s, 'ticket.last_contact verify - outbound' )
assert_equal( ticket.last_contact_customer.to_s, article_inbound.created_at.to_s, 'ticket.last_contact_customer verify - outbound' )
assert_equal( ticket.last_contact_agent.to_s, article_outbound.created_at.to_s, 'ticket.last_contact_agent verify - outbound' )
assert_equal( ticket.first_response.to_s, article_outbound.created_at.to_s, 'ticket.first_response verify - outbound' )
assert_equal( ticket.first_response_in_min, 0, 'ticket.first_response_in_min verify - outbound' )
assert_equal( ticket.first_response_diff_in_min, 60, 'ticket.first_response_diff_in_min verify - outbound' )
assert_equal( ticket.close_time, nil, 'ticket.close_time verify - outbound' )
assert_equal(ticket.article_count, 2, 'ticket.article_count verify - outbound')
assert_equal(ticket.last_contact.to_s, article_outbound.created_at.to_s, 'ticket.last_contact verify - outbound')
assert_equal(ticket.last_contact_customer.to_s, article_inbound.created_at.to_s, 'ticket.last_contact_customer verify - outbound')
assert_equal(ticket.last_contact_agent.to_s, article_outbound.created_at.to_s, 'ticket.last_contact_agent verify - outbound')
assert_equal(ticket.first_response.to_s, article_outbound.created_at.to_s, 'ticket.first_response verify - outbound')
assert_equal(ticket.first_response_in_min, 0, 'ticket.first_response_in_min verify - outbound')
assert_equal(ticket.first_response_diff_in_min, 60, 'ticket.first_response_diff_in_min verify - outbound')
assert_equal(ticket.close_time, nil, 'ticket.close_time verify - outbound')
delete = ticket.destroy
assert( delete, 'ticket destroy' )
assert(delete, 'ticket destroy')
ticket = Ticket.create(
title: 'some title äöüß',
group: Group.lookup( name: 'Users'),
customer_id: 2,
state: Ticket::State.lookup( name: 'new' ),
priority: Ticket::Priority.lookup( name: '2 normal' ),
state: Ticket::State.lookup( name: 'new'),
priority: Ticket::Priority.lookup( name: '2 normal'),
updated_by_id: 1,
created_by_id: 1,
created_at: '2013-03-28 23:49:00 UTC',
updated_at: '2013-03-28 23:49:00 UTC',
)
assert( ticket, 'ticket created' )
assert(ticket, 'ticket created')
assert_equal( ticket.title, 'some title äöüß', 'ticket.title verify' )
assert_equal( ticket.group.name, 'Users', 'ticket.group verify' )
assert_equal( ticket.state.name, 'new', 'ticket.state verify' )
assert_equal(ticket.title, 'some title äöüß', 'ticket.title verify')
assert_equal(ticket.group.name, 'Users', 'ticket.group verify')
assert_equal(ticket.state.name, 'new', 'ticket.state verify')
# create inbound article
article_inbound = Ticket::Article.create(
@ -447,12 +447,12 @@ class TicketSlaTest < ActiveSupport::TestCase
updated_at: '2013-03-28 23:49:00 UTC',
)
ticket = Ticket.find(ticket.id)
assert_equal( ticket.article_count, 1, 'ticket.article_count verify - inbound' )
assert_equal( ticket.last_contact.to_s, article_inbound.created_at.to_s, 'ticket.last_contact verify - inbound' )
assert_equal( ticket.last_contact_customer.to_s, article_inbound.created_at.to_s, 'ticket.last_contact_customer verify - inbound' )
assert_equal( ticket.last_contact_agent, nil, 'ticket.last_contact_agent verify - inbound' )
assert_equal( ticket.first_response, nil, 'ticket.first_response verify - inbound' )
assert_equal( ticket.close_time, nil, 'ticket.close_time verify - inbound' )
assert_equal(ticket.article_count, 1, 'ticket.article_count verify - inbound')
assert_equal(ticket.last_contact.to_s, article_inbound.created_at.to_s, 'ticket.last_contact verify - inbound')
assert_equal(ticket.last_contact_customer.to_s, article_inbound.created_at.to_s, 'ticket.last_contact_customer verify - inbound')
assert_equal(ticket.last_contact_agent, nil, 'ticket.last_contact_agent verify - inbound')
assert_equal(ticket.first_response, nil, 'ticket.first_response verify - inbound')
assert_equal(ticket.close_time, nil, 'ticket.close_time verify - inbound')
# create note article
article_note = Ticket::Article.create(
@ -470,12 +470,12 @@ class TicketSlaTest < ActiveSupport::TestCase
updated_at: '2013-03-28 23:52:00 UTC',
)
ticket = Ticket.find(ticket.id)
assert_equal( ticket.article_count, 2, 'ticket.article_count verify - inbound' )
assert_equal( ticket.last_contact.to_s, article_inbound.created_at.to_s, 'ticket.last_contact verify - inbound' )
assert_equal( ticket.last_contact_customer.to_s, article_inbound.created_at.to_s, 'ticket.last_contact_customer verify - inbound' )
assert_equal( ticket.last_contact_agent, nil, 'ticket.last_contact_agent verify - inbound' )
assert_equal( ticket.first_response, nil, 'ticket.first_response verify - inbound' )
assert_equal( ticket.close_time, nil, 'ticket.close_time verify - inbound' )
assert_equal(ticket.article_count, 2, 'ticket.article_count verify - inbound')
assert_equal(ticket.last_contact.to_s, article_inbound.created_at.to_s, 'ticket.last_contact verify - inbound')
assert_equal(ticket.last_contact_customer.to_s, article_inbound.created_at.to_s, 'ticket.last_contact_customer verify - inbound')
assert_equal(ticket.last_contact_agent, nil, 'ticket.last_contact_agent verify - inbound')
assert_equal(ticket.first_response, nil, 'ticket.first_response verify - inbound')
assert_equal(ticket.close_time, nil, 'ticket.close_time verify - inbound')
# create outbound article
article_outbound = Ticket::Article.create(
@ -493,41 +493,41 @@ class TicketSlaTest < ActiveSupport::TestCase
updated_at: '2013-03-28 23:55:00 UTC',
)
ticket = Ticket.find(ticket.id)
assert_equal( ticket.article_count, 3, 'ticket.article_count verify - inbound' )
assert_equal( ticket.last_contact.to_s, article_outbound.created_at.to_s, 'ticket.last_contact verify - inbound' )
assert_equal( ticket.last_contact_customer.to_s, article_inbound.created_at.to_s, 'ticket.last_contact_customer verify - inbound' )
assert_equal( ticket.last_contact_agent.to_s, article_outbound.created_at.to_s, 'ticket.last_contact_agent verify - inbound' )
assert_equal( ticket.first_response.to_s, article_outbound.created_at.to_s, 'ticket.first_response verify - inbound' )
assert_equal( ticket.close_time, nil, 'ticket.close_time verify - inbound' )
assert_equal(ticket.article_count, 3, 'ticket.article_count verify - inbound')
assert_equal(ticket.last_contact.to_s, article_outbound.created_at.to_s, 'ticket.last_contact verify - inbound')
assert_equal(ticket.last_contact_customer.to_s, article_inbound.created_at.to_s, 'ticket.last_contact_customer verify - inbound')
assert_equal(ticket.last_contact_agent.to_s, article_outbound.created_at.to_s, 'ticket.last_contact_agent verify - inbound')
assert_equal(ticket.first_response.to_s, article_outbound.created_at.to_s, 'ticket.first_response verify - inbound')
assert_equal(ticket.close_time, nil, 'ticket.close_time verify - inbound')
delete = sla.destroy
assert( delete, 'sla destroy' )
assert(delete, 'sla destroy')
delete = sla.destroy
assert( delete, 'sla destroy' )
assert(delete, 'sla destroy')
end
test 'ticket sla + timezone + holiday' do
# cleanup
delete = Sla.destroy_all
assert( delete, 'sla destroy_all' )
assert(delete, 'sla destroy_all')
delete = Ticket.destroy_all
assert( delete, 'ticket destroy_all' )
assert(delete, 'ticket destroy_all')
ticket = Ticket.create(
title: 'some title äöüß',
group: Group.lookup( name: 'Users'),
customer_id: 2,
state: Ticket::State.lookup( name: 'new' ),
priority: Ticket::Priority.lookup( name: '2 normal' ),
state: Ticket::State.lookup( name: 'new'),
priority: Ticket::Priority.lookup( name: '2 normal'),
created_at: '2013-03-21 09:30:00 UTC',
updated_at: '2013-03-21 09:30:00 UTC',
updated_by_id: 1,
created_by_id: 1,
)
assert( ticket, 'ticket created' )
assert_equal( ticket.escalation_time, nil, 'ticket.escalation_time verify' )
assert(ticket, 'ticket created')
assert_equal(ticket.escalation_time, nil, 'ticket.escalation_time verify')
# set sla's for timezone "Europe/Berlin" wintertime (+1), so UTC times are 7:00-16:00
calendar = Calendar.create_or_update(
@ -600,29 +600,29 @@ class TicketSlaTest < ActiveSupport::TestCase
)
Scheduler.worker(true)
ticket = Ticket.find(ticket.id)
assert_equal( ticket.escalation_time.gmtime.to_s, '2013-03-21 11:30:00 UTC', 'ticket.escalation_time verify 1' )
assert_equal( ticket.first_response_escal_date.gmtime.to_s, '2013-03-21 11:30:00 UTC', 'ticket.first_response_escal_date verify 1' )
assert_equal( ticket.update_time_escal_date.gmtime.to_s, '2013-03-21 12:30:00 UTC', 'ticket.update_time_escal_date verify 1' )
assert_equal( ticket.close_time_escal_date.gmtime.to_s, '2013-03-21 13:30:00 UTC', 'ticket.close_time_escal_date verify 1' )
assert_equal(ticket.escalation_time.gmtime.to_s, '2013-03-21 11:30:00 UTC', 'ticket.escalation_time verify 1')
assert_equal(ticket.first_response_escal_date.gmtime.to_s, '2013-03-21 11:30:00 UTC', 'ticket.first_response_escal_date verify 1')
assert_equal(ticket.update_time_escal_date.gmtime.to_s, '2013-03-21 12:30:00 UTC', 'ticket.update_time_escal_date verify 1')
assert_equal(ticket.close_time_escal_date.gmtime.to_s, '2013-03-21 13:30:00 UTC', 'ticket.close_time_escal_date verify 1')
delete = sla.destroy
assert( delete, 'sla destroy' )
assert(delete, 'sla destroy')
delete = ticket.destroy
assert( delete, 'ticket destroy' )
assert(delete, 'ticket destroy')
ticket = Ticket.create(
title: 'some title äöüß',
group: Group.lookup( name: 'Users'),
customer_id: 2,
state: Ticket::State.lookup( name: 'new' ),
priority: Ticket::Priority.lookup( name: '2 normal' ),
state: Ticket::State.lookup( name: 'new'),
priority: Ticket::Priority.lookup( name: '2 normal'),
created_at: '2013-10-21 09:30:00 UTC',
updated_at: '2013-10-21 09:30:00 UTC',
updated_by_id: 1,
created_by_id: 1,
)
assert( ticket, 'ticket created' )
assert_equal( ticket.escalation_time, nil, 'ticket.escalation_time verify' )
assert(ticket, 'ticket created')
assert_equal(ticket.escalation_time, nil, 'ticket.escalation_time verify')
# set sla's for timezone "Europe/Berlin" summertime (+2), so UTC times are 6:00-15:00
calendar = Calendar.create_or_update(
@ -689,30 +689,30 @@ class TicketSlaTest < ActiveSupport::TestCase
)
Scheduler.worker(true)
ticket = Ticket.find(ticket.id)
assert_equal( ticket.escalation_time.gmtime.to_s, '2013-10-21 11:30:00 UTC', 'ticket.escalation_time verify 1' )
assert_equal( ticket.first_response_escal_date.gmtime.to_s, '2013-10-21 11:30:00 UTC', 'ticket.first_response_escal_date verify 1' )
assert_equal( ticket.update_time_escal_date.gmtime.to_s, '2013-10-21 12:30:00 UTC', 'ticket.update_time_escal_date verify 1' )
assert_equal( ticket.close_time_escal_date.gmtime.to_s, '2013-10-21 13:30:00 UTC', 'ticket.close_time_escal_date verify 1' )
assert_equal(ticket.escalation_time.gmtime.to_s, '2013-10-21 11:30:00 UTC', 'ticket.escalation_time verify 1')
assert_equal(ticket.first_response_escal_date.gmtime.to_s, '2013-10-21 11:30:00 UTC', 'ticket.first_response_escal_date verify 1')
assert_equal(ticket.update_time_escal_date.gmtime.to_s, '2013-10-21 12:30:00 UTC', 'ticket.update_time_escal_date verify 1')
assert_equal(ticket.close_time_escal_date.gmtime.to_s, '2013-10-21 13:30:00 UTC', 'ticket.close_time_escal_date verify 1')
delete = ticket.destroy
assert( delete, 'ticket destroy' )
assert(delete, 'ticket destroy')
delete = sla.destroy
assert( delete, 'sla destroy' )
assert(delete, 'sla destroy')
ticket = Ticket.create(
title: 'some title äöüß',
group: Group.lookup( name: 'Users'),
customer_id: 2,
state: Ticket::State.lookup( name: 'new' ),
priority: Ticket::Priority.lookup( name: '2 normal' ),
state: Ticket::State.lookup( name: 'new'),
priority: Ticket::Priority.lookup( name: '2 normal'),
created_at: '2013-10-21 05:30:00 UTC',
updated_at: '2013-10-21 05:30:00 UTC',
updated_by_id: 1,
created_by_id: 1,
)
assert( ticket, 'ticket created' )
assert_equal( ticket.escalation_time, nil, 'ticket.escalation_time verify' )
assert(ticket, 'ticket created')
assert_equal(ticket.escalation_time, nil, 'ticket.escalation_time verify')
# set sla's for timezone "Europe/Berlin" summertime (+2), so UTC times are 6:00-15:00
sla = Sla.create_or_update(
@ -727,33 +727,33 @@ class TicketSlaTest < ActiveSupport::TestCase
)
Scheduler.worker(true)
ticket = Ticket.find(ticket.id)
assert_equal( ticket.escalation_time.gmtime.to_s, '2013-10-21 08:00:00 UTC', 'ticket.escalation_time verify 1' )
assert_equal( ticket.first_response_escal_date.gmtime.to_s, '2013-10-21 08:00:00 UTC', 'ticket.first_response_escal_date verify 1' )
assert_equal( ticket.update_time_escal_date.gmtime.to_s, '2013-10-21 09:00:00 UTC', 'ticket.update_time_escal_date verify 1' )
assert_equal( ticket.close_time_escal_date.gmtime.to_s, '2013-10-21 10:00:00 UTC', 'ticket.close_time_escal_date verify 1' )
assert_equal(ticket.escalation_time.gmtime.to_s, '2013-10-21 08:00:00 UTC', 'ticket.escalation_time verify 1')
assert_equal(ticket.first_response_escal_date.gmtime.to_s, '2013-10-21 08:00:00 UTC', 'ticket.first_response_escal_date verify 1')
assert_equal(ticket.update_time_escal_date.gmtime.to_s, '2013-10-21 09:00:00 UTC', 'ticket.update_time_escal_date verify 1')
assert_equal(ticket.close_time_escal_date.gmtime.to_s, '2013-10-21 10:00:00 UTC', 'ticket.close_time_escal_date verify 1')
ticket = Ticket.create(
title: 'some title holiday test',
group: Group.lookup( name: 'Users'),
customer_id: 2,
state: Ticket::State.lookup( name: 'new' ),
priority: Ticket::Priority.lookup( name: '2 normal' ),
state: Ticket::State.lookup( name: 'new'),
priority: Ticket::Priority.lookup( name: '2 normal'),
created_at: '2015-09-21 14:30:00 UTC',
updated_at: '2015-09-21 14:30:00 UTC',
updated_by_id: 1,
created_by_id: 1,
)
ticket = Ticket.find(ticket.id)
assert_equal( ticket.escalation_time.gmtime.to_s, '2015-09-23 07:30:00 UTC', 'ticket.escalation_time verify 1' )
assert_equal( ticket.first_response_escal_date.gmtime.to_s, '2015-09-23 07:30:00 UTC', 'ticket.first_response_escal_date verify 1' )
assert_equal( ticket.update_time_escal_date.gmtime.to_s, '2015-09-23 08:30:00 UTC', 'ticket.update_time_escal_date verify 1' )
assert_equal( ticket.close_time_escal_date.gmtime.to_s, '2015-09-23 09:30:00 UTC', 'ticket.close_time_escal_date verify 1' )
assert_equal(ticket.escalation_time.gmtime.to_s, '2015-09-23 07:30:00 UTC', 'ticket.escalation_time verify 1')
assert_equal(ticket.first_response_escal_date.gmtime.to_s, '2015-09-23 07:30:00 UTC', 'ticket.first_response_escal_date verify 1')
assert_equal(ticket.update_time_escal_date.gmtime.to_s, '2015-09-23 08:30:00 UTC', 'ticket.update_time_escal_date verify 1')
assert_equal(ticket.close_time_escal_date.gmtime.to_s, '2015-09-23 09:30:00 UTC', 'ticket.close_time_escal_date verify 1')
delete = sla.destroy
assert( delete, 'sla destroy' )
assert(delete, 'sla destroy')
delete = ticket.destroy
assert( delete, 'ticket destroy' )
assert(delete, 'ticket destroy')
end
@ -762,14 +762,14 @@ class TicketSlaTest < ActiveSupport::TestCase
title: 'some title äöüß3',
group: Group.lookup( name: 'Users'),
customer_id: 2,
state: Ticket::State.lookup( name: 'new' ),
priority: Ticket::Priority.lookup( name: '2 normal' ),
state: Ticket::State.lookup( name: 'new'),
priority: Ticket::Priority.lookup( name: '2 normal'),
created_at: '2013-06-04 09:00:00 UTC',
updated_at: '2013-06-04 09:00:00 UTC',
updated_by_id: 1,
created_by_id: 1,
)
assert( ticket, 'ticket created' )
assert(ticket, 'ticket created')
# set ticket at 10:00 to pending
History.add(
@ -881,33 +881,33 @@ class TicketSlaTest < ActiveSupport::TestCase
)
Scheduler.worker(true)
ticket = Ticket.find(ticket.id)
assert_equal( ticket.escalation_time.gmtime.to_s, '2013-06-04 13:30:00 UTC', 'ticket.escalation_time verify 1' )
assert_equal( ticket.first_response_escal_date.gmtime.to_s, '2013-06-04 11:30:00 UTC', 'ticket.first_response_escal_date verify 1' )
assert_equal( ticket.first_response_in_min, 75, 'ticket.first_response_in_min verify 3' )
assert_equal( ticket.first_response_diff_in_min, 45, 'ticket.first_response_diff_in_min verify 3' )
assert_equal( ticket.update_time_escal_date.gmtime.to_s, '2013-06-04 13:30:00 UTC', 'ticket.update_time_escal_date verify 1' )
assert_equal( ticket.close_time_escal_date.gmtime.to_s, '2013-06-04 13:40:00 UTC', 'ticket.close_time_escal_date verify 1' )
assert_equal( ticket.close_time_in_min, 150, 'ticket.close_time_in_min verify 3' )
assert_equal( ticket.close_time_diff_in_min, 100, 'ticket.close_time_diff_in_min# verify 3' )
assert_equal(ticket.escalation_time.gmtime.to_s, '2013-06-04 13:30:00 UTC', 'ticket.escalation_time verify 1')
assert_equal(ticket.first_response_escal_date.gmtime.to_s, '2013-06-04 11:30:00 UTC', 'ticket.first_response_escal_date verify 1')
assert_equal(ticket.first_response_in_min, 75, 'ticket.first_response_in_min verify 3')
assert_equal(ticket.first_response_diff_in_min, 45, 'ticket.first_response_diff_in_min verify 3')
assert_equal(ticket.update_time_escal_date.gmtime.to_s, '2013-06-04 13:30:00 UTC', 'ticket.update_time_escal_date verify 1')
assert_equal(ticket.close_time_escal_date.gmtime.to_s, '2013-06-04 13:40:00 UTC', 'ticket.close_time_escal_date verify 1')
assert_equal(ticket.close_time_in_min, 150, 'ticket.close_time_in_min verify 3')
assert_equal(ticket.close_time_diff_in_min, 100, 'ticket.close_time_diff_in_min# verify 3')
delete = sla.destroy
assert( delete, 'sla destroy' )
assert(delete, 'sla destroy')
delete = ticket.destroy
assert( delete, 'ticket destroy' )
assert(delete, 'ticket destroy')
# test Ticket created in state pending and closed without reopen or state change
ticket = Ticket.create(
title: 'some title äöüß3',
group: Group.lookup( name: 'Users'),
customer_id: 2,
state: Ticket::State.lookup( name: 'pending reminder' ),
priority: Ticket::Priority.lookup( name: '2 normal' ),
state: Ticket::State.lookup( name: 'pending reminder'),
priority: Ticket::Priority.lookup( name: '2 normal'),
created_at: '2013-06-04 09:00:00 UTC',
updated_at: '2013-06-04 09:00:00 UTC',
updated_by_id: 1,
created_by_id: 1,
)
assert( ticket, 'ticket created' )
assert(ticket, 'ticket created')
# set ticket from 11:30 to closed
History.add(
@ -977,34 +977,34 @@ class TicketSlaTest < ActiveSupport::TestCase
)
Scheduler.worker(true)
ticket = Ticket.find(ticket.id)
assert_equal( ticket.escalation_time, nil, 'ticket.escalation_time verify 1' )
assert_equal( ticket.first_response_escal_date.gmtime.to_s, '2013-06-04 13:00:00 UTC', 'ticket.first_response_escal_date verify 1' )
assert_equal( ticket.first_response_in_min, nil, 'ticket.first_response_in_min verify 3' )
assert_equal( ticket.first_response_diff_in_min, nil, 'ticket.first_response_diff_in_min verify 3' )
assert_equal( ticket.update_time_escal_date.gmtime.to_s, '2013-06-04 15:00:00 UTC', 'ticket.update_time_escal_date verify 1' )
assert_equal( ticket.close_time_escal_date.gmtime.to_s, '2013-06-04 16:00:00 UTC', 'ticket.close_time_escal_date verify 1' )
assert_equal( ticket.close_time_in_min, 0, 'ticket.close_time_in_min verify 3' )
assert_equal( ticket.close_time_diff_in_min, 240, 'ticket.close_time_diff_in_min# verify 3' )
assert_equal(ticket.escalation_time, nil, 'ticket.escalation_time verify 1')
assert_equal(ticket.first_response_escal_date.gmtime.to_s, '2013-06-04 13:00:00 UTC', 'ticket.first_response_escal_date verify 1')
assert_equal(ticket.first_response_in_min, nil, 'ticket.first_response_in_min verify 3')
assert_equal(ticket.first_response_diff_in_min, nil, 'ticket.first_response_diff_in_min verify 3')
assert_equal(ticket.update_time_escal_date.gmtime.to_s, '2013-06-04 15:00:00 UTC', 'ticket.update_time_escal_date verify 1')
assert_equal(ticket.close_time_escal_date.gmtime.to_s, '2013-06-04 16:00:00 UTC', 'ticket.close_time_escal_date verify 1')
assert_equal(ticket.close_time_in_min, 0, 'ticket.close_time_in_min verify 3')
assert_equal(ticket.close_time_diff_in_min, 240, 'ticket.close_time_diff_in_min# verify 3')
delete = sla.destroy
assert( delete, 'sla destroy' )
assert(delete, 'sla destroy')
delete = ticket.destroy
assert( delete, 'ticket destroy' )
assert(delete, 'ticket destroy')
# test Ticket created in state pending, changed state to openen, back to pending and closed
ticket = Ticket.create(
title: 'some title äöüß3',
group: Group.lookup( name: 'Users'),
customer_id: 2,
state: Ticket::State.lookup( name: 'pending reminder' ),
priority: Ticket::Priority.lookup( name: '2 normal' ),
state: Ticket::State.lookup( name: 'pending reminder'),
priority: Ticket::Priority.lookup( name: '2 normal'),
created_at: '2013-06-04 09:00:00 UTC',
updated_at: '2013-06-04 09:00:00 UTC',
updated_by_id: 1,
created_by_id: 1,
)
assert( ticket, 'ticket created' )
assert(ticket, 'ticket created')
# state change to open 10:30
History.add(
@ -1104,20 +1104,20 @@ class TicketSlaTest < ActiveSupport::TestCase
)
Scheduler.worker(true)
ticket = Ticket.find(ticket.id)
assert_equal( ticket.escalation_time, nil, 'ticket.escalation_time verify 1' )
assert_equal( ticket.first_response_escal_date.gmtime.to_s, '2013-06-04 12:30:00 UTC', 'ticket.first_response_escal_date verify 1' )
assert_equal( ticket.first_response_in_min, nil, 'ticket.first_response_in_min verify 3' )
assert_equal( ticket.first_response_diff_in_min, nil, 'ticket.first_response_diff_in_min verify 3' )
assert_equal( ticket.update_time_escal_date.gmtime.to_s, '2013-06-04 14:30:00 UTC', 'ticket.update_time_escal_date verify 1' )
assert_equal( ticket.close_time_escal_date.gmtime.to_s, '2013-06-04 15:30:00 UTC', 'ticket.close_time_escal_date verify 1' )
assert_equal( ticket.close_time_in_min, 30, 'ticket.close_time_in_min verify 3' )
assert_equal( ticket.close_time_diff_in_min, 210, 'ticket.close_time_diff_in_min# verify 3' )
assert_equal(ticket.escalation_time, nil, 'ticket.escalation_time verify 1')
assert_equal(ticket.first_response_escal_date.gmtime.to_s, '2013-06-04 12:30:00 UTC', 'ticket.first_response_escal_date verify 1')
assert_equal(ticket.first_response_in_min, nil, 'ticket.first_response_in_min verify 3')
assert_equal(ticket.first_response_diff_in_min, nil, 'ticket.first_response_diff_in_min verify 3')
assert_equal(ticket.update_time_escal_date.gmtime.to_s, '2013-06-04 14:30:00 UTC', 'ticket.update_time_escal_date verify 1')
assert_equal(ticket.close_time_escal_date.gmtime.to_s, '2013-06-04 15:30:00 UTC', 'ticket.close_time_escal_date verify 1')
assert_equal(ticket.close_time_in_min, 30, 'ticket.close_time_in_min verify 3')
assert_equal(ticket.close_time_diff_in_min, 210, 'ticket.close_time_diff_in_min# verify 3')
delete = sla.destroy
assert( delete, 'sla destroy' )
assert(delete, 'sla destroy')
delete = ticket.destroy
assert( delete, 'ticket destroy' )
assert(delete, 'ticket destroy')
### Test Ticket created in state pending, changed state to openen, back to pending and back to open then
### close ticket
@ -1125,14 +1125,14 @@ class TicketSlaTest < ActiveSupport::TestCase
title: 'some title äöüß3',
group: Group.lookup( name: 'Users'),
customer_id: 2,
state: Ticket::State.lookup( name: 'pending reminder' ),
priority: Ticket::Priority.lookup( name: '2 normal' ),
state: Ticket::State.lookup( name: 'pending reminder'),
priority: Ticket::Priority.lookup( name: '2 normal'),
created_at: '2013-06-04 09:00:00 UTC',
updated_at: '2013-06-04 09:00:00 UTC',
updated_by_id: 1,
created_by_id: 1,
)
assert( ticket, 'ticket created' )
assert(ticket, 'ticket created')
# state change to open from pending
History.add(
@ -1247,20 +1247,20 @@ class TicketSlaTest < ActiveSupport::TestCase
)
Scheduler.worker(true)
ticket = Ticket.find(ticket.id)
assert_equal( ticket.escalation_time, nil, 'ticket.escalation_time verify 1' )
assert_equal( ticket.first_response_escal_date.gmtime.to_s, '2013-06-04 12:30:00 UTC', 'ticket.first_response_escal_date verify 1' )
assert_equal( ticket.first_response_in_min, nil, 'ticket.first_response_in_min verify 3' )
assert_equal( ticket.first_response_diff_in_min, nil, 'ticket.first_response_diff_in_min verify 3' )
assert_equal( ticket.update_time_escal_date.gmtime.to_s, '2013-06-04 14:00:00 UTC', 'ticket.update_time_escal_date verify 1' )
assert_equal( ticket.close_time_escal_date.gmtime.to_s, '2013-06-04 15:00:00 UTC', 'ticket.close_time_escal_date verify 1' )
assert_equal( ticket.close_time_in_min, 60, 'ticket.close_time_in_min verify 3' )
assert_equal( ticket.close_time_diff_in_min, 180, 'ticket.close_time_diff_in_min# verify 3' )
assert_equal(ticket.escalation_time, nil, 'ticket.escalation_time verify 1')
assert_equal(ticket.first_response_escal_date.gmtime.to_s, '2013-06-04 12:30:00 UTC', 'ticket.first_response_escal_date verify 1')
assert_equal(ticket.first_response_in_min, nil, 'ticket.first_response_in_min verify 3')
assert_equal(ticket.first_response_diff_in_min, nil, 'ticket.first_response_diff_in_min verify 3')
assert_equal(ticket.update_time_escal_date.gmtime.to_s, '2013-06-04 14:00:00 UTC', 'ticket.update_time_escal_date verify 1')
assert_equal(ticket.close_time_escal_date.gmtime.to_s, '2013-06-04 15:00:00 UTC', 'ticket.close_time_escal_date verify 1')
assert_equal(ticket.close_time_in_min, 60, 'ticket.close_time_in_min verify 3')
assert_equal(ticket.close_time_diff_in_min, 180, 'ticket.close_time_diff_in_min# verify 3')
delete = sla.destroy
assert( delete, 'sla destroy' )
assert(delete, 'sla destroy')
delete = ticket.destroy
assert( delete, 'ticket destroy' )
assert(delete, 'ticket destroy')
end