Renamed tickets.ticket_priority to tickets.priority, tickets.ticket_state to ticket.state, ticket_articles.ticket_article_sender to ticket_articles.sender and ticket_articles.ticket_article_type to ticket_articles.type.

This commit is contained in:
Martin Edenhofer 2014-06-09 00:01:20 +02:00
parent 569d6e0233
commit 065fbb2bba
33 changed files with 613 additions and 600 deletions

View file

@ -146,7 +146,7 @@ class TicketsController < ApplicationController
# open tickets by customer
ticket_list = Ticket.where(
:customer_id => ticket.customer_id,
:ticket_state_id => Ticket::State.by_category( 'open' )
:state_id => Ticket::State.by_category( 'open' )
)
.where( 'id != ?', [ ticket.id ] )
.order('created_at DESC')

View file

@ -364,16 +364,16 @@ class Channel::EmailParser
# set ticket state to open if not new
if ticket
ticket_state = Ticket::State.find( ticket.ticket_state_id )
ticket_state_type = Ticket::StateType.find( ticket_state.state_type_id )
state = Ticket::State.find( ticket.state_id )
state_type = Ticket::StateType.find( state.state_type_id )
# if tickte is merged, find linked ticket
if ticket_state_type.name == 'merged'
if state_type.name == 'merged'
end
if ticket_state_type.name != 'new'
ticket.ticket_state = Ticket::State.where( :name => 'open' ).first
if state_type.name != 'new'
ticket.state = Ticket::State.where( :name => 'open' ).first
ticket.save
end
end
@ -386,8 +386,8 @@ class Channel::EmailParser
:group_id => channel[:group_id] || 1,
:customer_id => user.id,
:title => mail[:subject] || '',
:ticket_state_id => Ticket::State.where( :name => 'new' ).first.id,
:ticket_priority_id => Ticket::Priority.where( :name => '2 normal' ).first.id,
:state_id => Ticket::State.where( :name => 'new' ).first.id,
:priority_id => Ticket::Priority.where( :name => '2 normal' ).first.id,
)
set_attributes_by_x_headers( ticket, 'ticket', mail )
@ -401,8 +401,8 @@ class Channel::EmailParser
# set attributes
article = Ticket::Article.new(
:ticket_id => ticket.id,
:ticket_article_type_id => Ticket::Article::Type.where( :name => 'email' ).first.id,
:ticket_article_sender_id => Ticket::Article::Sender.where( :name => 'Customer' ).first.id,
:type_id => Ticket::Article::Type.where( :name => 'email' ).first.id,
:sender_id => Ticket::Article::Sender.where( :name => 'Customer' ).first.id,
:body => mail[:body],
:from => mail[:from],
:to => mail[:to],

View file

@ -195,8 +195,8 @@ class Channel::Twitter2
if @article_type == 'twitter direct-message'
ticket = Ticket.where( :customer_id => user.id ).first
if ticket
ticket_state_type = Ticket::StateType.where( ticket.ticket_state.state_type_id )
if ticket_state_type.name == 'closed' || ticket_state_type.name == 'closed'
state_type = Ticket::StateType.where( ticket.state.state_type_id )
if state_type.name == 'closed' || state_type.name == 'closed'
ticket = nil
end
end
@ -221,8 +221,8 @@ class Channel::Twitter2
:group_id => group_id,
:customer_id => user.id,
:title => tweet.text[0,40],
:ticket_state_id => state_id,
:ticket_priority_id => priority_id,
:state_id => state_id,
:priority_id => priority_id,
)
end
@ -236,8 +236,8 @@ class Channel::Twitter2
return article if article
# set ticket state to open if not new
if ticket.ticket_state.name != 'new'
ticket.ticket_state = Ticket::State.where( :name => 'open' ).first
if ticket.state.name != 'new'
ticket.state = Ticket::State.where( :name => 'open' ).first
ticket.save
end
@ -249,8 +249,8 @@ class Channel::Twitter2
article = Ticket::Article.create(
:ticket_id => ticket.id,
:ticket_article_type_id => Ticket::Article::Type.where( :name => @article_type ).first.id,
:ticket_article_sender_id => Ticket::Article::Sender.where( :name => 'Customer' ).first.id,
:type_id => Ticket::Article::Type.where( :name => @article_type ).first.id,
:sender_id => Ticket::Article::Sender.where( :name => 'Customer' ).first.id,
:body => tweet.text,
:from => sender.name,
:to => to,

View file

@ -21,7 +21,7 @@ add a new history entry for an object
History.add(
:history_type => 'updated',
:history_object => 'Ticket',
:history_attribute => 'ticket_state',
:history_attribute => 'state',
:o_id => ticket.id,
:id_to => 3,
:id_from => 2,

View file

@ -2,8 +2,8 @@
class Network < ApplicationModel
# belongs_to :group
# belongs_to :ticket_state, :class_name => 'Ticket::State'
# belongs_to :ticket_priority, :class_name => 'Ticket::Priority'
# belongs_to :state, :class_name => 'Ticket::State'
# belongs_to :priority, :class_name => 'Ticket::Priority'
class Category < ApplicationModel
self.table_name = 'network_categories'

View file

@ -9,12 +9,12 @@ class Observer::Ticket::Article::CommunicateEmail < ActiveRecord::Observer
return if Setting.get('import_mode')
# if sender is customer, do not communication
sender = Ticket::Article::Sender.lookup( :id => record.ticket_article_sender_id )
sender = Ticket::Article::Sender.lookup( :id => record.sender_id )
return 1 if sender == nil
return 1 if sender['name'] == 'Customer'
# only apply on emails
type = Ticket::Article::Type.lookup( :id => record.ticket_article_type_id )
type = Ticket::Article::Type.lookup( :id => record.type_id )
return if type['name'] != 'email'
# send background job

View file

@ -9,12 +9,12 @@ class Observer::Ticket::Article::CommunicateFacebook < ActiveRecord::Observer
return if Setting.get('import_mode')
# if sender is customer, do not communication
sender = Ticket::Article::Sender.lookup( :id => record.ticket_article_sender_id )
sender = Ticket::Article::Sender.lookup( :id => record.sender_id )
return 1 if sender == nil
return 1 if sender['name'] == 'Customer'
# only apply on emails
type = Ticket::Article::Type.lookup( :id => record.ticket_article_type_id )
type = Ticket::Article::Type.lookup( :id => record.type_id )
return if type['name'] != 'facebook'
a = Channel::Facebook.new

View file

@ -9,12 +9,12 @@ class Observer::Ticket::Article::CommunicateTwitter < ActiveRecord::Observer
return if Setting.get('import_mode')
# if sender is customer, do not communication
sender = Ticket::Article::Sender.lookup( :id => record.ticket_article_sender_id )
sender = Ticket::Article::Sender.lookup( :id => record.sender_id )
return 1 if sender == nil
return 1 if sender['name'] == 'Customer'
# only apply on tweets
type = Ticket::Article::Type.lookup( :id => record.ticket_article_type_id )
type = Ticket::Article::Type.lookup( :id => record.type_id )
return if type['name'] != 'twitter direct-message' && type['name'] != 'twitter status'
a = Channel::Twitter2.new

View file

@ -9,12 +9,12 @@ class Observer::Ticket::Article::FillupFromEmail < ActiveRecord::Observer
return if Setting.get('import_mode')
# if sender is customer, do not change anything
sender = Ticket::Article::Sender.lookup( :id => record.ticket_article_sender_id )
sender = Ticket::Article::Sender.lookup( :id => record.sender_id )
return if sender == nil
return if sender['name'] == 'Customer'
# set email attributes
type = Ticket::Article::Type.lookup( :id => record.ticket_article_type_id )
type = Ticket::Article::Type.lookup( :id => record.type_id )
return if type['name'] != 'email'
# set subject if empty

View file

@ -9,7 +9,7 @@ class Observer::Ticket::Article::FillupFromGeneral < ActiveRecord::Observer
return if Setting.get('import_mode')
# if sender is customer, do not change anything
sender = Ticket::Article::Sender.lookup( :id => record.ticket_article_sender_id )
sender = Ticket::Article::Sender.lookup( :id => record.sender_id )
return if sender == nil
return if sender['name'] == 'Customer'

View file

@ -9,8 +9,8 @@ class Observer::Ticket::ArticleSenderType < ActiveRecord::Observer
count = Ticket::Article.where( :ticket_id => record.ticket_id ).count
return if count > 1
record.ticket.create_article_type_id = record.ticket_article_type_id
record.ticket.create_article_sender_id = record.ticket_article_sender_id
record.ticket.create_article_type_id = record.type_id
record.ticket.create_article_sender_id = record.sender_id
# save ticket
record.ticket.save

View file

@ -22,9 +22,9 @@ class Observer::Ticket::CloseTime < ActiveRecord::Observer
return true if record.close_time
# check if ticket is closed now
ticket_state = Ticket::State.lookup( :id => record.ticket_state_id )
ticket_state_type = Ticket::StateType.lookup( :id => ticket_state.state_type_id )
return true if ticket_state_type.name != 'closed'
state = Ticket::State.lookup( :id => record.state_id )
state_type = Ticket::StateType.lookup( :id => state.state_type_id )
return true if state_type.name != 'closed'
# set close_time
record.close_time = Time.now

View file

@ -13,8 +13,8 @@ class Observer::Ticket::FirstResponse < ActiveRecord::Observer
return true if record.internal
# if sender is not agent
sender = Ticket::Article::Sender.lookup( :id => record.ticket_article_sender_id )
type = Ticket::Article::Type.lookup( :id => record.ticket_article_type_id )
sender = Ticket::Article::Sender.lookup( :id => record.sender_id )
type = Ticket::Article::Type.lookup( :id => record.type_id )
if sender.name != 'Agent' && type.name !~ /^phone/
return true
end

View file

@ -10,10 +10,10 @@ class Observer::Ticket::LastContact < ActiveRecord::Observer
return true if record.internal
# if article is a message to customer
return true if !Ticket::Article::Type.lookup( :id => record.ticket_article_type_id ).communication
return true if !Ticket::Article::Type.lookup( :id => record.type_id ).communication
# if sender is not customer
sender = Ticket::Article::Sender.lookup( :id => record.ticket_article_sender_id )
sender = Ticket::Article::Sender.lookup( :id => record.sender_id )
if sender.name == 'Customer'
# check if last communication is done by agent, else do not set last_contact_customer

View file

@ -49,11 +49,11 @@ class Observer::Ticket::Notification < ActiveRecord::Observer
:subject => 'New Ticket (#{ticket.title})',
:body => 'Hi #{recipient.firstname},
a new Ticket (#{ticket.title}) via i18n(#{article.ticket_article_type.name}).
a new Ticket (#{ticket.title}) via i18n(#{article.type.name}).
Group: #{ticket.group.name}
Owner: #{ticket.owner.firstname} #{ticket.owner.lastname}
State: i18n(#{ticket.ticket_state.name})
State: i18n(#{ticket.state.name})
From: #{article.from}
<snip>
@ -72,7 +72,7 @@ class Observer::Ticket::Notification < ActiveRecord::Observer
if event[:name] == 'Ticket' && event[:type] == 'create'
# only for incoming emails
next if article.ticket_article_type.name != 'email'
next if article.type.name != 'email'
puts 'send new ticket notify to customer'
send_notify(
@ -107,7 +107,7 @@ class Observer::Ticket::Notification < ActiveRecord::Observer
puts 'send new ticket::article notify'
if article.ticket_article_sender.name == 'Customer'
if article.sender.name == 'Customer'
send_notify(
{
:event => event,
@ -115,11 +115,11 @@ class Observer::Ticket::Notification < ActiveRecord::Observer
:subject => 'Follow Up (#{ticket.title})',
:body => 'Hi #{recipient.firstname},
a follow Up (#{ticket.title}) via i18n(#{article.ticket_article_type.name}).
a follow Up (#{ticket.title}) via i18n(#{article.type.name}).
Group: #{ticket.group.name}
Owner: #{ticket.owner.firstname} #{ticket.owner.lastname}
State: i18n(#{ticket.ticket_state.name})
State: i18n(#{ticket.state.name})
From: #{article.from}
<snip>
@ -136,7 +136,7 @@ class Observer::Ticket::Notification < ActiveRecord::Observer
# send new note notification to owner
# if agent == created.id
if article.ticket_article_sender.name == 'Agent' && article.created_by_id != article.ticket.owner_id
if article.sender.name == 'Agent' && article.created_by_id != article.ticket.owner_id
send_notify(
{
:event => event,
@ -144,11 +144,11 @@ class Observer::Ticket::Notification < ActiveRecord::Observer
:subject => 'Updated (#{ticket.title})',
:body => 'Hi #{recipient.firstname},
updated (#{ticket.title}) via i18n(#{article.ticket_article_type.name}).
updated (#{ticket.title}) via i18n(#{article.type.name}).
Group: #{ticket.group.name}
Owner: #{ticket.owner.firstname} #{ticket.owner.lastname}
State: i18n(#{ticket.ticket_state.name})
State: i18n(#{ticket.state.name})
From: #{article.from}
<snip>

View file

@ -13,21 +13,21 @@ class Observer::Ticket::ResetNewState < ActiveRecord::Observer
return true if record.internal
# if sender is agent
return true if Ticket::Article::Sender.lookup( :id => record.ticket_article_sender_id ).name != 'Agent'
return true if Ticket::Article::Sender.lookup( :id => record.sender_id ).name != 'Agent'
# if article is a message to customer
return true if !Ticket::Article::Type.lookup( :id => record.ticket_article_type_id ).communication
return true if !Ticket::Article::Type.lookup( :id => record.type_id ).communication
# if current ticket state is still new
ticket = Ticket.lookup( :id => record.ticket_id )
return true if ticket.ticket_state.state_type.name != 'new'
return true if ticket.state.state_type.name != 'new'
# TODO: add config option to state managment in UI
state = Ticket::State.lookup( :name => 'open' )
return if !state
# set ticket to open
ticket.ticket_state_id = state.id
ticket.state_id = state.id
# save ticket
ticket.save

View file

@ -14,17 +14,17 @@ class Observer::Ticket::UserTicketCounter < ActiveRecord::Observer
return if !record.customer_id
# open ticket count
ticket_state_open = Ticket::State.by_category( 'open' )
state_open = Ticket::State.by_category( 'open' )
tickets_open = Ticket.where(
:customer_id => record.customer_id,
:ticket_state_id => ticket_state_open,
:state_id => state_open,
).count()
# closed ticket count
ticket_state_closed = Ticket::State.by_category( 'closed' )
state_closed = Ticket::State.by_category( 'closed' )
tickets_closed = Ticket.where(
:customer_id => record.customer_id,
:ticket_state_id => ticket_state_closed,
:state_id => state_closed,
).count()
# check if update is needed

View file

@ -4,13 +4,13 @@ class Ticket < ApplicationModel
include Ticket::Escalation
include Ticket::Subject
include Ticket::Permission
require 'ticket/assets'
load 'ticket/assets.rb'
include Ticket::Assets
require 'ticket/history_log'
load 'ticket/history_log.rb'
include Ticket::HistoryLog
require 'ticket/activity_stream_log'
load 'ticket/activity_stream_log.rb'
include Ticket::ActivityStreamLog
require 'ticket/search_index'
load 'ticket/search_index.rb'
include Ticket::SearchIndex
extend Ticket::Search
@ -48,8 +48,8 @@ class Ticket < ApplicationModel
belongs_to :group
has_many :articles, :class_name => 'Ticket::Article', :after_add => :cache_update, :after_remove => :cache_update
belongs_to :organization
belongs_to :ticket_state, :class_name => 'Ticket::State'
belongs_to :ticket_priority, :class_name => 'Ticket::Priority'
belongs_to :state, :class_name => 'Ticket::State'
belongs_to :priority, :class_name => 'Ticket::Priority'
belongs_to :owner, :class_name => 'User'
belongs_to :customer, :class_name => 'User'
belongs_to :created_by, :class_name => 'User'
@ -100,8 +100,8 @@ returns
# create new merge article
Ticket::Article.create(
:ticket_id => self.id,
:ticket_article_type_id => Ticket::Article::Type.lookup( :name => 'note' ).id,
:ticket_article_sender_id => Ticket::Article::Sender.lookup( :name => 'Agent' ).id,
:type_id => Ticket::Article::Type.lookup( :name => 'note' ).id,
:sender_id => Ticket::Article::Sender.lookup( :name => 'Agent' ).id,
:body => 'merged',
:internal => false
)
@ -118,7 +118,7 @@ returns
)
# set state to 'merged'
self.ticket_state_id = Ticket::State.lookup( :name => 'merged' ).id
self.state_id = Ticket::State.lookup( :name => 'merged' ).id
# rest owner
self.owner_id = User.where( :login => '-' ).first.id

View file

@ -9,21 +9,21 @@ class Ticket::Article < ApplicationModel
include Ticket::Article::ActivityStreamLog
belongs_to :ticket
belongs_to :ticket_article_type, :class_name => 'Ticket::Article::Type'
belongs_to :ticket_article_sender, :class_name => 'Ticket::Article::Sender'
belongs_to :type, :class_name => 'Ticket::Article::Type'
belongs_to :sender, :class_name => 'Ticket::Article::Sender'
belongs_to :created_by, :class_name => 'User'
after_create :notify_clients_after_create
after_update :notify_clients_after_update
after_destroy :notify_clients_after_destroy
activity_stream_support :ignore_attributes => {
:ticket_article_type_id => true,
:ticket_article_sender_id => true,
:type_id => true,
:sender_id => true,
}
history_support :ignore_attributes => {
:ticket_article_type_id => true,
:ticket_article_sender_id => true,
:type_id => true,
:sender_id => true,
}
class Flag < ApplicationModel

View file

@ -15,9 +15,9 @@ returns
=end
def self.rebuild_all
ticket_state_list_open = Ticket::State.by_category( 'open' )
state_list_open = Ticket::State.by_category( 'open' )
tickets = Ticket.where( :ticket_state_id => ticket_state_list_open )
tickets = Ticket.where( :state_id => state_list_open )
tickets.each {|ticket|
ticket.escalation_calculation
}
@ -39,8 +39,8 @@ returns
def escalation_calculation
# set escalation off if ticket is already closed
ticket_state = Ticket::State.lookup( :id => self.ticket_state_id )
if ticket_state.ignore_escalation?
state = Ticket::State.lookup( :id => self.state_id )
if state.ignore_escalation?
# nothing to change
return true if !self.escalation_time
@ -186,7 +186,7 @@ returns
elsif sla.condition
hit = false
map = [
[ 'tickets.ticket_priority_id', 'ticket_priority_id' ],
[ 'tickets.priority_id', 'priority_id' ],
[ 'tickets.group_id', 'group_id' ]
]
map.each {|item|
@ -232,7 +232,7 @@ returns
# ignore if it isn't a state change
next if !history_item['attribute']
next if history_item['attribute'] != 'ticket_state'
next if history_item['attribute'] != 'state'
# ignore all newer state before start_time
next if history_item['created_at'] < start_time

View file

@ -45,7 +45,7 @@ returns
{
:type => 'updated',
:object => 'Ticket',
:attribute => 'ticket_priority',
:attribute => 'priority',
:o_id => 1,
:id_to => 3,
:id_from => 2,

View file

@ -32,9 +32,9 @@ list attributes
returns
result = {
:ticket_article_type_id => ticket_article_type_ids,
:ticket_state_id => ticket_state_ids,
:ticket_priority_id => ticket_priority_ids,
:type_id => type_ids,
:state_id => state_ids,
:priority_id => priority_ids,
:owner_id => owner_ids,
:group_id => group_ids,
:group_id__owner_id => groups_users,
@ -51,19 +51,19 @@ returns
end
# get ticket states
ticket_state_ids = []
state_ids = []
if params[:ticket]
ticket_state_type = params[:ticket].ticket_state.state_type
state_type = params[:ticket].state.state_type
end
ticket_state_types = ['open', 'closed', 'pending action', 'pending reminder']
if ticket_state_type && !ticket_state_types.include?(ticket_state_type.name)
ticket_state_ids.push params[:ticket].ticket_state.id
state_types = ['open', 'closed', 'pending action', 'pending reminder']
if state_type && !state_types.include?(state_type.name)
state_ids.push params[:ticket].state.id
end
ticket_state_types.each {|type|
ticket_state_type = Ticket::StateType.where( :name => type ).first
if ticket_state_type
ticket_state_type.states.each {|ticket_state|
ticket_state_ids.push ticket_state.id
state_types.each {|type|
state_type = Ticket::StateType.where( :name => type ).first
if state_type
state_type.states.each {|state|
state_ids.push state.id
}
end
}
@ -97,29 +97,29 @@ returns
}
# get priorities
ticket_priority_ids = []
priority_ids = []
Ticket::Priority.where( :active => true ).each { |priority|
ticket_priority_ids.push priority.id
priority_ids.push priority.id
}
ticket_article_type_ids = []
type_ids = []
if params[:ticket]
ticket_article_types = ['note', 'phone']
types = ['note', 'phone']
if params[:ticket].group.email_address_id
ticket_article_types.push 'email'
types.push 'email'
end
ticket_article_types.each {|ticket_article_type_name|
ticket_article_type = Ticket::Article::Type.lookup( :name => ticket_article_type_name )
if ticket_article_type
ticket_article_type_ids.push ticket_article_type.id
types.each {|type_name|
type = Ticket::Article::Type.lookup( :name => type_name )
if type
type_ids.push type.id
end
}
end
return {
:ticket_article_type_id => ticket_article_type_ids,
:ticket_state_id => ticket_state_ids,
:ticket_priority_id => ticket_priority_ids,
:type_id => type_ids,
:state_id => state_ids,
:priority_id => priority_ids,
:owner_id => owner_ids,
:group_id => group_ids,
:group_id__owner_id => groups_users,
@ -147,18 +147,18 @@ returns
def self.list_by_customer(data)
# get closed/open states
ticket_state_list_open = Ticket::State.by_category( 'open' )
ticket_state_list_closed = Ticket::State.by_category( 'closed' )
state_list_open = Ticket::State.by_category( 'open' )
state_list_closed = Ticket::State.by_category( 'closed' )
# get tickets
tickets_open = Ticket.where(
:customer_id => data[:customer_id],
:ticket_state_id => ticket_state_list_open
:state_id => state_list_open
).limit( data[:limit] || 15 ).order('created_at DESC')
tickets_closed = Ticket.where(
:customer_id => data[:customer_id],
:ticket_state_id => ticket_state_list_closed
:state_id => state_list_closed
).limit( data[:limit] || 15 ).order('created_at DESC')
return {

View file

@ -33,9 +33,9 @@ returns:
check if state is ignored for escalation
ticket_state = Ticket::State.lookup( :name => 'state name' )
state = Ticket::State.lookup( :name => 'state name' )
result = ticket_state.ignore_escalation?
result = state.ignore_escalation?
returns:

View file

@ -0,0 +1,12 @@
class UpdateTicketReplace < ActiveRecord::Migration
def up
rename_column :tickets, :ticket_priority_id, :priority_id
rename_column :tickets, :ticket_state_id, :state_id
rename_column :ticket_articles, :ticket_article_type_id, :type_id
rename_column :ticket_articles, :ticket_article_sender_id, :sender_id
end
def down
end
end

View file

@ -1097,7 +1097,7 @@ Setting.create_if_not_exists(
:title => 'Import Endpoint',
:name => 'import_otrs_endpoint',
:area => 'Import::OTRS',
:description => 'Defines OTRS endpoint to import users, ticket, ticket_states and articles.',
:description => 'Defines OTRS endpoint to import users, ticket, states and articles.',
:options => {
:form => [
{
@ -1306,13 +1306,13 @@ ticket = Ticket.create(
:customer_id => User.where( :login => 'nicole.braun@zammad.org' ).first.id,
:owner_id => User.where( :login => '-' ).first.id,
:title => 'Welcome to Zammad!',
:ticket_state_id => Ticket::State.where( :name => 'new' ).first.id,
:ticket_priority_id => Ticket::Priority.where( :name => '2 normal' ).first.id,
:state_id => Ticket::State.where( :name => 'new' ).first.id,
:priority_id => Ticket::Priority.where( :name => '2 normal' ).first.id,
)
Ticket::Article.create(
:ticket_id => ticket.id,
:ticket_article_type_id => Ticket::Article::Type.where(:name => 'phone' ).first.id,
:ticket_article_sender_id => Ticket::Article::Sender.where(:name => 'Customer' ).first.id,
:type_id => Ticket::Article::Type.where(:name => 'phone' ).first.id,
:sender_id => Ticket::Article::Sender.where(:name => 'Customer' ).first.id,
:from => 'Zammad Feedback <feedback@zammad.org>',
:body => 'Welcome!
@ -1337,7 +1337,7 @@ Overview.create_if_not_exists(
:prio => 1000,
:role_id => overview_role.id,
:condition => {
'tickets.ticket_state_id' => [ 1,2,3 ],
'tickets.state_id' => [ 1,2,3 ],
'tickets.owner_id' => 'current_user.id',
},
:order => {
@ -1345,9 +1345,9 @@ Overview.create_if_not_exists(
:direction => 'ASC',
},
:view => {
:d => [ 'title', 'customer', 'ticket_state', 'group', 'created_at' ],
:s => [ 'number', 'title', 'customer', 'ticket_state', 'ticket_priority', 'group', 'created_at' ],
:m => [ 'number', 'title', 'customer', 'ticket_state', 'ticket_priority', 'group', 'created_at' ],
:d => [ 'title', 'customer', 'state', 'group', 'created_at' ],
:s => [ 'number', 'title', 'customer', 'state', 'priority', 'group', 'created_at' ],
:m => [ 'number', 'title', 'customer', 'state', 'priority', 'group', 'created_at' ],
:view_mode_default => 's',
},
)
@ -1358,7 +1358,7 @@ Overview.create_if_not_exists(
:prio => 1001,
:role_id => overview_role.id,
:condition => {
'tickets.ticket_state_id' => [1,2,3],
'tickets.state_id' => [1,2,3],
'tickets.owner_id' => 1,
},
:order => {
@ -1366,9 +1366,9 @@ Overview.create_if_not_exists(
:direction => 'ASC',
},
:view => {
:d => [ 'title', 'customer', 'ticket_state', 'group', 'created_at' ],
:s => [ 'number', 'title', 'customer', 'ticket_state', 'ticket_priority', 'group', 'created_at' ],
:m => [ 'number', 'title', 'customer', 'ticket_state', 'ticket_priority', 'group', 'created_at' ],
:d => [ 'title', 'customer', 'state', 'group', 'created_at' ],
:s => [ 'number', 'title', 'customer', 'state', 'priority', 'group', 'created_at' ],
:m => [ 'number', 'title', 'customer', 'state', 'priority', 'group', 'created_at' ],
:view_mode_default => 's',
},
)
@ -1379,16 +1379,16 @@ Overview.create_if_not_exists(
:prio => 1002,
:role_id => overview_role.id,
:condition => {
'tickets.ticket_state_id' => [1,2,3],
'tickets.state_id' => [1,2,3],
},
:order => {
:by => 'created_at',
:direction => 'ASC',
},
:view => {
:d => [ 'title', 'customer', 'ticket_state', 'group', 'created_at' ],
:s => [ 'number', 'title', 'customer', 'ticket_state', 'ticket_priority', 'group', 'created_at' ],
:m => [ 'number', 'title', 'customer', 'ticket_state', 'ticket_priority', 'group', 'created_at' ],
:d => [ 'title', 'customer', 'state', 'group', 'created_at' ],
:s => [ 'number', 'title', 'customer', 'state', 'priority', 'group', 'created_at' ],
:m => [ 'number', 'title', 'customer', 'state', 'priority', 'group', 'created_at' ],
:view_mode_default => 's',
},
)
@ -1406,9 +1406,9 @@ Overview.create_if_not_exists(
:direction => 'ASC',
},
:view => {
:d => [ 'title', 'customer', 'ticket_state', 'group', 'owner', 'escalation_time' ],
:s => [ 'number', 'title', 'customer', 'ticket_state', 'ticket_priority', 'group', 'owner', 'escalation_time' ],
:m => [ 'number', 'title', 'customer', 'ticket_state', 'ticket_priority', 'group', 'owner', 'escalation_time' ],
:d => [ 'title', 'customer', 'state', 'group', 'owner', 'escalation_time' ],
:s => [ 'number', 'title', 'customer', 'state', 'priority', 'group', 'owner', 'escalation_time' ],
:m => [ 'number', 'title', 'customer', 'state', 'priority', 'group', 'owner', 'escalation_time' ],
:view_mode_default => 's',
},
)
@ -1419,7 +1419,7 @@ Overview.create_if_not_exists(
:prio => 1020,
:role_id => overview_role.id,
:condition => {
'tickets.ticket_state_id' => [3],
'tickets.state_id' => [3],
'tickets.owner_id' => 'current_user.id',
},
:order => {
@ -1427,9 +1427,9 @@ Overview.create_if_not_exists(
:direction => 'ASC',
},
:view => {
:d => [ 'title', 'customer', 'ticket_state', 'group', 'created_at' ],
:s => [ 'number', 'title', 'customer', 'ticket_state', 'ticket_priority', 'group', 'created_at' ],
:m => [ 'number', 'title', 'customer', 'ticket_state', 'ticket_priority', 'group', 'created_at' ],
:d => [ 'title', 'customer', 'state', 'group', 'created_at' ],
:s => [ 'number', 'title', 'customer', 'state', 'priority', 'group', 'created_at' ],
:m => [ 'number', 'title', 'customer', 'state', 'priority', 'group', 'created_at' ],
:view_mode_default => 's',
},
)
@ -1440,7 +1440,7 @@ Overview.create_if_not_exists(
:prio => 9003,
:role_id => overview_role.id,
:condition => {
# 'tickets.ticket_state_id' => [3],
# 'tickets.state_id' => [3],
# 'tickets.owner_id' => current_user.id,
},
:order => {
@ -1448,9 +1448,9 @@ Overview.create_if_not_exists(
:direction => 'ASC',
},
:view => {
:s => [ 'title', 'customer', 'ticket_state', 'group', 'created_at' ],
:s => [ 'number', 'title', 'customer', 'ticket_state', 'ticket_priority', 'group', 'created_at' ],
:m => [ 'number', 'title', 'customer', 'ticket_state', 'ticket_priority', 'group', 'created_at' ],
:s => [ 'title', 'customer', 'state', 'group', 'created_at' ],
:s => [ 'number', 'title', 'customer', 'state', 'priority', 'group', 'created_at' ],
:m => [ 'number', 'title', 'customer', 'state', 'priority', 'group', 'created_at' ],
:view_mode_default => 's',
},
)
@ -1462,7 +1462,7 @@ Overview.create_if_not_exists(
:prio => 1000,
:role_id => overview_role.id,
:condition => {
'tickets.ticket_state_id' => [ 1,2,3,4,6 ],
'tickets.state_id' => [ 1,2,3,4,6 ],
'tickets.customer_id' => 'current_user.id',
},
:order => {
@ -1470,9 +1470,9 @@ Overview.create_if_not_exists(
:direction => 'DESC',
},
:view => {
:d => [ 'title', 'customer', 'ticket_state', 'created_at' ],
:s => [ 'number', 'title', 'ticket_state', 'ticket_priority', 'created_at' ],
:m => [ 'number', 'title', 'ticket_state', 'ticket_priority', 'created_at' ],
:d => [ 'title', 'customer', 'state', 'created_at' ],
:s => [ 'number', 'title', 'state', 'priority', 'created_at' ],
:m => [ 'number', 'title', 'state', 'priority', 'created_at' ],
:view_mode_default => 's',
},
)
@ -1483,7 +1483,7 @@ Overview.create_if_not_exists(
:role_id => overview_role.id,
:organization_shared => true,
:condition => {
'tickets.ticket_state_id' => [ 1,2,3,4,6 ],
'tickets.state_id' => [ 1,2,3,4,6 ],
'tickets.organization_id' => 'current_user.organization_id',
},
:order => {
@ -1491,9 +1491,9 @@ Overview.create_if_not_exists(
:direction => 'DESC',
},
:view => {
:d => [ 'title', 'customer', 'ticket_state', 'created_at' ],
:s => [ 'number', 'title', 'customer', 'ticket_state', 'ticket_priority', 'created_at' ],
:m => [ 'number', 'title', 'ticket_state', 'ticket_priority', 'created_at' ],
:d => [ 'title', 'customer', 'state', 'created_at' ],
:s => [ 'number', 'title', 'customer', 'state', 'priority', 'created_at' ],
:m => [ 'number', 'title', 'state', 'priority', 'created_at' ],
:view_mode_default => 's',
},
)

View file

@ -127,10 +127,10 @@ module Import::OTRS
#self.ticket('156115')
#return
# create states
ticket_state
state
# create priorities
ticket_priority
priority
# create groups
ticket_group
@ -185,10 +185,10 @@ module Import::OTRS
end
# create states
ticket_state
state
# create priorities
ticket_priority
priority
# create groups
ticket_group
@ -233,8 +233,8 @@ module Import::OTRS
:CreateBy => :created_by_id,
:TicketNumber => :number,
:QueueID => :group_id,
:StateID => :ticket_state_id,
:PriorityID => :ticket_priority_id,
:StateID => :state_id,
:PriorityID => :priority_id,
:Owner => :owner,
:CustomerUserID => :customer,
:Title => :title,
@ -249,8 +249,8 @@ module Import::OTRS
# :CloseTimeDiffInMin => :close_time_diff_in_min,
},
:Article => {
:SenderType => :ticket_article_sender,
:ArticleType => :ticket_article_type,
:SenderType => :sender,
:ArticleType => :type,
:TicketID => :ticket_id,
:ArticleID => :id,
:Body => :body,
@ -338,7 +338,7 @@ module Import::OTRS
end
}
# create customer/sender if needed
if article_new[:ticket_article_sender] == 'customer' && article_new[:created_by_id].to_i == 1 && !article_new[:from].empty?
if article_new[:sender] == 'customer' && article_new[:created_by_id].to_i == 1 && !article_new[:from].empty?
# set extra headers
begin
email = Mail::Address.new( article_new[:from] ).address
@ -379,41 +379,41 @@ module Import::OTRS
article_new[:created_by_id] = user.id
end
if article_new[:ticket_article_sender] == 'customer'
article_new[:ticket_article_sender_id] = Ticket::Article::Sender.lookup( :name => 'Customer' ).id
article_new.delete( :ticket_article_sender )
if article_new[:sender] == 'customer'
article_new[:sender_id] = Ticket::Article::Sender.lookup( :name => 'Customer' ).id
article_new.delete( :sender )
end
if article_new[:ticket_article_sender] == 'agent'
article_new[:ticket_article_sender_id] = Ticket::Article::Sender.lookup( :name => 'Agent' ).id
article_new.delete( :ticket_article_sender )
if article_new[:sender] == 'agent'
article_new[:sender_id] = Ticket::Article::Sender.lookup( :name => 'Agent' ).id
article_new.delete( :sender )
end
if article_new[:ticket_article_sender] == 'system'
article_new[:ticket_article_sender_id] = Ticket::Article::Sender.lookup( :name => 'System' ).id
article_new.delete( :ticket_article_sender )
if article_new[:sender] == 'system'
article_new[:sender_id] = Ticket::Article::Sender.lookup( :name => 'System' ).id
article_new.delete( :sender )
end
if article_new[:ticket_article_type] == 'email-external'
article_new[:ticket_article_type_id] = Ticket::Article::Type.lookup( :name => 'email' ).id
if article_new[:type] == 'email-external'
article_new[:type_id] = Ticket::Article::Type.lookup( :name => 'email' ).id
article_new[:internal] = false
elsif article_new[:ticket_article_type] == 'email-internal'
article_new[:ticket_article_type_id] = Ticket::Article::Type.lookup( :name => 'email' ).id
elsif article_new[:type] == 'email-internal'
article_new[:type_id] = Ticket::Article::Type.lookup( :name => 'email' ).id
article_new[:internal] = true
elsif article_new[:ticket_article_type] == 'note-external'
article_new[:ticket_article_type_id] = Ticket::Article::Type.lookup( :name => 'note' ).id
elsif article_new[:type] == 'note-external'
article_new[:type_id] = Ticket::Article::Type.lookup( :name => 'note' ).id
article_new[:internal] = false
elsif article_new[:ticket_article_type] == 'note-internal'
article_new[:ticket_article_type_id] = Ticket::Article::Type.lookup( :name => 'note' ).id
elsif article_new[:type] == 'note-internal'
article_new[:type_id] = Ticket::Article::Type.lookup( :name => 'note' ).id
article_new[:internal] = true
elsif article_new[:ticket_article_type] == 'phone'
article_new[:ticket_article_type_id] = Ticket::Article::Type.lookup( :name => 'phone' ).id
elsif article_new[:type] == 'phone'
article_new[:type_id] = Ticket::Article::Type.lookup( :name => 'phone' ).id
article_new[:internal] = false
elsif article_new[:ticket_article_type] == 'webrequest'
article_new[:ticket_article_type_id] = Ticket::Article::Type.lookup( :name => 'web' ).id
elsif article_new[:type] == 'webrequest'
article_new[:type_id] = Ticket::Article::Type.lookup( :name => 'web' ).id
article_new[:internal] = false
else
article_new[:ticket_article_type_id] = 9
article_new[:type_id] = 9
end
article_new.delete( :ticket_article_type )
article_new.delete( :type )
article_old = Ticket::Article.where( :id => article_new[:id] ).first
#puts 'ARTICLE OLD ' + article_old.inspect
# set state types
@ -466,7 +466,7 @@ module Import::OTRS
:o_id => history['TicketID'],
:history_type => 'updated',
:history_object => 'Ticket',
:history_attribute => 'ticket_state',
:history_attribute => 'state',
:value_from => from,
:id_from => from_id,
:value_to => to,
@ -516,7 +516,7 @@ module Import::OTRS
:o_id => history['TicketID'],
:history_type => 'updated',
:history_object => 'Ticket',
:history_attribute => 'ticket_priority',
:history_attribute => 'priority',
:value_from => from,
:value_to => to,
:id_from => from_id,
@ -542,7 +542,7 @@ module Import::OTRS
}
end
def self.ticket_state
def self.state
response = request( "public.pl?Action=Export;Type=State" )
return if !response
return if !response.success?
@ -587,8 +587,8 @@ module Import::OTRS
if state['TypeName'] == 'pending auto'
state['TypeName'] = 'pending action'
end
ticket_state_type = Ticket::StateType.where( :name => state['TypeName'] ).first
state_new[:state_type_id] = ticket_state_type.id
state_type = Ticket::StateType.where( :name => state['TypeName'] ).first
state_new[:state_type_id] = state_type.id
if state_old
# puts 'TS: ' + state_new.inspect
state_old.update_attributes(state_new)
@ -599,7 +599,7 @@ module Import::OTRS
end
}
end
def self.ticket_priority
def self.priority
response = request( "public.pl?Action=Export;Type=Priority" )
return if !response
return if !response.success?

View file

@ -29,16 +29,16 @@ class ActivityStreamTest < ActiveSupport::TestCase
:customer_id => current_user.id,
:owner_id => User.lookup( :login => '-' ).id,
:title => 'Unit Test 1 (äöüß)!',
:ticket_state_id => Ticket::State.lookup( :name => 'new' ).id,
:ticket_priority_id => Ticket::Priority.lookup( :name => '2 normal' ).id,
:state_id => Ticket::State.lookup( :name => 'new' ).id,
:priority_id => Ticket::Priority.lookup( :name => '2 normal' ).id,
:updated_by_id => current_user.id,
:created_by_id => current_user.id,
},
:article => {
:updated_by_id => current_user.id,
:created_by_id => current_user.id,
:ticket_article_type_id => Ticket::Article::Type.lookup( :name => 'phone' ).id,
:ticket_article_sender_id => Ticket::Article::Sender.lookup( :name => 'Customer' ).id,
:type_id => Ticket::Article::Type.lookup( :name => 'phone' ).id,
:sender_id => Ticket::Article::Sender.lookup( :name => 'Customer' ).id,
:from => 'Unit Test <unittest@example.com>',
:body => 'Unit Test 123',
:internal => false
@ -47,8 +47,8 @@ class ActivityStreamTest < ActiveSupport::TestCase
:update => {
:ticket => {
:title => 'Unit Test 1 (äöüß) - update!',
:ticket_state_id => Ticket::State.lookup( :name => 'open' ).id,
:ticket_priority_id => Ticket::Priority.lookup( :name => '1 low' ).id,
:state_id => Ticket::State.lookup( :name => 'open' ).id,
:priority_id => Ticket::Priority.lookup( :name => '1 low' ).id,
},
},
:check => [
@ -286,7 +286,8 @@ class ActivityStreamTest < ActiveSupport::TestCase
:update2 => {
:user => {
:firstname => 'Bob',
:lastname => 'Smith', },
:lastname => 'Smith',
},
},
:check => [
{

View file

@ -23,13 +23,13 @@ Some Textäöü",
:success => true,
:result => {
0 => {
:ticket_priority => '2 normal',
:priority => '2 normal',
:title => 'äöü some subject',
},
1 => {
:body => 'Some Textäöü',
:ticket_article_sender => 'Customer',
:ticket_article_type => 'email',
:sender => 'Customer',
:type => 'email',
:internal => false,
},
},
@ -43,13 +43,13 @@ Some Textäöü".encode("ISO-8859-1"),
:success => true,
:result => {
0 => {
:ticket_priority => '2 normal',
:priority => '2 normal',
:title => '', # should be äöü some subject, but can not be parsed from mime tools
},
1 => {
:body => 'Some Textäöü',
:ticket_article_sender => 'Customer',
:ticket_article_type => 'email',
:sender => 'Customer',
:type => 'email',
:internal => false,
},
},
@ -119,13 +119,13 @@ Some Text",
:success => true,
:result => {
0 => {
:ticket_priority => '2 normal',
:priority => '2 normal',
:title => '【专业为您注册香港及海外公司(好处多多)】                                                                                                                                                                                                                                     ',
},
1 => {
:body => 'Some Text',
:ticket_article_sender => 'Customer',
:ticket_article_type => 'email',
:sender => 'Customer',
:type => 'email',
},
},
},
@ -148,9 +148,9 @@ Some Text',
:data => 'From: me@example.com
To: customer@example.com
Subject: some subject
X-Zammad-Ticket-Ticket_Priority: 3 high
X-Zammad-Article-Ticket_Article_Sender: System
x-Zammad-Article-Ticket_Article_Type: phone
X-Zammad-Ticket-priority: 3 high
X-Zammad-Article-sender: System
x-Zammad-Article-type: phone
x-Zammad-Article-Internal: true
Some Text',
@ -158,12 +158,12 @@ Some Text',
:success => true,
:result => {
0 => {
:ticket_priority => '3 high',
:priority => '3 high',
:title => 'some subject',
},
1 => {
:ticket_article_sender => 'System',
:ticket_article_type => 'phone',
:sender => 'System',
:type => 'phone',
:internal => true,
},
},
@ -178,9 +178,9 @@ Some Text',
:data => 'From: me@example.com
To: customer@example.com
Subject: some subject
X-Zammad-Ticket-Ticket_Priority: 3 high
X-Zammad-Article-Ticket_Article_Sender: System
x-Zammad-Article-Ticket_Article_Type: phone
X-Zammad-Ticket-Priority: 3 high
X-Zammad-Article-Sender: System
x-Zammad-Article-Type: phone
x-Zammad-Article-Internal: true
Some Text',
@ -188,12 +188,12 @@ Some Text',
:success => true,
:result => {
0 => {
:ticket_priority => '2 normal',
:priority => '2 normal',
:title => 'some subject',
},
1 => {
:ticket_article_sender => 'Customer',
:ticket_article_type => 'email',
:sender => 'Customer',
:type => 'email',
:internal => false,
},
},
@ -215,7 +215,7 @@ Some Text',
:from => 'nobody@example.com',
},
:perform => {
'X-Zammad-Ticket-Ticket_Priority' => '3 high',
'X-Zammad-Ticket-priority' => '3 high',
},
:channel => 'email',
:active => true,
@ -262,12 +262,12 @@ Some Text',
:result => {
0 => {
:group => group.name,
:ticket_priority => '2 normal',
:priority => '2 normal',
:title => 'some subject',
},
1 => {
:ticket_article_sender => 'Customer',
:ticket_article_type => 'email',
:sender => 'Customer',
:type => 'email',
:internal => true,
},
},
@ -284,12 +284,12 @@ Some Text',
:result => {
0 => {
:group => 'Twitter',
:ticket_priority => '2 normal',
:priority => '2 normal',
:title => 'some subject',
},
1 => {
:ticket_article_sender => 'Customer',
:ticket_article_type => 'email',
:sender => 'Customer',
:type => 'email',
:internal => true,
},
},

View file

@ -15,16 +15,16 @@ class HistoryTest < ActiveSupport::TestCase
:customer_id => current_user.id,
:owner_id => User.lookup( :login => '-' ).id,
:title => 'Unit Test 1 (äöüß)!',
:ticket_state_id => Ticket::State.lookup( :name => 'new' ).id,
:ticket_priority_id => Ticket::Priority.lookup( :name => '2 normal' ).id,
:state_id => Ticket::State.lookup( :name => 'new' ).id,
:priority_id => Ticket::Priority.lookup( :name => '2 normal' ).id,
:updated_by_id => current_user.id,
:created_by_id => current_user.id,
},
:article => {
:updated_by_id => current_user.id,
:created_by_id => current_user.id,
:ticket_article_type_id => Ticket::Article::Type.lookup( :name => 'phone' ).id,
:ticket_article_sender_id => Ticket::Article::Sender.lookup( :name => 'Customer' ).id,
:type_id => Ticket::Article::Type.lookup( :name => 'phone' ).id,
:sender_id => Ticket::Article::Sender.lookup( :name => 'Customer' ).id,
:from => 'Unit Test <unittest@example.com>',
:body => 'Unit Test 123',
:internal => false
@ -33,8 +33,8 @@ class HistoryTest < ActiveSupport::TestCase
:ticket_update => {
:ticket => {
:title => 'Unit Test 1 (äöüß) - update!',
:ticket_state_id => Ticket::State.lookup( :name => 'open' ).id,
:ticket_priority_id => Ticket::Priority.lookup( :name => '1 low' ).id,
:state_id => Ticket::State.lookup( :name => 'open' ).id,
:priority_id => Ticket::Priority.lookup( :name => '1 low' ).id,
},
},
:history_check => [
@ -55,7 +55,7 @@ class HistoryTest < ActiveSupport::TestCase
:result => true,
:history_object => 'Ticket',
:history_type => 'updated',
:history_attribute => 'ticket_state',
:history_attribute => 'state',
:value_from => 'new',
:value_to => 'open',
:id_from => Ticket::State.lookup( :name => 'new' ).id,
@ -82,16 +82,16 @@ class HistoryTest < ActiveSupport::TestCase
:customer_id => current_user.id,
:owner_id => User.lookup( :login => '-' ).id,
:title => 'Unit Test 2 (äöüß)!',
:ticket_state_id => Ticket::State.lookup( :name => 'new' ).id,
:ticket_priority_id => Ticket::Priority.lookup( :name => '2 normal' ).id,
:state_id => Ticket::State.lookup( :name => 'new' ).id,
:priority_id => Ticket::Priority.lookup( :name => '2 normal' ).id,
:updated_by_id => current_user.id,
:created_by_id => current_user.id,
},
:article => {
:created_by_id => current_user.id,
:updated_by_id => current_user.id,
:ticket_article_type_id => Ticket::Article::Type.lookup(:name => 'phone' ).id,
:ticket_article_sender_id => Ticket::Article::Sender.lookup(:name => 'Customer' ).id,
:type_id => Ticket::Article::Type.lookup(:name => 'phone' ).id,
:sender_id => Ticket::Article::Sender.lookup(:name => 'Customer' ).id,
:from => 'Unit Test <unittest@example.com>',
:body => 'Unit Test 123',
:internal => false
@ -100,7 +100,7 @@ class HistoryTest < ActiveSupport::TestCase
:ticket_update => {
:ticket => {
:title => 'Unit Test 2 (äöüß) - update!',
:ticket_state_id => Ticket::State.lookup( :name => 'open' ).id,
:state_id => Ticket::State.lookup( :name => 'open' ).id,
:owner_id => current_user.id,
},
:article => {

View file

@ -7,8 +7,8 @@ class NotificationFactoryTest < ActiveSupport::TestCase
:title => 'some title äöüß',
:group => Group.lookup( :name => 'Users'),
:customer_id => 2,
:ticket_state => Ticket::State.lookup( :name => 'new' ),
:ticket_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,
)
@ -41,7 +41,7 @@ class NotificationFactoryTest < ActiveSupport::TestCase
},
{
:locale => 'de',
:string => '\'i18n(#{ticket.ticket_state.name})\' ticket state',
:string => '\'i18n(#{ticket.state.name})\' ticket state',
:result => '\'neu\' ticket state',
},
]

View file

@ -7,8 +7,8 @@ class TicketTest < ActiveSupport::TestCase
:title => 'some title äöüß',
:group => Group.lookup( :name => 'Users'),
:customer_id => 2,
:ticket_state => Ticket::State.lookup( :name => 'new' ),
:ticket_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,
)
@ -16,7 +16,7 @@ class TicketTest < ActiveSupport::TestCase
assert_equal( ticket.title, 'some title äöüß', 'ticket.title verify' )
assert_equal( ticket.group.name, 'Users', 'ticket.group verify' )
assert_equal( ticket.ticket_state.name, 'new', 'ticket.state verify' )
assert_equal( ticket.state.name, 'new', 'ticket.state verify' )
# create inbound article
article_inbound = Ticket::Article.create(
@ -27,8 +27,8 @@ class TicketTest < ActiveSupport::TestCase
:message_id => 'some@id',
:body => 'some message article_inbound 😍😍😍',
:internal => false,
:ticket_article_sender => Ticket::Article::Sender.where(:name => 'Customer').first,
:ticket_article_type => Ticket::Article::Type.where(:name => 'email').first,
:sender => Ticket::Article::Sender.where(:name => 'Customer').first,
:type => Ticket::Article::Type.where(:name => 'email').first,
:updated_by_id => 1,
:created_by_id => 1,
)
@ -49,8 +49,8 @@ class TicketTest < ActiveSupport::TestCase
:subject => 'some note',
:body => 'some message',
:internal => true,
:ticket_article_sender => Ticket::Article::Sender.where(:name => 'Agent').first,
:ticket_article_type => Ticket::Article::Type.where(:name => 'note').first,
:sender => Ticket::Article::Sender.where(:name => 'Agent').first,
:type => Ticket::Article::Type.where(:name => 'note').first,
:updated_by_id => 1,
:created_by_id => 1,
)
@ -73,8 +73,8 @@ class TicketTest < ActiveSupport::TestCase
:message_id => 'some@id2',
:body => 'some message 2',
:internal => false,
:ticket_article_sender => Ticket::Article::Sender.where(:name => 'Agent').first,
:ticket_article_type => Ticket::Article::Type.where(:name => 'email').first,
:sender => Ticket::Article::Sender.where(:name => 'Agent').first,
:type => Ticket::Article::Type.where(:name => 'email').first,
:updated_by_id => 1,
:created_by_id => 1,
)
@ -87,7 +87,7 @@ class TicketTest < ActiveSupport::TestCase
assert_equal( ticket.first_response.to_s, article_outbound.created_at.to_s, 'ticket.first_response verify - outbound' )
assert_equal( ticket.close_time, nil, 'ticket.close_time verify - outbound' )
ticket.ticket_state_id = Ticket::State.where(:name => 'closed').first.id
ticket.state_id = Ticket::State.where(:name => 'closed').first.id
ticket.save
ticket = Ticket.find(ticket.id)
@ -115,8 +115,8 @@ class TicketTest < ActiveSupport::TestCase
:title => 'some title äöüß',
:group => Group.lookup( :name => 'Users'),
:customer_id => 2,
:ticket_state => Ticket::State.lookup( :name => 'new' ),
:ticket_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,
@ -150,7 +150,7 @@ class TicketTest < ActiveSupport::TestCase
sla = Sla.create(
:name => 'test sla 2',
:condition => { "tickets.ticket_priority_id" =>["1", "2", "3"] },
:condition => { "tickets.priority_id" =>["1", "2", "3"] },
:data => {
"Mon"=>"Mon", "Tue"=>"Tue", "Wed"=>"Wed", "Thu"=>"Thu", "Fri"=>"Fri", "Sat"=>"Sat", "Sun"=>"Sun",
"beginning_of_workday" => "8:00",
@ -296,7 +296,7 @@ class TicketTest < ActiveSupport::TestCase
# set close time over time
ticket.update_attributes(
:ticket_state => Ticket::State.lookup( :name => 'closed' )
:state => Ticket::State.lookup( :name => 'closed' )
)
assert_equal( ticket.escalation_time, nil, 'ticket.escalation_time verify 9' )
@ -320,8 +320,8 @@ class TicketTest < ActiveSupport::TestCase
:title => 'some title äöüß',
:group => Group.lookup( :name => 'Users'),
:customer_id => 2,
:ticket_state => Ticket::State.lookup( :name => 'new' ),
:ticket_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',
@ -331,7 +331,7 @@ class TicketTest < ActiveSupport::TestCase
assert_equal( ticket.title, 'some title äöüß', 'ticket.title verify' )
assert_equal( ticket.group.name, 'Users', 'ticket.group verify' )
assert_equal( ticket.ticket_state.name, 'new', 'ticket.state verify' )
assert_equal( ticket.state.name, 'new', 'ticket.state verify' )
# create inbound article
article_inbound = Ticket::Article.create(
@ -342,8 +342,8 @@ class TicketTest < ActiveSupport::TestCase
:message_id => 'some@id',
:body => 'some message',
:internal => false,
:ticket_article_sender => Ticket::Article::Sender.where(:name => 'Customer').first,
:ticket_article_type => Ticket::Article::Type.where(:name => 'email').first,
:sender => Ticket::Article::Sender.where(:name => 'Customer').first,
:type => Ticket::Article::Type.where(:name => 'email').first,
:updated_by_id => 1,
:created_by_id => 1,
:created_at => '2013-03-28 23:49:00 UTC',
@ -366,8 +366,8 @@ class TicketTest < ActiveSupport::TestCase
:message_id => 'some@id2',
:body => 'some message 2',
:internal => false,
:ticket_article_sender => Ticket::Article::Sender.where(:name => 'Agent').first,
:ticket_article_type => Ticket::Article::Type.where(:name => 'email').first,
:sender => Ticket::Article::Sender.where(:name => 'Agent').first,
:type => Ticket::Article::Type.where(:name => 'email').first,
:updated_by_id => 1,
:created_by_id => 1,
:created_at => '2013-03-29 08:00:03 UTC',
@ -392,8 +392,8 @@ class TicketTest < ActiveSupport::TestCase
:title => 'some title äöüß',
:group => Group.lookup( :name => 'Users'),
:customer_id => 2,
:ticket_state => Ticket::State.lookup( :name => 'new' ),
:ticket_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',
@ -403,7 +403,7 @@ class TicketTest < ActiveSupport::TestCase
assert_equal( ticket.title, 'some title äöüß', 'ticket.title verify' )
assert_equal( ticket.group.name, 'Users', 'ticket.group verify' )
assert_equal( ticket.ticket_state.name, 'new', 'ticket.state verify' )
assert_equal( ticket.state.name, 'new', 'ticket.state verify' )
# create inbound article
article_inbound = Ticket::Article.create(
@ -413,8 +413,8 @@ class TicketTest < ActiveSupport::TestCase
:message_id => 'some@id',
:body => 'some message',
:internal => false,
:ticket_article_sender => Ticket::Article::Sender.where(:name => 'Customer').first,
:ticket_article_type => Ticket::Article::Type.where(:name => 'phone').first,
:sender => Ticket::Article::Sender.where(:name => 'Customer').first,
:type => Ticket::Article::Type.where(:name => 'phone').first,
:updated_by_id => 1,
:created_by_id => 1,
:created_at => '2013-03-28 23:49:00 UTC',
@ -447,8 +447,8 @@ class TicketTest < ActiveSupport::TestCase
:title => 'some title äöüß',
:group => Group.lookup( :name => 'Users'),
:customer_id => 2,
:ticket_state => Ticket::State.lookup( :name => 'new' ),
:ticket_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,
@ -489,8 +489,8 @@ class TicketTest < ActiveSupport::TestCase
:title => 'some title äöüß',
:group => Group.lookup( :name => 'Users'),
:customer_id => 2,
:ticket_state => Ticket::State.lookup( :name => 'new' ),
:ticket_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,
@ -532,8 +532,8 @@ class TicketTest < ActiveSupport::TestCase
:title => 'some title äöüß',
:group => Group.lookup( :name => 'Users'),
:customer_id => 2,
:ticket_state => Ticket::State.lookup( :name => 'new' ),
:ticket_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 06:30:00 UTC',
:updated_at => '2013-10-21 06:30:00 UTC',
:updated_by_id => 1,
@ -578,8 +578,8 @@ class TicketTest < ActiveSupport::TestCase
:title => 'some title äöüß3',
:group => Group.lookup( :name => 'Users'),
:customer_id => 2,
:ticket_state => Ticket::State.lookup( :name => 'new' ),
:ticket_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,
@ -591,7 +591,7 @@ class TicketTest < ActiveSupport::TestCase
History.add(
:history_type => 'updated',
:history_object => 'Ticket',
:history_attribute => 'ticket_state',
:history_attribute => 'state',
:o_id => ticket.id,
:id_to => 3,
:id_from => 2,
@ -606,7 +606,7 @@ class TicketTest < ActiveSupport::TestCase
History.add(
:history_type => 'updated',
:history_object => 'Ticket',
:history_attribute => 'ticket_state',
:history_attribute => 'state',
:o_id => ticket.id,
:id_to => 2,
:id_from => 3,
@ -631,7 +631,7 @@ class TicketTest < ActiveSupport::TestCase
History.add(
:history_type => 'updated',
:history_object => 'Ticket',
:history_attribute => 'ticket_state',
:history_attribute => 'state',
:o_id => ticket.id,
:id_to => 3,
:id_from => 2,
@ -683,8 +683,8 @@ class TicketTest < ActiveSupport::TestCase
:title => 'some title äöüß3',
:group => Group.lookup( :name => 'Users'),
:customer_id => 2,
:ticket_state => Ticket::State.lookup( :name => 'pending' ),
:ticket_priority => Ticket::Priority.lookup( :name => '2 normal' ),
:state => Ticket::State.lookup( :name => 'pending' ),
: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,
@ -697,7 +697,7 @@ class TicketTest < ActiveSupport::TestCase
History.add(
:history_type => 'updated',
:history_object => 'Ticket',
:history_attribute => 'ticket_state',
:history_attribute => 'state',
:o_id => ticket.id,
:id_to => 4,
:id_from => 3,
@ -749,8 +749,8 @@ class TicketTest < ActiveSupport::TestCase
:title => 'some title äöüß3',
:group => Group.lookup( :name => 'Users'),
:customer_id => 2,
:ticket_state => Ticket::State.lookup( :name => 'pending' ),
:ticket_priority => Ticket::Priority.lookup( :name => '2 normal' ),
:state => Ticket::State.lookup( :name => 'pending' ),
: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,
@ -762,7 +762,7 @@ class TicketTest < ActiveSupport::TestCase
History.add(
:history_type => 'updated',
:history_object => 'Ticket',
:history_attribute => 'ticket_state',
:history_attribute => 'state',
:o_id => ticket.id,
:id_to => 2,
:id_from => 3,
@ -777,7 +777,7 @@ class TicketTest < ActiveSupport::TestCase
History.add(
:history_type => 'updated',
:history_object => 'Ticket',
:history_attribute => 'ticket_state',
:history_attribute => 'state',
:o_id => ticket.id,
:id_to => 3,
:id_from => 2,
@ -792,7 +792,7 @@ class TicketTest < ActiveSupport::TestCase
History.add(
:history_type => 'updated',
:history_object => 'Ticket',
:history_attribute => 'ticket_state',
:history_attribute => 'state',
:o_id => ticket.id,
:id_to => 4,
:id_from => 3,
@ -844,8 +844,8 @@ class TicketTest < ActiveSupport::TestCase
:title => 'some title äöüß3',
:group => Group.lookup( :name => 'Users'),
:customer_id => 2,
:ticket_state => Ticket::State.lookup( :name => 'pending' ),
:ticket_priority => Ticket::Priority.lookup( :name => '2 normal' ),
:state => Ticket::State.lookup( :name => 'pending' ),
: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,
@ -857,7 +857,7 @@ class TicketTest < ActiveSupport::TestCase
History.add(
:history_type => 'updated',
:history_object => 'Ticket',
:history_attribute => 'ticket_state',
:history_attribute => 'state',
:o_id => ticket.id,
:id_to => 2,
:id_from => 3,
@ -872,7 +872,7 @@ class TicketTest < ActiveSupport::TestCase
History.add(
:history_type => 'updated',
:history_object => 'Ticket',
:history_attribute => 'ticket_state',
:history_attribute => 'state',
:o_id => ticket.id,
:id_to => 3,
:id_from => 2,
@ -887,7 +887,7 @@ class TicketTest < ActiveSupport::TestCase
History.add(
:history_type => 'updated',
:history_object => 'Ticket',
:history_attribute => 'ticket_state',
:history_attribute => 'state',
:o_id => ticket.id,
:id_to => 2,
:id_from => 3,
@ -902,7 +902,7 @@ class TicketTest < ActiveSupport::TestCase
History.add(
:history_type => 'updated',
:history_object => 'Ticket',
:history_attribute => 'ticket_state',
:history_attribute => 'state',
:o_id => ticket.id,
:id_to => 4,
:id_from => 3,

View file

@ -62,16 +62,16 @@ class TwitterTest < ActiveSupport::TestCase
:group_id => group.id,
:customer_id => user.id,
:title => text[0,40],
:ticket_state_id => state.id,
:ticket_priority_id => priority.id,
:state_id => state.id,
:priority_id => priority.id,
:updated_by_id => 1,
:created_by_id => 1,
)
assert( ticket, "outbound ticket created" )
article = Ticket::Article.create(
:ticket_id => ticket.id,
:ticket_article_type_id => Ticket::Article::Type.where( :name => 'twitter status' ).first.id,
:ticket_article_sender_id => Ticket::Article::Sender.where( :name => 'Agent' ).first.id,
:type_id => Ticket::Article::Type.where( :name => 'twitter status' ).first.id,
:sender_id => Ticket::Article::Sender.where( :name => 'Agent' ).first.id,
:body => text,
# :from => sender.name,
# :to => to,
@ -173,13 +173,13 @@ class TwitterTest < ActiveSupport::TestCase
assert( ticket.articles, "ticket.articles exists" )
article_count = ticket.articles.count
assert( article_count )
# assert_equal( ticket.ticket_state.name, 'new' )
# assert_equal( ticket.state.name, 'new' )
# reply via ticket
outbound_article = Ticket::Article.create(
:ticket_id => ticket.id,
:ticket_article_type_id => Ticket::Article::Type.where( :name => 'twitter direct-message' ).first.id,
:ticket_article_sender_id => Ticket::Article::Sender.where( :name => 'Agent' ).first.id,
:type_id => Ticket::Article::Type.where( :name => 'twitter direct-message' ).first.id,
:sender_id => Ticket::Article::Sender.where( :name => 'Agent' ).first.id,
:body => text,
# :from => sender.name,
:to => 'me_bauer',