Merge branch 'develop' of github.com:martini/zammad into develop

Conflicts:
	test/unit/ticket_sla_test.rb
This commit is contained in:
Martin Edenhofer 2015-04-27 19:44:35 +02:00
commit 7ff5568b37
59 changed files with 361 additions and 358 deletions

View file

@ -267,7 +267,7 @@ class ApplicationController < ActionController::Base
next if t.name =~ /^MST/ next if t.name =~ /^MST/
next if t.name =~ /^ROC/ next if t.name =~ /^ROC/
next if t.name =~ /^ROK/ next if t.name =~ /^ROK/
diff = t.current_period.utc_total_offset / 60 /60 diff = t.current_period.utc_total_offset / 60 / 60
config['timezones'][ t.name ] = diff config['timezones'][ t.name ] = diff
} }

View file

@ -76,7 +76,7 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
# validate url # validate url
messages = {} messages = {}
if !Setting.get('system_online_service') if !Setting.get('system_online_service')
if !params[:url] ||params[:url] !~ /^(http|https):\/\/.+?$/ if !params[:url] || params[:url] !~ /^(http|https):\/\/.+?$/
messages[:url] = 'A URL looks like http://zammad.example.com' messages[:url] = 'A URL looks like http://zammad.example.com'
end end
end end

View file

@ -6,7 +6,7 @@ class ImportOtrsController < ApplicationController
return if setup_done_response return if setup_done_response
# validate # validate
if !params[:url] ||params[:url] !~ /^(http|https):\/\/.+?$/ if !params[:url] || params[:url] !~ /^(http|https):\/\/.+?$/
render json: { render json: {
result: 'invalid', result: 'invalid',
message: 'Invalid!', message: 'Invalid!',

View file

@ -105,7 +105,7 @@ curl http://localhost/api/v1/online_notifications/mark_all_as_read -v -u #{login
=end =end
def mark_all_as_read def mark_all_as_read
notifications = OnlineNotification.list(current_user,100) notifications = OnlineNotification.list(current_user, 100)
notifications.each do |notification| notifications.each do |notification|
if !notification['seen'] if !notification['seen']
OnlineNotification.seen( id: notification['id'] ) OnlineNotification.seen( id: notification['id'] )

View file

@ -127,7 +127,7 @@ class SessionsController < ApplicationController
request.env['rack.session.options'][:expire_after] = -1.year request.env['rack.session.options'][:expire_after] = -1.year
request.env['rack.session.options'][:renew] = true request.env['rack.session.options'][:renew] = true
render json: { } render json: {}
end end
def create_omniauth def create_omniauth

View file

@ -18,7 +18,7 @@ class TaskbarController < ApplicationController
end end
def create def create
model_create_render(Taskbar,params) model_create_render(Taskbar, params)
end end
def update def update

View file

@ -89,7 +89,7 @@ return all activity entries of an user
=end =end
def self.list(user,limit) def self.list(user, limit)
role_ids = user.role_ids role_ids = user.role_ids
group_ids = user.group_ids group_ids = user.group_ids

View file

@ -108,7 +108,7 @@ returns
# set relations # set relations
self.class.reflect_on_all_associations.map { |assoc| self.class.reflect_on_all_associations.map { |assoc|
real_key = assoc.name.to_s[0,assoc.name.to_s.length-1] + '_ids' real_key = assoc.name.to_s[0, assoc.name.to_s.length - 1] + '_ids'
if params.has_key?( real_key.to_sym ) if params.has_key?( real_key.to_sym )
list_of_items = params[ real_key.to_sym ] list_of_items = params[ real_key.to_sym ]
if params[ real_key.to_sym ].class != Array if params[ real_key.to_sym ].class != Array
@ -141,7 +141,7 @@ returns
# set relations # set relations
attributes = self.attributes attributes = self.attributes
self.class.reflect_on_all_associations.map { |assoc| self.class.reflect_on_all_associations.map { |assoc|
real_key = assoc.name.to_s[0,assoc.name.to_s.length-1] + '_ids' real_key = assoc.name.to_s[0, assoc.name.to_s.length - 1] + '_ids'
if self.respond_to?( real_key ) if self.respond_to?( real_key )
attributes[ real_key ] = self.send( real_key ) attributes[ real_key ] = self.send( real_key )
end end
@ -872,13 +872,13 @@ log object update history with all updated attributes, if configured - will be e
# get attribute name # get attribute name
attribute_name = key.to_s attribute_name = key.to_s
if attribute_name[-3,3] == '_id' if attribute_name[-3, 3] == '_id'
attribute_name = attribute_name[ 0, attribute_name.length-3 ] attribute_name = attribute_name[ 0, attribute_name.length - 3 ]
end end
value_id = [] value_id = []
value_str = [ value[0], value[1] ] value_str = [ value[0], value[1] ]
if key.to_s[-3,3] == '_id' if key.to_s[-3, 3] == '_id'
value_id[0] = value[0] value_id[0] = value[0]
value_id[1] = value[1] value_id[1] = value[1]

View file

@ -112,8 +112,8 @@ returns
# get attribute name # get attribute name
attribute_name_with_id = key.to_s attribute_name_with_id = key.to_s
attribute_name = key.to_s attribute_name = key.to_s
next if attribute_name[-3,3] != '_id' next if attribute_name[-3, 3] != '_id'
attribute_name = attribute_name[ 0, attribute_name.length-3 ] attribute_name = attribute_name[ 0, attribute_name.length - 3 ]
# check if attribute method exists # check if attribute method exists
next if !ref_object.respond_to?( attribute_name ) next if !ref_object.respond_to?( attribute_name )

View file

@ -526,7 +526,7 @@ class Channel::EmailParser
def set_attributes_by_x_headers( item_object, header_name, mail ) def set_attributes_by_x_headers( item_object, header_name, mail )
# loop all x-zammad-hedaer-* headers # loop all x-zammad-hedaer-* headers
item_object.attributes.each{|key,value| item_object.attributes.each{|key, value|
# ignore read only attributes # ignore read only attributes
next if key == 'updated_at' next if key == 'updated_at'
@ -535,9 +535,9 @@ class Channel::EmailParser
next if key == 'created_by_id' next if key == 'created_by_id'
# check if id exists # check if id exists
key_short = key[ key.length-3 , key.length ] key_short = key[ key.length - 3, key.length ]
if key_short == '_id' if key_short == '_id'
key_short = key[ 0, key.length-3 ] key_short = key[ 0, key.length - 3 ]
header = "x-zammad-#{header_name}-#{key_short}" header = "x-zammad-#{header_name}-#{key_short}"
if mail[ header.to_sym ] if mail[ header.to_sym ]
puts "NOTICE: header #{header} found #{mail[ header.to_sym ]}" puts "NOTICE: header #{header} found #{mail[ header.to_sym ]}"

View file

@ -65,7 +65,7 @@ class Channel::IMAP < Channel::EmailParser
# check for verify message # check for verify message
if check_type == 'verify' if check_type == 'verify'
subject = @imap.fetch(message_id,'ENVELOPE')[0].attr['ENVELOPE'].subject subject = @imap.fetch(message_id, 'ENVELOPE')[0].attr['ENVELOPE'].subject
if subject && subject =~ /#{verify_string}/ if subject && subject =~ /#{verify_string}/
puts " - verify email #{verify_string} found" puts " - verify email #{verify_string} found"
@imap.store(message_id, '+FLAGS', [:Deleted]) @imap.store(message_id, '+FLAGS', [:Deleted])
@ -76,7 +76,7 @@ class Channel::IMAP < Channel::EmailParser
else else
# delete email from server after article was created # delete email from server after article was created
msg = @imap.fetch(message_id,'RFC822')[0].attr['RFC822'] msg = @imap.fetch(message_id, 'RFC822')[0].attr['RFC822']
if process(channel, msg) if process(channel, msg)
@imap.store(message_id, '+FLAGS', [:Deleted]) @imap.store(message_id, '+FLAGS', [:Deleted])
end end

View file

@ -227,7 +227,7 @@ class Channel::TWITTER2
ticket = Ticket.create( ticket = Ticket.create(
group_id: group_id, group_id: group_id,
customer_id: user.id, customer_id: user.id,
title: tweet.text[0,40], title: tweet.text[0, 40],
state_id: state_id, state_id: state_id,
priority_id: priority_id, priority_id: priority_id,
) )

View file

@ -70,7 +70,7 @@ class Observer::Ticket::Notification::BackgroundJob
object: 'Ticket', object: 'Ticket',
o_id: ticket.id, o_id: ticket.id,
seen: seen, seen: seen,
created_by_id: ticket.updated_by_id || 1, created_by_id: ticket.updated_by_id ||  1,
user_id: user.id, user_id: user.id,
) )
@ -134,7 +134,7 @@ class Observer::Ticket::Notification::BackgroundJob
history_type: 'notification', history_type: 'notification',
history_object: 'Ticket', history_object: 'Ticket',
value_to: recipient_list, value_to: recipient_list,
created_by_id: ticket.updated_by_id || 1 created_by_id: ticket.updated_by_id ||  1
) )
end end
end end
@ -165,8 +165,8 @@ class Observer::Ticket::Notification::BackgroundJob
# get attribute name # get attribute name
attribute_name = key.to_s attribute_name = key.to_s
object_manager_attribute = attribute_list[attribute_name] object_manager_attribute = attribute_list[attribute_name]
if attribute_name[-3,3] == '_id' if attribute_name[-3, 3] == '_id'
attribute_name = attribute_name[ 0, attribute_name.length-3 ].to_s attribute_name = attribute_name[ 0, attribute_name.length - 3 ].to_s
end end
# add item to changes hash # add item to changes hash
@ -177,7 +177,7 @@ class Observer::Ticket::Notification::BackgroundJob
# if changed item is an _id field/reference, do an lookup for the realy values # if changed item is an _id field/reference, do an lookup for the realy values
value_id = [] value_id = []
value_str = [ value[0], value[1] ] value_str = [ value[0], value[1] ]
if key.to_s[-3,3] == '_id' if key.to_s[-3, 3] == '_id'
value_id[0] = value[0] value_id[0] = value[0]
value_id[1] = value[1] value_id[1] = value[1]
@ -289,7 +289,7 @@ State: i18n(#{ticket.state.name.text2html})<br>
def template_update(user, ticket, article, ticket_changes) def template_update(user, ticket, article, ticket_changes)
changes = '' changes = ''
ticket_changes.each {|key,value| ticket_changes.each {|key, value|
changes += "i18n(#{key.to_s.text2html}): #{value[0].to_s.text2html} -> #{value[1].to_s.text2html}<br>\n" changes += "i18n(#{key.to_s.text2html}): #{value[0].to_s.text2html} -> #{value[1].to_s.text2html}<br>\n"
} }
article_content = '' article_content = ''
@ -339,7 +339,7 @@ Changes:<br>
end end
body = template_header(user) + body body = template_header(user) + body
body += template_footer(user,ticket, article) body += template_footer(user, ticket, article)
template = { template = {
subject: subject, subject: subject,

View file

@ -85,7 +85,7 @@ return all online notifications of an user
=end =end
def self.list(user,limit) def self.list(user, limit)
notifications = OnlineNotification.where(user_id: user.id). notifications = OnlineNotification.where(user_id: user.id).
order( 'created_at DESC, id DESC' ). order( 'created_at DESC, id DESC' ).
@ -167,7 +167,7 @@ returns:
=end =end
def self.list_full(user,limit) def self.list_full(user, limit)
notifications = OnlineNotification.list(user, limit) notifications = OnlineNotification.list(user, limit)
assets = ApplicationModel.assets_of_object_list(notifications) assets = ApplicationModel.assets_of_object_list(notifications)

View file

@ -21,8 +21,8 @@ returns
# get attribute name # get attribute name
attribute_name = key.to_s attribute_name = key.to_s
next if attribute_name[-3,3] != '_id' next if attribute_name[-3, 3] != '_id'
attribute_name = attribute_name[ 0, attribute_name.length-3 ] attribute_name = attribute_name[ 0, attribute_name.length - 3 ]
# check if attribute method exists # check if attribute method exists
next if !ref_object.respond_to?( attribute_name ) next if !ref_object.respond_to?( attribute_name )

View file

@ -207,11 +207,11 @@ class Package < ApplicationModel
end end
# uninstall files of old package # uninstall files of old package
self.uninstall({ self.uninstall(
name: package_db.name, name: package_db.name,
version: package_db.version, version: package_db.version,
migration_not_down: true, migration_not_down: true,
}) )
end end
# store package # store package
@ -391,7 +391,7 @@ class Package < ApplicationModel
# check if directories need to be created # check if directories need to be created
directories = location.split '/' directories = location.split '/'
(0..(directories.length-2) ).each {|position| (0..(directories.length - 2) ).each {|position|
tmp_path = '' tmp_path = ''
(1..position).each {|count| (1..position).each {|count|
tmp_path = tmp_path + '/' + directories[count].to_s tmp_path = tmp_path + '/' + directories[count].to_s

View file

@ -60,7 +60,7 @@ class Store::Provider::File
end end
# write file to fs # write file to fs
def self.write_to_fs(data,sha) def self.write_to_fs(data, sha)
# install file # install file
permission = '600' permission = '600'

View file

@ -366,7 +366,7 @@ returns
=end =end
def self.password_reset_via_token(token,password) def self.password_reset_via_token(token, password)
# check token # check token
user = Token.check( action: 'PasswordReset', name: token ) user = Token.check( action: 'PasswordReset', name: token )

View file

@ -6,6 +6,6 @@ Zammad::Application.routes.draw do
match api_path + '/networks/:id', to: 'networks#show', via: :get match api_path + '/networks/:id', to: 'networks#show', via: :get
match api_path + '/networks', to: 'networks#create', via: :post match api_path + '/networks', to: 'networks#create', via: :post
match api_path + '/networks/:id', to: 'networks#update', via: :put match api_path + '/networks/:id', to: 'networks#update', via: :put
match api_path + '/networks/:id', to: 'networks#destroy',via: :delete match api_path + '/networks/:id', to: 'networks#destroy', via: :delete
end end

View file

@ -6,6 +6,6 @@ Zammad::Application.routes.draw do
match api_path + '/organizations/:id', to: 'organizations#show', via: :get match api_path + '/organizations/:id', to: 'organizations#show', via: :get
match api_path + '/organizations', to: 'organizations#create', via: :post match api_path + '/organizations', to: 'organizations#create', via: :post
match api_path + '/organizations/:id', to: 'organizations#update', via: :put match api_path + '/organizations/:id', to: 'organizations#update', via: :put
match api_path + '/organizations/history/:id',to: 'organizations#history',via: :get match api_path + '/organizations/history/:id', to: 'organizations#history', via: :get
end end

View file

@ -5,6 +5,6 @@ Zammad::Application.routes.draw do
match api_path + '/taskbar/:id', to: 'taskbar#show', via: :get match api_path + '/taskbar/:id', to: 'taskbar#show', via: :get
match api_path + '/taskbar', to: 'taskbar#create', via: :post match api_path + '/taskbar', to: 'taskbar#create', via: :post
match api_path + '/taskbar/:id', to: 'taskbar#update', via: :put match api_path + '/taskbar/:id', to: 'taskbar#update', via: :put
match api_path + '/taskbar/:id', to: 'taskbar#destroy',via: :delete match api_path + '/taskbar/:id', to: 'taskbar#destroy', via: :delete
end end

View file

@ -33,7 +33,7 @@ class CreateBase < ActiveRecord::Migration
t.column :last_login, :timestamp, null: true t.column :last_login, :timestamp, null: true
t.column :source, :string, limit: 200, null: true t.column :source, :string, limit: 200, null: true
t.column :login_failed, :integer, null: false, default: 0 t.column :login_failed, :integer, null: false, default: 0
t.column :preferences, :string, limit: 8000,null: true t.column :preferences, :string, limit: 8000, null: true
t.column :updated_by_id, :integer, null: false t.column :updated_by_id, :integer, null: false
t.column :created_by_id, :integer, null: false t.column :created_by_id, :integer, null: false
t.timestamps t.timestamps

View file

@ -35,10 +35,10 @@ class CreateTicket < ActiveRecord::Migration
t.references :state, null: false t.references :state, null: false
t.references :organization, null: true t.references :organization, null: true
t.column :number, :string, limit: 60, null: false t.column :number, :string, limit: 60, null: false
t.column :title, :string, limit: 250,null: false t.column :title, :string, limit: 250, null: false
t.column :owner_id, :integer, null: false t.column :owner_id, :integer, null: false
t.column :customer_id, :integer, null: false t.column :customer_id, :integer, null: false
t.column :note, :string, limit: 250,null: true t.column :note, :string, limit: 250, null: true
t.column :first_response, :timestamp, null: true t.column :first_response, :timestamp, null: true
t.column :first_response_escal_date, :timestamp, null: true t.column :first_response_escal_date, :timestamp, null: true
t.column :first_response_sla_time, :timestamp, null: true t.column :first_response_sla_time, :timestamp, null: true

View file

@ -168,7 +168,7 @@ class CreateObjectManager < ActiveRecord::Migration
null: false, null: false,
default: 2, default: 2,
translate: true, translate: true,
filter: [1,2,3,4,7], filter: [1, 2, 3, 4, 7],
}, },
editable: false, editable: false,
active: true, active: true,
@ -182,7 +182,7 @@ class CreateObjectManager < ActiveRecord::Migration
item_class: 'column', item_class: 'column',
nulloption: false, nulloption: false,
null: true, null: true,
filter: [1,4], filter: [1, 4],
default: 1, default: 1,
}, },
}, },
@ -190,12 +190,12 @@ class CreateObjectManager < ActiveRecord::Migration
Agent: { Agent: {
nulloption: false, nulloption: false,
null: false, null: false,
filter: [2,3,4,7], filter: [2, 3, 4, 7],
}, },
Customer: { Customer: {
nulloption: false, nulloption: false,
null: true, null: true,
filter: [2,4], filter: [2, 4],
default: 2, default: 2,
}, },
}, },
@ -217,10 +217,10 @@ class CreateObjectManager < ActiveRecord::Migration
null: true, null: true,
translate: true, translate: true,
required_if: { required_if: {
state_id: [3,7] state_id: [3, 7]
}, },
shown_if: { shown_if: {
state_id: [3,7] state_id: [3, 7]
}, },
}, },
editable: false, editable: false,

View file

@ -14,7 +14,7 @@ class UpdateOverviewAndTicketState < ActiveRecord::Migration
condition: { condition: {
'tickets.state_id' => [3], 'tickets.state_id' => [3],
'tickets.owner_id' => 'current_user.id', 'tickets.owner_id' => 'current_user.id',
'tickets.pending_time' => { 'direction' => 'before', 'count'=> 1, 'area' => 'minute' }, 'tickets.pending_time' => { 'direction' => 'before', 'count' => 1, 'area' => 'minute' },
}, },
order: { order: {
by: 'created_at', by: 'created_at',
@ -43,7 +43,7 @@ class UpdateOverviewAndTicketState < ActiveRecord::Migration
null: false, null: false,
default: 2, default: 2,
translate: true, translate: true,
filter: [1,2,3,4,7], filter: [1, 2, 3, 4, 7],
}, },
editable: false, editable: false,
active: true, active: true,
@ -57,7 +57,7 @@ class UpdateOverviewAndTicketState < ActiveRecord::Migration
item_class: 'column', item_class: 'column',
nulloption: false, nulloption: false,
null: true, null: true,
filter: [1,4], filter: [1, 4],
default: 1, default: 1,
}, },
}, },
@ -65,12 +65,12 @@ class UpdateOverviewAndTicketState < ActiveRecord::Migration
Agent: { Agent: {
nulloption: false, nulloption: false,
null: false, null: false,
filter: [2,3,4,7], filter: [2, 3, 4, 7],
}, },
Customer: { Customer: {
nulloption: false, nulloption: false,
null: true, null: true,
filter: [2,4], filter: [2, 4],
default: 2, default: 2,
}, },
}, },
@ -93,10 +93,10 @@ class UpdateOverviewAndTicketState < ActiveRecord::Migration
null: true, null: true,
translate: true, translate: true,
required_if: { required_if: {
state_id: [3,7] state_id: [3, 7]
}, },
shown_if: { shown_if: {
state_id: [3,7] state_id: [3, 7]
}, },
}, },
editable: false, editable: false,

View file

@ -10,7 +10,7 @@ class UpdateOverview2 < ActiveRecord::Migration
prio: 1000, prio: 1000,
role_id: overview_role.id, role_id: overview_role.id,
condition: { condition: {
'tickets.state_id' => [ 1,2,3,7 ], 'tickets.state_id' => [ 1, 2, 3, 7 ],
'tickets.owner_id' => 'current_user.id', 'tickets.owner_id' => 'current_user.id',
}, },
order: { order: {

View file

@ -1406,7 +1406,7 @@ Overview.create_if_not_exists(
prio: 1000, prio: 1000,
role_id: overview_role.id, role_id: overview_role.id,
condition: { condition: {
'tickets.state_id' => [ 1,2,3,7 ], 'tickets.state_id' => [ 1, 2, 3, 7 ],
'tickets.owner_id' => 'current_user.id', 'tickets.owner_id' => 'current_user.id',
}, },
order: { order: {
@ -1429,7 +1429,7 @@ Overview.create_if_not_exists(
condition: { condition: {
'tickets.state_id' => [3], 'tickets.state_id' => [3],
'tickets.owner_id' => 'current_user.id', 'tickets.owner_id' => 'current_user.id',
'tickets.pending_time' => { 'direction' => 'before', 'count'=> 1, 'area' => 'minute' }, 'tickets.pending_time' => { 'direction' => 'before', 'count' => 1, 'area' => 'minute' },
}, },
order: { order: {
by: 'created_at', by: 'created_at',
@ -1449,7 +1449,7 @@ Overview.create_if_not_exists(
prio: 1020, prio: 1020,
role_id: overview_role.id, role_id: overview_role.id,
condition: { condition: {
'tickets.state_id' => [1,2,3], 'tickets.state_id' => [1, 2, 3],
'tickets.owner_id' => 1, 'tickets.owner_id' => 1,
}, },
order: { order: {
@ -1470,7 +1470,7 @@ Overview.create_if_not_exists(
prio: 1030, prio: 1030,
role_id: overview_role.id, role_id: overview_role.id,
condition: { condition: {
'tickets.state_id' => [1,2,3], 'tickets.state_id' => [1, 2, 3],
}, },
order: { order: {
by: 'created_at', by: 'created_at',
@ -1478,7 +1478,7 @@ Overview.create_if_not_exists(
}, },
view: { view: {
d: [ 'title', 'customer', 'group', 'state', 'owner', 'created_at' ], d: [ 'title', 'customer', 'group', 'state', 'owner', 'created_at' ],
s: [ 'title', 'customer', 'group', 'state', 'owner','created_at' ], s: [ 'title', 'customer', 'group', 'state', 'owner', 'created_at' ],
m: [ 'number', 'title', 'customer', 'group', 'state', 'owner', 'created_at' ], m: [ 'number', 'title', 'customer', 'group', 'state', 'owner', 'created_at' ],
view_mode_default: 's', view_mode_default: 's',
}, },
@ -1491,7 +1491,7 @@ Overview.create_if_not_exists(
role_id: overview_role.id, role_id: overview_role.id,
condition: { condition: {
'tickets.state_id' => [3], 'tickets.state_id' => [3],
'tickets.pending_time' => { 'direction' => 'before', 'count'=> 1, 'area' => 'minute' }, 'tickets.pending_time' => { 'direction' => 'before', 'count' => 1, 'area' => 'minute' },
}, },
order: { order: {
by: 'created_at', by: 'created_at',
@ -1511,7 +1511,7 @@ Overview.create_if_not_exists(
prio: 1040, prio: 1040,
role_id: overview_role.id, role_id: overview_role.id,
condition: { condition: {
'tickets.escalation_time' => { 'direction' => 'before', 'count'=> 5, 'area' => 'minute' }, 'tickets.escalation_time' => { 'direction' => 'before', 'count' => 5, 'area' => 'minute' },
}, },
order: { order: {
by: 'escalation_time', by: 'escalation_time',
@ -1532,7 +1532,7 @@ Overview.create_if_not_exists(
prio: 1000, prio: 1000,
role_id: overview_role.id, role_id: overview_role.id,
condition: { condition: {
'tickets.state_id' => [ 1,2,3,4,6 ], 'tickets.state_id' => [ 1, 2, 3, 4, 6 ],
'tickets.customer_id' => 'current_user.id', 'tickets.customer_id' => 'current_user.id',
}, },
order: { order: {
@ -1553,7 +1553,7 @@ Overview.create_if_not_exists(
role_id: overview_role.id, role_id: overview_role.id,
organization_shared: true, organization_shared: true,
condition: { condition: {
'tickets.state_id' => [ 1,2,3,4,6 ], 'tickets.state_id' => [ 1, 2, 3, 4, 6 ],
'tickets.organization_id' => 'current_user.organization_id', 'tickets.organization_id' => 'current_user.organization_id',
}, },
order: { order: {

View file

@ -2,8 +2,8 @@ class Class
def to_app_model_url def to_app_model_url
camel_cased_word = self.to_s camel_cased_word = self.to_s
camel_cased_word.gsub(/::/, '_'). camel_cased_word.gsub(/::/, '_').
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2'). gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2').
gsub(/([a-z\d])([A-Z])/,'\1_\2'). gsub(/([a-z\d])([A-Z])/, '\1_\2').
tr('-', '_'). tr('-', '_').
downcase downcase
end end

View file

@ -54,7 +54,7 @@ module FillDB
suffix = rand(99_999).to_s suffix = rand(99_999).to_s
organization = nil organization = nil
if !organization_pool.empty? && rand(2) == 1 if !organization_pool.empty? && rand(2) == 1
organization = organization_pool[ organization_pool.length-1 ] organization = organization_pool[ organization_pool.length - 1 ]
end end
user = User.create_or_update( user = User.create_or_update(
login: "filldb-customer-#{suffix}", login: "filldb-customer-#{suffix}",
@ -95,15 +95,15 @@ module FillDB
state_pool = Ticket::State.all state_pool = Ticket::State.all
if tickets && !tickets.zero? if tickets && !tickets.zero?
(1..tickets).each {|count| (1..tickets).each {|count|
customer = customer_pool[ rand(customer_pool.length-1) ] customer = customer_pool[ rand(customer_pool.length - 1) ]
agent = agent_pool[ rand(agent_pool.length-1) ] agent = agent_pool[ rand(agent_pool.length - 1) ]
ticket = Ticket.create( ticket = Ticket.create(
title: 'some title äöüß' + rand(999_999).to_s, title: 'some title äöüß' + rand(999_999).to_s,
group: group_pool[ rand(group_pool.length-1) ], group: group_pool[ rand(group_pool.length - 1) ],
customer: customer, customer: customer,
owner: agent, owner: agent,
state: state_pool[ rand(state_pool.length-1) ], state: state_pool[ rand(state_pool.length - 1) ],
priority: priority_pool[ rand(priority_pool.length-1) ], priority: priority_pool[ rand(priority_pool.length - 1) ],
updated_by_id: agent.id, updated_by_id: agent.id,
created_by_id: agent.id, created_by_id: agent.id,
) )

View file

@ -37,13 +37,13 @@ returns
=end =end
def self.reverse_geocode(lat,lng) def self.reverse_geocode(lat, lng)
# load backend # load backend
backend = self.load_adapter_by_setting( 'geo_location_backend' ) backend = self.load_adapter_by_setting( 'geo_location_backend' )
return if !backend return if !backend
# db lookup # db lookup
backend.reverse_geocode(lat,lng) backend.reverse_geocode(lat, lng)
end end
end end

View file

@ -15,10 +15,10 @@ class GeoLocation::Gmaps
lat = result['results'].first['geometry']['location']['lat'] lat = result['results'].first['geometry']['location']['lat']
lng = result['results'].first['geometry']['location']['lng'] lng = result['results'].first['geometry']['location']['lng']
latlng = [lat,lng] latlng = [lat, lng]
end end
def self.reverse_geocode(lat,lng) def self.reverse_geocode(lat, lng)
url = "http://maps.googleapis.com/maps/api/geocode/json?latlng=#{lat},#{lng}&sensor=true" url = "http://maps.googleapis.com/maps/api/geocode/json?latlng=#{lat},#{lng}&sensor=true"
response = UserAgent.get(url) response = UserAgent.get(url)
return if !response.success? return if !response.success?

View file

@ -67,7 +67,7 @@ module Import::OTRS
required_group_ro: 'groups_ro', required_group_ro: 'groups_ro',
required_group_rw: 'groups_rw', required_group_rw: 'groups_rw',
} }
types.each {|config_key,result_key| types.each {|config_key, result_key|
if config[config_key] if config[config_key]
return false if !result[result_key].has_value?( config[config_key] ) return false if !result[result_key].has_value?( config[config_key] )
end end
@ -82,7 +82,7 @@ module Import::OTRS
group_ro_role_map: 'groups_ro', group_ro_role_map: 'groups_ro',
group_rw_role_map: 'groups_rw', group_rw_role_map: 'groups_rw',
} }
types.each {|config_key,result_key| types.each {|config_key, result_key|
next if !config[config_key] next if !config[config_key]
config[config_key].each {|otrs_group, role| config[config_key].each {|otrs_group, role|
next if !result[result_key].has_value?( otrs_group ) next if !result[result_key].has_value?( otrs_group )
@ -278,7 +278,7 @@ module Import::OTRS
created_by_id: 1, created_by_id: 1,
updated_by_id: 1, updated_by_id: 1,
} }
map[:Ticket].each { |key,value| map[:Ticket].each { |key, value|
if record['Ticket'][key.to_s] && record['Ticket'][key.to_s].class == String if record['Ticket'][key.to_s] && record['Ticket'][key.to_s].class == String
ticket_new[value] = Encode.conv( 'utf8', record['Ticket'][key.to_s] ) ticket_new[value] = Encode.conv( 'utf8', record['Ticket'][key.to_s] )
else else
@ -331,7 +331,7 @@ module Import::OTRS
created_by_id: 1, created_by_id: 1,
updated_by_id: 1, updated_by_id: 1,
} }
map[:Article].each { |key,value| map[:Article].each { |key, value|
if article[key.to_s] if article[key.to_s]
article_new[value] = Encode.conv( 'utf8', article[key.to_s] ) article_new[value] = Encode.conv( 'utf8', article[key.to_s] )
end end
@ -572,7 +572,7 @@ module Import::OTRS
created_by_id: 1, created_by_id: 1,
updated_by_id: 1, updated_by_id: 1,
} }
map.each { |key,value| map.each { |key, value|
if state[key.to_s] if state[key.to_s]
state_new[value] = state[key.to_s] state_new[value] = state[key.to_s]
end end
@ -623,7 +623,7 @@ module Import::OTRS
created_by_id: 1, created_by_id: 1,
updated_by_id: 1, updated_by_id: 1,
} }
map.each { |key,value| map.each { |key, value|
if priority[key.to_s] if priority[key.to_s]
priority_new[value] = priority[key.to_s] priority_new[value] = priority[key.to_s]
end end
@ -667,7 +667,7 @@ module Import::OTRS
created_by_id: 1, created_by_id: 1,
updated_by_id: 1, updated_by_id: 1,
} }
map.each { |key,value| map.each { |key, value|
if group[key.to_s] if group[key.to_s]
group_new[value] = group[key.to_s] group_new[value] = group[key.to_s]
end end
@ -719,7 +719,7 @@ module Import::OTRS
source: 'OTRS Import', source: 'OTRS Import',
role_ids: [ role.id ], role_ids: [ role.id ],
} }
map.each { |key,value| map.each { |key, value|
if user[key.to_s] if user[key.to_s]
user_new[value] = user[key.to_s] user_new[value] = user[key.to_s]
end end
@ -793,7 +793,7 @@ module Import::OTRS
source: 'OTRS Import', source: 'OTRS Import',
role_ids: [role.id], role_ids: [role.id],
} }
map.each { |key,value| map.each { |key, value|
if user[key.to_s] if user[key.to_s]
user_new[value] = user[key.to_s] user_new[value] = user[key.to_s]
end end

View file

@ -347,7 +347,7 @@ module Import::OTRS2
run = true run = true
while run while run
count += steps count += steps
records = load('CustomerUser', steps, count-steps) records = load('CustomerUser', steps, count - steps)
if !records || !records[0] if !records || !records[0]
log 'all customers imported.' log 'all customers imported.'
run = false run = false
@ -371,11 +371,11 @@ module Import::OTRS2
while run while run
count += steps count += steps
log "loading... thread# #{thread} ..." log "loading... thread# #{thread} ..."
offset = count-steps offset = count - steps
if offset != 0 if offset != 0
offset = count - steps + 1 offset = count - steps + 1
end end
records = load( 'Ticket', steps, count-steps) records = load( 'Ticket', steps, count - steps)
if !records || !records[0] if !records || !records[0]
log "... thread# #{thread}, no more work." log "... thread# #{thread}, no more work."
run = false run = false
@ -450,11 +450,11 @@ module Import::OTRS2
while run while run
count += steps count += steps
log 'loading... diff ...' log 'loading... diff ...'
offset = count-steps offset = count - steps
if offset != 0 if offset != 0
offset = count - steps + 1 offset = count - steps + 1
end end
records = load( 'Ticket', steps, count-steps, 1 ) records = load( 'Ticket', steps, count - steps, 1 )
if !records || !records[0] if !records || !records[0]
log '... no more work.' log '... no more work.'
run = false run = false
@ -520,7 +520,7 @@ module Import::OTRS2
created_by_id: 1, created_by_id: 1,
updated_by_id: 1, updated_by_id: 1,
} }
map[:Ticket].each { |key,value| map[:Ticket].each { |key, value|
if record[key.to_s] && record[key.to_s].class == String if record[key.to_s] && record[key.to_s].class == String
ticket_new[value] = Encode.conv( 'utf8', record[key.to_s] ) ticket_new[value] = Encode.conv( 'utf8', record[key.to_s] )
else else
@ -571,7 +571,7 @@ module Import::OTRS2
created_by_id: 1, created_by_id: 1,
updated_by_id: 1, updated_by_id: 1,
} }
map[:Article].each { |key,value| map[:Article].each { |key, value|
if article[key.to_s] if article[key.to_s]
article_new[value] = Encode.conv( 'utf8', article[key.to_s] ) article_new[value] = Encode.conv( 'utf8', article[key.to_s] )
end end
@ -820,7 +820,7 @@ module Import::OTRS2
created_by_id: 1, created_by_id: 1,
updated_by_id: 1, updated_by_id: 1,
} }
map.each { |key,value| map.each { |key, value|
if state.has_key?(key.to_s) if state.has_key?(key.to_s)
state_new[value] = state[key.to_s] state_new[value] = state[key.to_s]
end end
@ -869,7 +869,7 @@ module Import::OTRS2
created_by_id: 1, created_by_id: 1,
updated_by_id: 1, updated_by_id: 1,
} }
map.each { |key,value| map.each { |key, value|
if priority.has_key?(key.to_s) if priority.has_key?(key.to_s)
priority_new[value] = priority[key.to_s] priority_new[value] = priority[key.to_s]
end end
@ -910,7 +910,7 @@ module Import::OTRS2
created_by_id: 1, created_by_id: 1,
updated_by_id: 1, updated_by_id: 1,
} }
map.each { |key,value| map.each { |key, value|
if group.has_key?(key.to_s) if group.has_key?(key.to_s)
group_new[value] = group[key.to_s] group_new[value] = group[key.to_s]
end end
@ -966,7 +966,7 @@ module Import::OTRS2
role_ids: role_ids, role_ids: role_ids,
group_ids: group_ids, group_ids: group_ids,
} }
map.each { |key,value| map.each { |key, value|
if user.has_key?(key.to_s) if user.has_key?(key.to_s)
user_new[value] = user[key.to_s] user_new[value] = user[key.to_s]
end end
@ -1037,7 +1037,7 @@ module Import::OTRS2
if group_lookup['Name'] == 'admin' && permissions && permissions.include?('rw') if group_lookup['Name'] == 'admin' && permissions && permissions.include?('rw')
roles.push 'Admin' roles.push 'Admin'
end end
if group_lookup['Name'] =~ /^(stats|report)/ && permissions && ( permissions.include?('ro') || permissions.include?('rw') ) if group_lookup['Name'] =~ /^(stats|report)/ && permissions && ( permissions.include?('ro') ||  permissions.include?('rw') )
roles.push 'Report' roles.push 'Report'
end end
end end
@ -1091,7 +1091,7 @@ module Import::OTRS2
organization_id: get_organization_id(user, organizations), organization_id: get_organization_id(user, organizations),
role_ids: [ role_customer.id ], role_ids: [ role_customer.id ],
} }
map.each { |key,value| map.each { |key, value|
if user.has_key?(key.to_s) if user.has_key?(key.to_s)
user_new[value] = user[key.to_s] user_new[value] = user[key.to_s]
end end
@ -1155,7 +1155,7 @@ module Import::OTRS2
created_by_id: 1, created_by_id: 1,
updated_by_id: 1, updated_by_id: 1,
} }
map.each { |key,value| map.each { |key, value|
if organization.has_key?(key.to_s) if organization.has_key?(key.to_s)
organization_new[value] = organization[key.to_s] organization_new[value] = organization[key.to_s]
end end

View file

@ -42,10 +42,13 @@ returns
# send update to browser # send update to browser
if session && session['id'] if session && session['id']
self.send( client_id, { self.send(
client_id,
{
event: 'ws:login', event: 'ws:login',
data: { success: true }, data: { success: true },
}) }
)
end end
end end
@ -395,7 +398,7 @@ returns
path = @path + '/spool/' path = @path + '/spool/'
FileUtils.mkpath path FileUtils.mkpath path
file = Time.new.to_f.to_s + '-' + rand(99_999).to_s file = Time.new.to_f.to_s + '-' + rand(99_999).to_s
File.open( path + '/' + file , 'wb' ) { |file| File.open( path + '/' + file, 'wb' ) { |file|
data = { data = {
msg: msg, msg: msg,
timestamp: Time.now.to_i, timestamp: Time.now.to_i,

View file

@ -43,7 +43,7 @@ class Sessions::Backend::ActivityStream
data = self.load data = self.load
return if !data||data.empty? return if !data || data.empty?
if !@client if !@client
return { return {
@ -54,11 +54,11 @@ class Sessions::Backend::ActivityStream
end end
@client.log 'notify', "push activity_stream #{ data.first.class.to_s } for user #{ @user.id }" @client.log 'notify', "push activity_stream #{ data.first.class.to_s } for user #{ @user.id }"
@client.send({ @client.send(
event: 'activity_stream_rebuild', event: 'activity_stream_rebuild',
collection: 'activity_stream', collection: 'activity_stream',
data: data, data: data,
}) )
end end
end end

View file

@ -52,7 +52,7 @@ class Sessions::Backend::Collections::Base
# load current data # load current data
items = self.load items = self.load
return if !items||items.empty? return if !items || items.empty?
# get relations of data # get relations of data
all = [] all = []
@ -74,18 +74,18 @@ class Sessions::Backend::Collections::Base
} }
end end
@client.log 'notify', "push assets for push_collection #{ items.first.class.to_s } for user #{ @user.id }" @client.log 'notify', "push assets for push_collection #{ items.first.class.to_s } for user #{ @user.id }"
@client.send({ @client.send(
data: assets, data: assets,
event: [ 'loadAssets' ], event: [ 'loadAssets' ],
}) )
@client.log 'notify', "push push_collection #{ items.first.class.to_s } for user #{ @user.id }" @client.log 'notify', "push push_collection #{ items.first.class.to_s } for user #{ @user.id }"
@client.send({ @client.send(
event: 'resetCollection', event: 'resetCollection',
data: { data: {
items.first.class.to_app_model => all, items.first.class.to_app_model => all,
}, },
}) )
end end
def self.model_set(model) def self.model_set(model)

View file

@ -43,7 +43,7 @@ class Sessions::Backend::Rss
data = self.load data = self.load
return if !data||data.empty? return if !data || data.empty?
if !@client if !@client
return { return {
@ -54,11 +54,11 @@ class Sessions::Backend::Rss
end end
@client.log 'notify', "push rss for user #{@user.id}" @client.log 'notify', "push rss for user #{@user.id}"
@client.send({ @client.send(
event: 'rss_rebuild', event: 'rss_rebuild',
collection: 'dashboard_rss', collection: 'dashboard_rss',
data: data, data: data,
}) )
end end
end end

View file

@ -59,10 +59,10 @@ class Sessions::Backend::TicketCreate
end end
@client.log 'notify', "push ticket_create for user #{ @user.id }" @client.log 'notify', "push ticket_create for user #{ @user.id }"
@client.send({ @client.send(
collection: 'ticket_create_attributes', collection: 'ticket_create_attributes',
data: data, data: data,
}) )
end end
end end

View file

@ -57,10 +57,10 @@ class Sessions::Backend::TicketOverviewIndex
end end
@client.log 'notify', "push overview_index for user #{ @user.id }" @client.log 'notify', "push overview_index for user #{ @user.id }"
@client.send({ @client.send(
event: ['ticket_overview_index'], event: ['ticket_overview_index'],
data: data, data: data,
}) )
end end
end end

View file

@ -106,11 +106,11 @@ class Sessions::Backend::TicketOverviewList
@client.log 'notify', "push overview_list for user #{ @user.id }" @client.log 'notify', "push overview_list for user #{ @user.id }"
# send update to browser # send update to browser
@client.send({ @client.send(
data: assets, data: assets,
event: [ 'loadAssets' ] event: [ 'loadAssets' ]
}) )
@client.send({ @client.send(
data: { data: {
view: item[:index].link.to_s, view: item[:index].link.to_s,
overview: overview_data[:overview], overview: overview_data[:overview],
@ -122,7 +122,7 @@ class Sessions::Backend::TicketOverviewList
}, },
}, },
event: [ 'ticket_overview_rebuild' ], event: [ 'ticket_overview_rebuild' ],
}) )
end end
} }
return results if !@client return results if !@client

View file

@ -7,7 +7,7 @@ module StaticAssets
data[:content] = Base64.decode64($2) data[:content] = Base64.decode64($2)
return data return data
end end
raise "Unable to parse data url: #{data_url.substr(0,100)}" raise "Unable to parse data url: #{data_url.substr(0, 100)}"
end end
# store image 1:1 # store image 1:1

View file

@ -197,7 +197,7 @@ put working hours matrix and timezone in function, returns UTC working hours mat
# keep it in current day # keep it in current day
if next_hour == 23 if next_hour == 23
start_time += diff-1 start_time += diff - 1
else else
start_time += diff start_time += diff
end end
@ -334,7 +334,7 @@ put working hours matrix and timezone in function, returns UTC working hours mat
# keep it in current day # keep it in current day
if next_hour == 23 if next_hour == 23
start_time += diff-1 start_time += diff - 1
else else
start_time += diff start_time += diff
end end

View file

@ -45,7 +45,7 @@ returns
http = get_http(uri, options) http = get_http(uri, options)
# prepare request # prepare request
request = Net::HTTP::Get.new( uri, {'User-Agent' => 'Zammad User Agent'} ) request = Net::HTTP::Get.new( uri, { 'User-Agent' => 'Zammad User Agent' } )
# http basic auth (if needed) # http basic auth (if needed)
request = set_basic_auth(request, options) request = set_basic_auth(request, options)
@ -93,7 +93,7 @@ returns
http = get_http(uri, options) http = get_http(uri, options)
# prepare request # prepare request
request = Net::HTTP::Post.new( uri, {'User-Agent' => 'Zammad User Agent'} ) request = Net::HTTP::Post.new( uri, { 'User-Agent' => 'Zammad User Agent' } )
# set params # set params
request = set_params(request, params, options) request = set_params(request, params, options)
@ -141,7 +141,7 @@ returns
http = get_http(uri, options) http = get_http(uri, options)
# prepare request # prepare request
request = Net::HTTP::Put.new( uri, {'User-Agent' => 'Zammad User Agent'} ) request = Net::HTTP::Put.new( uri, { 'User-Agent' => 'Zammad User Agent' } )
# set params # set params
request = set_params(request, params, options) request = set_params(request, params, options)
@ -185,7 +185,7 @@ returns
http = get_http(uri, options) http = get_http(uri, options)
# prepare request # prepare request
request = Net::HTTP::Delete.new( uri, {'User-Agent' => 'Zammad User Agent'} ) request = Net::HTTP::Delete.new( uri, { 'User-Agent' => 'Zammad User Agent' } )
# http basic auth (if needed) # http basic auth (if needed)
request = set_basic_auth(request, options) request = set_basic_auth(request, options)
@ -340,7 +340,7 @@ returns
raise "Unable to process http call '#{response.inspect}'" raise "Unable to process http call '#{response.inspect}'"
end end
def self.ftp(uri,options) def self.ftp(uri, options)
host = uri.host host = uri.host
filename = File.basename(uri.path) filename = File.basename(uri.path)
remote_dir = File.dirname(uri.path) remote_dir = File.dirname(uri.path)

View file

@ -22,7 +22,7 @@ def checkForHeader(fileName)
# detect file type # detect file type
if allLines[0] =~ /(^# Copyright)/ || allLines[1] =~ /(^# Copyright)/ if allLines[0] =~ /(^# Copyright)/ || allLines[1] =~ /(^# Copyright)/
foundHeader = true foundHeader = true
elsif allLines[1] =~/^=begin/ #assume external script elsif allLines[1] =~ /^=begin/ #assume external script
foundHeader = true foundHeader = true
end end
if allLines[0] =~ /(^#!\/)/ if allLines[0] =~ /(^#!\/)/
@ -67,7 +67,7 @@ def checkForHeader(fileName)
end end
#folder array #folder array
folder = ['app/assets/javascripts/app','app/controllers/', 'app/models/', 'app/helpers/', 'app/mailers/' ] folder = ['app/assets/javascripts/app', 'app/controllers/', 'app/models/', 'app/helpers/', 'app/mailers/' ]
folder.each do |folder| folder.each do |folder|
puts 'Working on folder' + folder.to_s puts 'Working on folder' + folder.to_s
rbfiles = File.join("../#{folder}**", '*.{rb,coffee}') rbfiles = File.join("../#{folder}**", '*.{rb,coffee}')

View file

@ -64,7 +64,7 @@ puts "Starting websocket server on #{ @options[:b] }:#{ @options[:p] } (secure:#
if ARGV[0] == 'stop' if ARGV[0] == 'stop'
# read pid # read pid
pid =File.open( @options[:i].to_s ).read pid = File.open( @options[:i].to_s ).read
pid.gsub!(/\r|\n/, '') pid.gsub!(/\r|\n/, '')
# kill # kill
@ -76,7 +76,7 @@ if ARGV[0] == 'start' && @options[:d]
Daemons.daemonize Daemons.daemonize
# create pid file # create pid file
$daemon_pid = File.new( @options[:i].to_s,'w' ) $daemon_pid = File.new( @options[:i].to_s, 'w' )
$daemon_pid.sync = true $daemon_pid.sync = true
$daemon_pid.puts(Process.pid.to_s) $daemon_pid.puts(Process.pid.to_s)
$daemon_pid.close $daemon_pid.close

View file

@ -625,7 +625,7 @@ class TestCase < Test::Unit::TestCase
raise "not matching '#{data[:title]}' in title '#{title}'" raise "not matching '#{data[:title]}' in title '#{title}'"
end end
end end
puts "tv #{params.inspect}" puts "tv #{params.inspect}"
# verify modified # verify modified
if data.has_key?(:modified) if data.has_key?(:modified)
exists = instance.find_elements( { css: '.tasks .active .icon' } )[0] exists = instance.find_elements( { css: '.tasks .active .icon' } )[0]

View file

@ -73,7 +73,7 @@ class TwitterTest < ActiveSupport::TestCase
ticket = Ticket.create( ticket = Ticket.create(
group_id: group.id, group_id: group.id,
customer_id: user.id, customer_id: user.id,
title: text[0,40], title: text[0, 40],
state_id: state.id, state_id: state.id,
priority_id: priority.id, priority_id: priority.id,
updated_by_id: 1, updated_by_id: 1,

View file

@ -2153,7 +2153,7 @@ Some Text',
assert( false, "No user '#{user_result[:email]}' found!" ) assert( false, "No user '#{user_result[:email]}' found!" )
return return
end end
user_result.each { |key,value| user_result.each { |key, value|
if user.respond_to?( key ) if user.respond_to?( key )
assert_equal( value, user.send(key), "user check #{ key }" ) assert_equal( value, user.send(key), "user check #{ key }" )
else else

View file

@ -3,7 +3,7 @@ require 'test_helper'
class SessionBasicTest < ActiveSupport::TestCase class SessionBasicTest < ActiveSupport::TestCase
test 'a cache' do test 'a cache' do
Sessions::CacheIn.set( 'last_run_test' , true, { expires_in: 2.seconds } ) Sessions::CacheIn.set( 'last_run_test', true, { expires_in: 2.seconds } )
result = Sessions::CacheIn.get( 'last_run_test' ) result = Sessions::CacheIn.get( 'last_run_test' )
assert_equal( true, result, 'check 1' ) assert_equal( true, result, 'check 1' )
@ -37,7 +37,7 @@ class SessionBasicTest < ActiveSupport::TestCase
assert_equal( nil, result, 'check 2' ) assert_equal( nil, result, 'check 2' )
# check delete cache # check delete cache
Sessions::CacheIn.set( 'last_run_delete' , true, { expires_in: 5.seconds } ) Sessions::CacheIn.set( 'last_run_delete', true, { expires_in: 5.seconds } )
result = Sessions::CacheIn.get( 'last_run_delete' ) result = Sessions::CacheIn.get( 'last_run_delete' )
assert_equal( true, result, 'check 1' ) assert_equal( true, result, 'check 1' )
Sessions::CacheIn.delete( 'last_run_delete' ) Sessions::CacheIn.delete( 'last_run_delete' )

View file

@ -116,7 +116,7 @@ class SessionEnhancedTest < ActiveSupport::TestCase
assert_equal( true, messages[0]['data']['success'], 'messages 1') assert_equal( true, messages[0]['data']['success'], 'messages 1')
# broadcast to all clients # broadcast to all clients
Sessions.broadcast( { msg: 'ooo123123123123123123'} ) Sessions.broadcast( { msg: 'ooo123123123123123123' } )
messages = Sessions.queue(client_id1) messages = Sessions.queue(client_id1)
assert_equal( messages.count, 1, 'messages count') assert_equal( messages.count, 1, 'messages count')
assert_equal( 'ooo123123123123123123', messages[0]['msg'], 'messages broadcast 1') assert_equal( 'ooo123123123123123123', messages[0]['msg'], 'messages broadcast 1')
@ -130,7 +130,7 @@ class SessionEnhancedTest < ActiveSupport::TestCase
assert_equal( 'ooo123123123123123123', messages[0]['msg'], 'messages broadcast 1') assert_equal( 'ooo123123123123123123', messages[0]['msg'], 'messages broadcast 1')
# send dedicated message to user # send dedicated message to user
Sessions.send_to( agent1.id, { msg: 'ooo1231231231231231234'} ) Sessions.send_to( agent1.id, { msg: 'ooo1231231231231231234' } )
messages = Sessions.queue(client_id1) messages = Sessions.queue(client_id1)
assert_equal( messages.count, 1, 'messages count') assert_equal( messages.count, 1, 'messages count')
assert_equal( 'ooo1231231231231231234', messages[0]['msg'], 'messages send 1') assert_equal( 'ooo1231231231231231234', messages[0]['msg'], 'messages send 1')

View file

@ -407,7 +407,7 @@ class TicketNotificationTest < ActiveSupport::TestCase
) )
# check changed attributes # check changed attributes
human_changes = bg.human_changes(agent1,ticket1) human_changes = bg.human_changes(agent1, ticket1)
assert( human_changes['Priority'], 'Check if attributes translated based on ObjectManager::Attribute' ) assert( human_changes['Priority'], 'Check if attributes translated based on ObjectManager::Attribute' )
assert( human_changes['Pending till'], 'Check if attributes translated based on ObjectManager::Attribute' ) assert( human_changes['Pending till'], 'Check if attributes translated based on ObjectManager::Attribute' )
assert_equal( 'i18n(1 low)', human_changes['Priority'][0] ) assert_equal( 'i18n(1 low)', human_changes['Priority'][0] )
@ -511,7 +511,7 @@ class TicketNotificationTest < ActiveSupport::TestCase
puts "hc #{human_changes.inspect}" puts "hc #{human_changes.inspect}"
# check changed attributes # check changed attributes
human_changes = bg.human_changes(agent1,ticket1) human_changes = bg.human_changes(agent1, ticket1)
assert( human_changes['Title'], 'Check if attributes translated based on ObjectManager::Attribute' ) assert( human_changes['Title'], 'Check if attributes translated based on ObjectManager::Attribute' )
assert( human_changes['Priority'], 'Check if attributes translated based on ObjectManager::Attribute' ) assert( human_changes['Priority'], 'Check if attributes translated based on ObjectManager::Attribute' )
assert_equal( 'i18n(2 normal)', human_changes['Priority'][0] ) assert_equal( 'i18n(2 normal)', human_changes['Priority'][0] )
@ -522,7 +522,7 @@ class TicketNotificationTest < ActiveSupport::TestCase
assert_not( human_changes['pending_time'] ) assert_not( human_changes['pending_time'] )
assert_not( human_changes['pending_till'] ) assert_not( human_changes['pending_till'] )
human_changes = bg.human_changes(agent2,ticket1) human_changes = bg.human_changes(agent2, ticket1)
puts "hc2 #{human_changes.inspect}" puts "hc2 #{human_changes.inspect}"
template = bg.template_update(agent1, ticket1, article, human_changes) template = bg.template_update(agent1, ticket1, article, human_changes)

View file

@ -28,7 +28,7 @@ class TicketSlaTest < ActiveSupport::TestCase
name: 'test sla 1', name: 'test sla 1',
condition: {}, condition: {},
data: { data: {
'Mon'=>'Mon', 'Tue'=>'Tue', 'Wed'=>'Wed', 'Thu'=>'Thu', 'Fri'=>'Fri', 'Sat'=>'Sat', 'Sun'=>'Sun', 'Mon' => 'Mon', 'Tue' => 'Tue', 'Wed' => 'Wed', 'Thu' => 'Thu', 'Fri' => 'Fri', 'Sat' => 'Sat', 'Sun' => 'Sun',
'beginning_of_workday' => '8:00', 'beginning_of_workday' => '8:00',
'end_of_workday' => '18:00', 'end_of_workday' => '18:00',
}, },
@ -49,9 +49,9 @@ class TicketSlaTest < ActiveSupport::TestCase
sla = Sla.create( sla = Sla.create(
name: 'test sla 2', name: 'test sla 2',
condition: { 'tickets.priority_id' =>['1', '2', '3'] }, condition: { 'tickets.priority_id' => ['1', '2', '3'] },
data: { data: {
'Mon'=>'Mon', 'Tue'=>'Tue', 'Wed'=>'Wed', 'Thu'=>'Thu', 'Fri'=>'Fri', 'Sat'=>'Sat', 'Sun'=>'Sun', 'Mon' => 'Mon', 'Tue' => 'Tue', 'Wed' => 'Wed', 'Thu' => 'Thu', 'Fri' => 'Fri', 'Sat' => 'Sat', 'Sun' => 'Sun',
'beginning_of_workday' => '8:00', 'beginning_of_workday' => '8:00',
'end_of_workday' => '18:00', 'end_of_workday' => '18:00',
}, },
@ -360,7 +360,7 @@ class TicketSlaTest < ActiveSupport::TestCase
name: 'test sla 1', name: 'test sla 1',
condition: {}, condition: {},
data: { data: {
'Mon'=>'Mon', 'Tue'=>'Tue', 'Wed'=>'Wed', 'Thu'=>'Thu', 'Fri'=>'Fri', 'Sat'=>'Sat', 'Sun'=>'Sun', 'Mon' => 'Mon', 'Tue' => 'Tue', 'Wed' => 'Wed', 'Thu' => 'Thu', 'Fri' => 'Fri', 'Sat' => 'Sat', 'Sun' => 'Sun',
'beginning_of_workday' => '9:00', 'beginning_of_workday' => '9:00',
'end_of_workday' => '18:00', 'end_of_workday' => '18:00',
}, },
@ -402,7 +402,7 @@ class TicketSlaTest < ActiveSupport::TestCase
name: 'test sla 1', name: 'test sla 1',
condition: {}, condition: {},
data: { data: {
'Mon'=>'Mon', 'Tue'=>'Tue', 'Wed'=>'Wed', 'Thu'=>'Thu', 'Fri'=>'Fri', 'Sat'=>'Sat', 'Sun'=>'Sun', 'Mon' => 'Mon', 'Tue' => 'Tue', 'Wed' => 'Wed', 'Thu' => 'Thu', 'Fri' => 'Fri', 'Sat' => 'Sat', 'Sun' => 'Sun',
'beginning_of_workday' => '9:00', 'beginning_of_workday' => '9:00',
'end_of_workday' => '18:00', 'end_of_workday' => '18:00',
}, },
@ -445,7 +445,7 @@ class TicketSlaTest < ActiveSupport::TestCase
name: 'test sla 1', name: 'test sla 1',
condition: {}, condition: {},
data: { data: {
'Mon'=>'Mon', 'Tue'=>'Tue', 'Wed'=>'Wed', 'Thu'=>'Thu', 'Fri'=>'Fri', 'Sat'=>'Sat', 'Sun'=>'Sun', 'Mon' => 'Mon', 'Tue' => 'Tue', 'Wed' => 'Wed', 'Thu' => 'Thu', 'Fri' => 'Fri', 'Sat' => 'Sat', 'Sun' => 'Sun',
'beginning_of_workday' => '9:00', 'beginning_of_workday' => '9:00',
'end_of_workday' => '18:00', 'end_of_workday' => '18:00',
}, },
@ -549,7 +549,7 @@ class TicketSlaTest < ActiveSupport::TestCase
name: 'test sla 1', name: 'test sla 1',
condition: {}, condition: {},
data: { data: {
'Mon'=>'Mon', 'Tue'=>'Tue', 'Wed'=>'Wed', 'Thu'=>'Thu', 'Fri'=>'Fri', 'Sat'=>'Sat', 'Sun'=>'Sun', 'Mon' => 'Mon', 'Tue' => 'Tue', 'Wed' => 'Wed', 'Thu' => 'Thu', 'Fri' => 'Fri', 'Sat' => 'Sat', 'Sun' => 'Sun',
'beginning_of_workday' => '9:00', 'beginning_of_workday' => '9:00',
'end_of_workday' => '18:00', 'end_of_workday' => '18:00',
}, },
@ -612,7 +612,7 @@ class TicketSlaTest < ActiveSupport::TestCase
name: 'test sla 1', name: 'test sla 1',
condition: {}, condition: {},
data: { data: {
'Mon'=>'Mon', 'Tue'=>'Tue', 'Wed'=>'Wed', 'Thu'=>'Thu', 'Fri'=>'Fri', 'Sat'=>'Sat', 'Sun'=>'Sun', 'Mon' => 'Mon', 'Tue' => 'Tue', 'Wed' => 'Wed', 'Thu' => 'Thu', 'Fri' => 'Fri', 'Sat' => 'Sat', 'Sun' => 'Sun',
'beginning_of_workday' => '9:00', 'beginning_of_workday' => '9:00',
'end_of_workday' => '18:00', 'end_of_workday' => '18:00',
}, },
@ -706,7 +706,7 @@ class TicketSlaTest < ActiveSupport::TestCase
name: 'test sla 1', name: 'test sla 1',
condition: {}, condition: {},
data: { data: {
'Mon'=>'Mon', 'Tue'=>'Tue', 'Wed'=>'Wed', 'Thu'=>'Thu', 'Fri'=>'Fri', 'Sat'=>'Sat', 'Sun'=>'Sun', 'Mon' => 'Mon', 'Tue' => 'Tue', 'Wed' => 'Wed', 'Thu' => 'Thu', 'Fri' => 'Fri', 'Sat' => 'Sat', 'Sun' => 'Sun',
'beginning_of_workday' => '9:00', 'beginning_of_workday' => '9:00',
'end_of_workday' => '18:00', 'end_of_workday' => '18:00',
}, },
@ -816,7 +816,7 @@ class TicketSlaTest < ActiveSupport::TestCase
name: 'test sla 1', name: 'test sla 1',
condition: {}, condition: {},
data: { data: {
'Mon'=>'Mon', 'Tue'=>'Tue', 'Wed'=>'Wed', 'Thu'=>'Thu', 'Fri'=>'Fri', 'Sat'=>'Sat', 'Sun'=>'Sun', 'Mon' => 'Mon', 'Tue' => 'Tue', 'Wed' => 'Wed', 'Thu' => 'Thu', 'Fri' => 'Fri', 'Sat' => 'Sat', 'Sun' => 'Sun',
'beginning_of_workday' => '9:00', 'beginning_of_workday' => '9:00',
'end_of_workday' => '18:00', 'end_of_workday' => '18:00',
}, },