diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 535cc0503..9022ec280 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -267,7 +267,7 @@ class ApplicationController < ActionController::Base next if t.name =~ /^MST/ next if t.name =~ /^ROC/ 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 } diff --git a/app/controllers/getting_started_controller.rb b/app/controllers/getting_started_controller.rb index 3f0f24079..e1b840b97 100644 --- a/app/controllers/getting_started_controller.rb +++ b/app/controllers/getting_started_controller.rb @@ -76,7 +76,7 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password} # validate url messages = {} 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' end end diff --git a/app/controllers/import_otrs_controller.rb b/app/controllers/import_otrs_controller.rb index ae38a2395..0e0d49091 100644 --- a/app/controllers/import_otrs_controller.rb +++ b/app/controllers/import_otrs_controller.rb @@ -6,7 +6,7 @@ class ImportOtrsController < ApplicationController return if setup_done_response # validate - if !params[:url] ||params[:url] !~ /^(http|https):\/\/.+?$/ + if !params[:url] || params[:url] !~ /^(http|https):\/\/.+?$/ render json: { result: 'invalid', message: 'Invalid!', @@ -64,7 +64,7 @@ class ImportOtrsController < ApplicationController # return result render json: { - result: 'invalid', + result: 'invalid', message_human: message_human, } end diff --git a/app/controllers/online_notifications_controller.rb b/app/controllers/online_notifications_controller.rb index dad949b83..f3e4b273a 100644 --- a/app/controllers/online_notifications_controller.rb +++ b/app/controllers/online_notifications_controller.rb @@ -105,13 +105,13 @@ curl http://localhost/api/v1/online_notifications/mark_all_as_read -v -u #{login =end def mark_all_as_read - notifications = OnlineNotification.list(current_user,100) + notifications = OnlineNotification.list(current_user, 100) notifications.each do |notification| if !notification['seen'] OnlineNotification.seen( id: notification['id'] ) end end - render json: {}, status: :ok + render json: {}, status: :ok end end diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 1332bfa41..e8c66fddb 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -127,7 +127,7 @@ class SessionsController < ApplicationController request.env['rack.session.options'][:expire_after] = -1.year request.env['rack.session.options'][:renew] = true - render json: { } + render json: {} end def create_omniauth diff --git a/app/controllers/taskbar_controller.rb b/app/controllers/taskbar_controller.rb index 378907aaf..49da083c7 100644 --- a/app/controllers/taskbar_controller.rb +++ b/app/controllers/taskbar_controller.rb @@ -18,7 +18,7 @@ class TaskbarController < ApplicationController end def create - model_create_render(Taskbar,params) + model_create_render(Taskbar, params) end def update diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 195a2e08f..463786880 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -283,7 +283,7 @@ class UsersController < ApplicationController user_all.each { |user| realname = user.firstname.to_s + ' ' + user.lastname.to_s if user.email && user.email.to_s != '' - realname = realname + ' <' + user.email.to_s + '>' + realname = realname + ' <' + user.email.to_s + '>' end a = { id: user.id, label: realname, value: realname } users.push a diff --git a/app/models/activity_stream.rb b/app/models/activity_stream.rb index 45f2d17c5..9b2a551e0 100644 --- a/app/models/activity_stream.rb +++ b/app/models/activity_stream.rb @@ -89,7 +89,7 @@ return all activity entries of an user =end - def self.list(user,limit) + def self.list(user, limit) role_ids = user.role_ids group_ids = user.group_ids diff --git a/app/models/application_model.rb b/app/models/application_model.rb index 952cd2d1f..54e68f8a0 100644 --- a/app/models/application_model.rb +++ b/app/models/application_model.rb @@ -108,7 +108,7 @@ returns # set relations 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 ) list_of_items = params[ real_key.to_sym ] if params[ real_key.to_sym ].class != Array @@ -141,7 +141,7 @@ returns # set relations attributes = self.attributes 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 ) attributes[ real_key ] = self.send( real_key ) end @@ -872,13 +872,13 @@ log object update history with all updated attributes, if configured - will be e # get attribute name attribute_name = key.to_s - if attribute_name[-3,3] == '_id' - attribute_name = attribute_name[ 0, attribute_name.length-3 ] + if attribute_name[-3, 3] == '_id' + attribute_name = attribute_name[ 0, attribute_name.length - 3 ] end value_id = [] 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[1] = value[1] diff --git a/app/models/application_model/search_index_base.rb b/app/models/application_model/search_index_base.rb index dfc7854f6..c5ad7fb81 100644 --- a/app/models/application_model/search_index_base.rb +++ b/app/models/application_model/search_index_base.rb @@ -112,8 +112,8 @@ returns # get attribute name attribute_name_with_id = key.to_s attribute_name = key.to_s - next if attribute_name[-3,3] != '_id' - attribute_name = attribute_name[ 0, attribute_name.length-3 ] + next if attribute_name[-3, 3] != '_id' + attribute_name = attribute_name[ 0, attribute_name.length - 3 ] # check if attribute method exists next if !ref_object.respond_to?( attribute_name ) diff --git a/app/models/authorization.rb b/app/models/authorization.rb index 31c9345d5..95bcfde84 100644 --- a/app/models/authorization.rb +++ b/app/models/authorization.rb @@ -87,8 +87,8 @@ class Authorization < ApplicationModel private - def delete_user_cache - self.user.cache_delete - end + def delete_user_cache + self.user.cache_delete + end end diff --git a/app/models/avatar.rb b/app/models/avatar.rb index 7ddaf6111..4e8d8cb96 100644 --- a/app/models/avatar.rb +++ b/app/models/avatar.rb @@ -340,35 +340,35 @@ returns: private - def self.set_default_items(object_id, o_id, avatar_id) - avatars = Avatar.where( - object_lookup_id: object_id, - o_id: o_id, - ).order( 'created_at ASC, id DESC' ) - avatars.each do |avatar| - next if avatar.id == avatar_id - avatar.default = false - avatar.save! - end + def self.set_default_items(object_id, o_id, avatar_id) + avatars = Avatar.where( + object_lookup_id: object_id, + o_id: o_id, + ).order( 'created_at ASC, id DESC' ) + avatars.each do |avatar| + next if avatar.id == avatar_id + avatar.default = false + avatar.save! end + end - def self.add_init_avatar(object_id, o_id) + def self.add_init_avatar(object_id, o_id) - count = Avatar.where( - object_lookup_id: object_id, - o_id: o_id, - ).count - return if count > 0 + count = Avatar.where( + object_lookup_id: object_id, + o_id: o_id, + ).count + return if count > 0 - Avatar.create( - o_id: o_id, - object_lookup_id: object_id, - default: true, - source: 'init', - initial: true, - deletable: false, - updated_by_id: 1, - created_by_id: 1, - ) - end + Avatar.create( + o_id: o_id, + object_lookup_id: object_id, + default: true, + source: 'init', + initial: true, + deletable: false, + updated_by_id: 1, + created_by_id: 1, + ) + end end diff --git a/app/models/channel/email_parser.rb b/app/models/channel/email_parser.rb index f7af05bc5..526f97e37 100644 --- a/app/models/channel/email_parser.rb +++ b/app/models/channel/email_parser.rb @@ -191,7 +191,7 @@ class Channel::EmailParser else # text part only - if !mail.mime_type || mail.mime_type.to_s == '' || mail.mime_type.to_s.downcase == 'text/plain' + if !mail.mime_type || mail.mime_type.to_s == '' || mail.mime_type.to_s.downcase == 'text/plain' data[:body] = mail.body.decoded data[:body] = Encode.conv( mail.charset, data[:body] ) @@ -526,7 +526,7 @@ class Channel::EmailParser def set_attributes_by_x_headers( item_object, header_name, mail ) # loop all x-zammad-hedaer-* headers - item_object.attributes.each{|key,value| + item_object.attributes.each{|key, value| # ignore read only attributes next if key == 'updated_at' @@ -535,9 +535,9 @@ class Channel::EmailParser next if key == 'created_by_id' # check if id exists - key_short = key[ key.length-3 , key.length ] + key_short = key[ key.length - 3, key.length ] 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}" if mail[ header.to_sym ] puts "NOTICE: header #{header} found #{mail[ header.to_sym ]}" diff --git a/app/models/channel/imap.rb b/app/models/channel/imap.rb index 7e90f55e2..41c57db7a 100644 --- a/app/models/channel/imap.rb +++ b/app/models/channel/imap.rb @@ -65,7 +65,7 @@ class Channel::IMAP < Channel::EmailParser # check for verify message 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}/ puts " - verify email #{verify_string} found" @imap.store(message_id, '+FLAGS', [:Deleted]) @@ -76,7 +76,7 @@ class Channel::IMAP < Channel::EmailParser else # 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) @imap.store(message_id, '+FLAGS', [:Deleted]) end diff --git a/app/models/channel/twitter2.rb b/app/models/channel/twitter2.rb index 8fa40f12b..9b794f0d1 100644 --- a/app/models/channel/twitter2.rb +++ b/app/models/channel/twitter2.rb @@ -227,7 +227,7 @@ class Channel::TWITTER2 ticket = Ticket.create( group_id: group_id, customer_id: user.id, - title: tweet.text[0,40], + title: tweet.text[0, 40], state_id: state_id, priority_id: priority_id, ) diff --git a/app/models/observer/ticket/notification/background_job.rb b/app/models/observer/ticket/notification/background_job.rb index 8716eaa6c..c9ddcca46 100644 --- a/app/models/observer/ticket/notification/background_job.rb +++ b/app/models/observer/ticket/notification/background_job.rb @@ -70,7 +70,7 @@ class Observer::Ticket::Notification::BackgroundJob object: 'Ticket', o_id: ticket.id, seen: seen, - created_by_id: ticket.updated_by_id || 1, + created_by_id: ticket.updated_by_id ||  1, user_id: user.id, ) @@ -134,7 +134,7 @@ class Observer::Ticket::Notification::BackgroundJob history_type: 'notification', history_object: 'Ticket', value_to: recipient_list, - created_by_id: ticket.updated_by_id || 1 + created_by_id: ticket.updated_by_id ||  1 ) end end @@ -165,8 +165,8 @@ class Observer::Ticket::Notification::BackgroundJob # get attribute name attribute_name = key.to_s object_manager_attribute = attribute_list[attribute_name] - if attribute_name[-3,3] == '_id' - attribute_name = attribute_name[ 0, attribute_name.length-3 ].to_s + if attribute_name[-3, 3] == '_id' + attribute_name = attribute_name[ 0, attribute_name.length - 3 ].to_s end # 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 value_id = [] 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[1] = value[1] @@ -289,7 +289,7 @@ State: i18n(#{ticket.state.name.text2html})
def template_update(user, ticket, article, ticket_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}
\n" } article_content = '' @@ -339,7 +339,7 @@ Changes:
end body = template_header(user) + body - body += template_footer(user,ticket, article) + body += template_footer(user, ticket, article) template = { subject: subject, diff --git a/app/models/online_notification.rb b/app/models/online_notification.rb index 2abe8333c..a1c2bfa9d 100644 --- a/app/models/online_notification.rb +++ b/app/models/online_notification.rb @@ -85,7 +85,7 @@ return all online notifications of an user =end - def self.list(user,limit) + def self.list(user, limit) notifications = OnlineNotification.where(user_id: user.id). order( 'created_at DESC, id DESC' ). @@ -167,7 +167,7 @@ returns: =end - def self.list_full(user,limit) + def self.list_full(user, limit) notifications = OnlineNotification.list(user, limit) assets = ApplicationModel.assets_of_object_list(notifications) diff --git a/app/models/organization/search_index.rb b/app/models/organization/search_index.rb index 26bc44fb7..33421f9d6 100644 --- a/app/models/organization/search_index.rb +++ b/app/models/organization/search_index.rb @@ -21,8 +21,8 @@ returns # get attribute name attribute_name = key.to_s - next if attribute_name[-3,3] != '_id' - attribute_name = attribute_name[ 0, attribute_name.length-3 ] + next if attribute_name[-3, 3] != '_id' + attribute_name = attribute_name[ 0, attribute_name.length - 3 ] # check if attribute method exists next if !ref_object.respond_to?( attribute_name ) diff --git a/app/models/package.rb b/app/models/package.rb index 6589bbfb0..f355adb63 100644 --- a/app/models/package.rb +++ b/app/models/package.rb @@ -207,11 +207,11 @@ class Package < ApplicationModel end # uninstall files of old package - self.uninstall({ + self.uninstall( name: package_db.name, version: package_db.version, migration_not_down: true, - }) + ) end # store package @@ -391,7 +391,7 @@ class Package < ApplicationModel # check if directories need to be created directories = location.split '/' - (0..(directories.length-2) ).each {|position| + (0..(directories.length - 2) ).each {|position| tmp_path = '' (1..position).each {|count| tmp_path = tmp_path + '/' + directories[count].to_s diff --git a/app/models/store/provider/file.rb b/app/models/store/provider/file.rb index 5b2534b79..fdcc8a562 100644 --- a/app/models/store/provider/file.rb +++ b/app/models/store/provider/file.rb @@ -60,7 +60,7 @@ class Store::Provider::File end # write file to fs - def self.write_to_fs(data,sha) + def self.write_to_fs(data, sha) # install file permission = '600' diff --git a/app/models/user.rb b/app/models/user.rb index 4ca5839b4..ef23209fe 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -366,7 +366,7 @@ returns =end - def self.password_reset_via_token(token,password) + def self.password_reset_via_token(token, password) # check token user = Token.check( action: 'PasswordReset', name: token ) diff --git a/config/routes/network.rb b/config/routes/network.rb index 345a277d6..f3b6ecd7f 100644 --- a/config/routes/network.rb +++ b/config/routes/network.rb @@ -6,6 +6,6 @@ Zammad::Application.routes.draw do match api_path + '/networks/:id', to: 'networks#show', via: :get 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#destroy',via: :delete + match api_path + '/networks/:id', to: 'networks#destroy', via: :delete end diff --git a/config/routes/organization.rb b/config/routes/organization.rb index ad54d47f9..ead3b0193 100644 --- a/config/routes/organization.rb +++ b/config/routes/organization.rb @@ -6,6 +6,6 @@ Zammad::Application.routes.draw do match api_path + '/organizations/:id', to: 'organizations#show', via: :get match api_path + '/organizations', to: 'organizations#create', via: :post 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 diff --git a/config/routes/taskbar.rb b/config/routes/taskbar.rb index 0a9765352..b63457537 100644 --- a/config/routes/taskbar.rb +++ b/config/routes/taskbar.rb @@ -5,6 +5,6 @@ Zammad::Application.routes.draw do match api_path + '/taskbar/:id', to: 'taskbar#show', via: :get 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#destroy',via: :delete + match api_path + '/taskbar/:id', to: 'taskbar#destroy', via: :delete end diff --git a/db/migrate/20120101000001_create_base.rb b/db/migrate/20120101000001_create_base.rb index 2f8d2db7e..976c7fdfe 100644 --- a/db/migrate/20120101000001_create_base.rb +++ b/db/migrate/20120101000001_create_base.rb @@ -33,7 +33,7 @@ class CreateBase < ActiveRecord::Migration t.column :last_login, :timestamp, null: true t.column :source, :string, limit: 200, null: true 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 :created_by_id, :integer, null: false t.timestamps diff --git a/db/migrate/20120101000010_create_ticket.rb b/db/migrate/20120101000010_create_ticket.rb index 0a7e94b59..bcd9be345 100644 --- a/db/migrate/20120101000010_create_ticket.rb +++ b/db/migrate/20120101000010_create_ticket.rb @@ -35,10 +35,10 @@ class CreateTicket < ActiveRecord::Migration t.references :state, null: false t.references :organization, null: true 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 :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_escal_date, :timestamp, null: true t.column :first_response_sla_time, :timestamp, null: true diff --git a/db/migrate/20140831000001_create_object_manager.rb b/db/migrate/20140831000001_create_object_manager.rb index 869f1ba07..d77192158 100644 --- a/db/migrate/20140831000001_create_object_manager.rb +++ b/db/migrate/20140831000001_create_object_manager.rb @@ -168,7 +168,7 @@ class CreateObjectManager < ActiveRecord::Migration null: false, default: 2, translate: true, - filter: [1,2,3,4,7], + filter: [1, 2, 3, 4, 7], }, editable: false, active: true, @@ -182,7 +182,7 @@ class CreateObjectManager < ActiveRecord::Migration item_class: 'column', nulloption: false, null: true, - filter: [1,4], + filter: [1, 4], default: 1, }, }, @@ -190,12 +190,12 @@ class CreateObjectManager < ActiveRecord::Migration Agent: { nulloption: false, null: false, - filter: [2,3,4,7], + filter: [2, 3, 4, 7], }, Customer: { nulloption: false, null: true, - filter: [2,4], + filter: [2, 4], default: 2, }, }, @@ -217,10 +217,10 @@ class CreateObjectManager < ActiveRecord::Migration null: true, translate: true, required_if: { - state_id: [3,7] + state_id: [3, 7] }, shown_if: { - state_id: [3,7] + state_id: [3, 7] }, }, editable: false, diff --git a/db/migrate/20150112000001_update_overview_and_ticket_state.rb b/db/migrate/20150112000001_update_overview_and_ticket_state.rb index cbbf2b51f..f60759d10 100644 --- a/db/migrate/20150112000001_update_overview_and_ticket_state.rb +++ b/db/migrate/20150112000001_update_overview_and_ticket_state.rb @@ -14,7 +14,7 @@ class UpdateOverviewAndTicketState < ActiveRecord::Migration condition: { 'tickets.state_id' => [3], '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: { by: 'created_at', @@ -43,7 +43,7 @@ class UpdateOverviewAndTicketState < ActiveRecord::Migration null: false, default: 2, translate: true, - filter: [1,2,3,4,7], + filter: [1, 2, 3, 4, 7], }, editable: false, active: true, @@ -57,7 +57,7 @@ class UpdateOverviewAndTicketState < ActiveRecord::Migration item_class: 'column', nulloption: false, null: true, - filter: [1,4], + filter: [1, 4], default: 1, }, }, @@ -65,12 +65,12 @@ class UpdateOverviewAndTicketState < ActiveRecord::Migration Agent: { nulloption: false, null: false, - filter: [2,3,4,7], + filter: [2, 3, 4, 7], }, Customer: { nulloption: false, null: true, - filter: [2,4], + filter: [2, 4], default: 2, }, }, @@ -93,10 +93,10 @@ class UpdateOverviewAndTicketState < ActiveRecord::Migration null: true, translate: true, required_if: { - state_id: [3,7] + state_id: [3, 7] }, shown_if: { - state_id: [3,7] + state_id: [3, 7] }, }, editable: false, diff --git a/db/migrate/20150223000001_update_overview2.rb b/db/migrate/20150223000001_update_overview2.rb index d51be1b9f..18ecac3bf 100644 --- a/db/migrate/20150223000001_update_overview2.rb +++ b/db/migrate/20150223000001_update_overview2.rb @@ -10,7 +10,7 @@ class UpdateOverview2 < ActiveRecord::Migration prio: 1000, role_id: overview_role.id, condition: { - 'tickets.state_id' => [ 1,2,3,7 ], + 'tickets.state_id' => [ 1, 2, 3, 7 ], 'tickets.owner_id' => 'current_user.id', }, order: { diff --git a/db/seeds.rb b/db/seeds.rb index 42fbc22f9..806e074ac 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -1406,7 +1406,7 @@ Overview.create_if_not_exists( prio: 1000, role_id: overview_role.id, condition: { - 'tickets.state_id' => [ 1,2,3,7 ], + 'tickets.state_id' => [ 1, 2, 3, 7 ], 'tickets.owner_id' => 'current_user.id', }, order: { @@ -1429,7 +1429,7 @@ Overview.create_if_not_exists( condition: { 'tickets.state_id' => [3], '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: { by: 'created_at', @@ -1449,7 +1449,7 @@ Overview.create_if_not_exists( prio: 1020, role_id: overview_role.id, condition: { - 'tickets.state_id' => [1,2,3], + 'tickets.state_id' => [1, 2, 3], 'tickets.owner_id' => 1, }, order: { @@ -1470,7 +1470,7 @@ Overview.create_if_not_exists( prio: 1030, role_id: overview_role.id, condition: { - 'tickets.state_id' => [1,2,3], + 'tickets.state_id' => [1, 2, 3], }, order: { by: 'created_at', @@ -1478,7 +1478,7 @@ Overview.create_if_not_exists( }, view: { 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' ], view_mode_default: 's', }, @@ -1491,7 +1491,7 @@ Overview.create_if_not_exists( role_id: overview_role.id, condition: { 'tickets.state_id' => [3], - 'tickets.pending_time' => { 'direction' => 'before', 'count'=> 1, 'area' => 'minute' }, + 'tickets.pending_time' => { 'direction' => 'before', 'count' => 1, 'area' => 'minute' }, }, order: { by: 'created_at', @@ -1511,7 +1511,7 @@ Overview.create_if_not_exists( prio: 1040, role_id: overview_role.id, condition: { - 'tickets.escalation_time' => { 'direction' => 'before', 'count'=> 5, 'area' => 'minute' }, + 'tickets.escalation_time' => { 'direction' => 'before', 'count' => 5, 'area' => 'minute' }, }, order: { by: 'escalation_time', @@ -1532,7 +1532,7 @@ Overview.create_if_not_exists( prio: 1000, role_id: overview_role.id, condition: { - 'tickets.state_id' => [ 1,2,3,4,6 ], + 'tickets.state_id' => [ 1, 2, 3, 4, 6 ], 'tickets.customer_id' => 'current_user.id', }, order: { @@ -1553,7 +1553,7 @@ Overview.create_if_not_exists( role_id: overview_role.id, organization_shared: true, condition: { - 'tickets.state_id' => [ 1,2,3,4,6 ], + 'tickets.state_id' => [ 1, 2, 3, 4, 6 ], 'tickets.organization_id' => 'current_user.organization_id', }, order: { diff --git a/lib/core_ext/class.rb b/lib/core_ext/class.rb index 0b6ac9185..896ad94a8 100644 --- a/lib/core_ext/class.rb +++ b/lib/core_ext/class.rb @@ -2,8 +2,8 @@ class Class def to_app_model_url camel_cased_word = self.to_s camel_cased_word.gsub(/::/, '_'). - gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2'). - gsub(/([a-z\d])([A-Z])/,'\1_\2'). + gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2'). + gsub(/([a-z\d])([A-Z])/, '\1_\2'). tr('-', '_'). downcase end diff --git a/lib/fill_db.rb b/lib/fill_db.rb index a9a000dc8..361c9e398 100644 --- a/lib/fill_db.rb +++ b/lib/fill_db.rb @@ -54,7 +54,7 @@ module FillDB suffix = rand(99_999).to_s organization = nil if !organization_pool.empty? && rand(2) == 1 - organization = organization_pool[ organization_pool.length-1 ] + organization = organization_pool[ organization_pool.length - 1 ] end user = User.create_or_update( login: "filldb-customer-#{suffix}", @@ -95,15 +95,15 @@ module FillDB state_pool = Ticket::State.all if tickets && !tickets.zero? (1..tickets).each {|count| - customer = customer_pool[ rand(customer_pool.length-1) ] - agent = agent_pool[ rand(agent_pool.length-1) ] + customer = customer_pool[ rand(customer_pool.length - 1) ] + agent = agent_pool[ rand(agent_pool.length - 1) ] ticket = Ticket.create( 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, owner: agent, - state: state_pool[ rand(state_pool.length-1) ], - priority: priority_pool[ rand(priority_pool.length-1) ], + state: state_pool[ rand(state_pool.length - 1) ], + priority: priority_pool[ rand(priority_pool.length - 1) ], updated_by_id: agent.id, created_by_id: agent.id, ) diff --git a/lib/geo_location.rb b/lib/geo_location.rb index b18df5560..40ac95c35 100644 --- a/lib/geo_location.rb +++ b/lib/geo_location.rb @@ -37,13 +37,13 @@ returns =end - def self.reverse_geocode(lat,lng) + def self.reverse_geocode(lat, lng) # load backend backend = self.load_adapter_by_setting( 'geo_location_backend' ) return if !backend # db lookup - backend.reverse_geocode(lat,lng) + backend.reverse_geocode(lat, lng) end end diff --git a/lib/geo_location/gmaps.rb b/lib/geo_location/gmaps.rb index 2f125c7e9..7265ed49b 100644 --- a/lib/geo_location/gmaps.rb +++ b/lib/geo_location/gmaps.rb @@ -15,10 +15,10 @@ class GeoLocation::Gmaps lat = result['results'].first['geometry']['location']['lat'] lng = result['results'].first['geometry']['location']['lng'] - latlng = [lat,lng] + latlng = [lat, lng] 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" response = UserAgent.get(url) return if !response.success? diff --git a/lib/import/otrs.rb b/lib/import/otrs.rb index b92bca452..b9e08326b 100644 --- a/lib/import/otrs.rb +++ b/lib/import/otrs.rb @@ -67,7 +67,7 @@ module Import::OTRS required_group_ro: 'groups_ro', required_group_rw: 'groups_rw', } - types.each {|config_key,result_key| + types.each {|config_key, result_key| if config[config_key] return false if !result[result_key].has_value?( config[config_key] ) end @@ -82,7 +82,7 @@ module Import::OTRS group_ro_role_map: 'groups_ro', group_rw_role_map: 'groups_rw', } - types.each {|config_key,result_key| + types.each {|config_key, result_key| next if !config[config_key] config[config_key].each {|otrs_group, role| next if !result[result_key].has_value?( otrs_group ) @@ -278,7 +278,7 @@ module Import::OTRS created_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 ticket_new[value] = Encode.conv( 'utf8', record['Ticket'][key.to_s] ) else @@ -331,7 +331,7 @@ module Import::OTRS created_by_id: 1, updated_by_id: 1, } - map[:Article].each { |key,value| + map[:Article].each { |key, value| if article[key.to_s] article_new[value] = Encode.conv( 'utf8', article[key.to_s] ) end @@ -572,7 +572,7 @@ module Import::OTRS created_by_id: 1, updated_by_id: 1, } - map.each { |key,value| + map.each { |key, value| if state[key.to_s] state_new[value] = state[key.to_s] end @@ -623,7 +623,7 @@ module Import::OTRS created_by_id: 1, updated_by_id: 1, } - map.each { |key,value| + map.each { |key, value| if priority[key.to_s] priority_new[value] = priority[key.to_s] end @@ -667,7 +667,7 @@ module Import::OTRS created_by_id: 1, updated_by_id: 1, } - map.each { |key,value| + map.each { |key, value| if group[key.to_s] group_new[value] = group[key.to_s] end @@ -719,7 +719,7 @@ module Import::OTRS source: 'OTRS Import', role_ids: [ role.id ], } - map.each { |key,value| + map.each { |key, value| if user[key.to_s] user_new[value] = user[key.to_s] end @@ -793,7 +793,7 @@ module Import::OTRS source: 'OTRS Import', role_ids: [role.id], } - map.each { |key,value| + map.each { |key, value| if user[key.to_s] user_new[value] = user[key.to_s] end diff --git a/lib/import/otrs2.rb b/lib/import/otrs2.rb index c5b54e1b8..d62a5d896 100644 --- a/lib/import/otrs2.rb +++ b/lib/import/otrs2.rb @@ -347,7 +347,7 @@ module Import::OTRS2 run = true while run count += steps - records = load('CustomerUser', steps, count-steps) + records = load('CustomerUser', steps, count - steps) if !records || !records[0] log 'all customers imported.' run = false @@ -371,11 +371,11 @@ module Import::OTRS2 while run count += steps log "loading... thread# #{thread} ..." - offset = count-steps + offset = count - steps if offset != 0 offset = count - steps + 1 end - records = load( 'Ticket', steps, count-steps) + records = load( 'Ticket', steps, count - steps) if !records || !records[0] log "... thread# #{thread}, no more work." run = false @@ -450,11 +450,11 @@ module Import::OTRS2 while run count += steps log 'loading... diff ...' - offset = count-steps + offset = count - steps if offset != 0 offset = count - steps + 1 end - records = load( 'Ticket', steps, count-steps, 1 ) + records = load( 'Ticket', steps, count - steps, 1 ) if !records || !records[0] log '... no more work.' run = false @@ -520,7 +520,7 @@ module Import::OTRS2 created_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 ticket_new[value] = Encode.conv( 'utf8', record[key.to_s] ) else @@ -571,7 +571,7 @@ module Import::OTRS2 created_by_id: 1, updated_by_id: 1, } - map[:Article].each { |key,value| + map[:Article].each { |key, value| if article[key.to_s] article_new[value] = Encode.conv( 'utf8', article[key.to_s] ) end @@ -820,7 +820,7 @@ module Import::OTRS2 created_by_id: 1, updated_by_id: 1, } - map.each { |key,value| + map.each { |key, value| if state.has_key?(key.to_s) state_new[value] = state[key.to_s] end @@ -869,7 +869,7 @@ module Import::OTRS2 created_by_id: 1, updated_by_id: 1, } - map.each { |key,value| + map.each { |key, value| if priority.has_key?(key.to_s) priority_new[value] = priority[key.to_s] end @@ -910,7 +910,7 @@ module Import::OTRS2 created_by_id: 1, updated_by_id: 1, } - map.each { |key,value| + map.each { |key, value| if group.has_key?(key.to_s) group_new[value] = group[key.to_s] end @@ -966,7 +966,7 @@ module Import::OTRS2 role_ids: role_ids, group_ids: group_ids, } - map.each { |key,value| + map.each { |key, value| if user.has_key?(key.to_s) user_new[value] = user[key.to_s] end @@ -1037,7 +1037,7 @@ module Import::OTRS2 if group_lookup['Name'] == 'admin' && permissions && permissions.include?('rw') roles.push 'Admin' 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' end end @@ -1091,7 +1091,7 @@ module Import::OTRS2 organization_id: get_organization_id(user, organizations), role_ids: [ role_customer.id ], } - map.each { |key,value| + map.each { |key, value| if user.has_key?(key.to_s) user_new[value] = user[key.to_s] end @@ -1155,7 +1155,7 @@ module Import::OTRS2 created_by_id: 1, updated_by_id: 1, } - map.each { |key,value| + map.each { |key, value| if organization.has_key?(key.to_s) organization_new[value] = organization[key.to_s] end diff --git a/lib/sessions.rb b/lib/sessions.rb index d6dd1c6fc..5cdd478a0 100644 --- a/lib/sessions.rb +++ b/lib/sessions.rb @@ -42,10 +42,13 @@ returns # send update to browser if session && session['id'] - self.send( client_id, { - event: 'ws:login', - data: { success: true }, - }) + self.send( + client_id, + { + event: 'ws:login', + data: { success: true }, + } + ) end end @@ -269,7 +272,7 @@ returns while check if File::exists?( path + filename ) count += 1 - filename = filename + '-' + count + filename = filename + '-' + count else check = false end @@ -395,7 +398,7 @@ returns path = @path + '/spool/' FileUtils.mkpath path 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 = { msg: msg, timestamp: Time.now.to_i, diff --git a/lib/sessions/backend/activity_stream.rb b/lib/sessions/backend/activity_stream.rb index 07043b00e..888d9d70e 100644 --- a/lib/sessions/backend/activity_stream.rb +++ b/lib/sessions/backend/activity_stream.rb @@ -43,7 +43,7 @@ class Sessions::Backend::ActivityStream data = self.load - return if !data||data.empty? + return if !data || data.empty? if !@client return { @@ -54,11 +54,11 @@ class Sessions::Backend::ActivityStream end @client.log 'notify', "push activity_stream #{ data.first.class.to_s } for user #{ @user.id }" - @client.send({ + @client.send( event: 'activity_stream_rebuild', collection: 'activity_stream', data: data, - }) + ) end end diff --git a/lib/sessions/backend/collections/base.rb b/lib/sessions/backend/collections/base.rb index d48f55a0c..4bdd65347 100644 --- a/lib/sessions/backend/collections/base.rb +++ b/lib/sessions/backend/collections/base.rb @@ -52,7 +52,7 @@ class Sessions::Backend::Collections::Base # load current data items = self.load - return if !items||items.empty? + return if !items || items.empty? # get relations of data all = [] @@ -74,18 +74,18 @@ class Sessions::Backend::Collections::Base } end @client.log 'notify', "push assets for push_collection #{ items.first.class.to_s } for user #{ @user.id }" - @client.send({ + @client.send( data: assets, event: [ 'loadAssets' ], - }) + ) @client.log 'notify', "push push_collection #{ items.first.class.to_s } for user #{ @user.id }" - @client.send({ + @client.send( event: 'resetCollection', data: { items.first.class.to_app_model => all, }, - }) + ) end def self.model_set(model) diff --git a/lib/sessions/backend/rss.rb b/lib/sessions/backend/rss.rb index 1a67fbcf9..95ceaa646 100644 --- a/lib/sessions/backend/rss.rb +++ b/lib/sessions/backend/rss.rb @@ -43,7 +43,7 @@ class Sessions::Backend::Rss data = self.load - return if !data||data.empty? + return if !data || data.empty? if !@client return { @@ -54,11 +54,11 @@ class Sessions::Backend::Rss end @client.log 'notify', "push rss for user #{@user.id}" - @client.send({ + @client.send( event: 'rss_rebuild', collection: 'dashboard_rss', data: data, - }) + ) end end diff --git a/lib/sessions/backend/ticket_create.rb b/lib/sessions/backend/ticket_create.rb index 039059417..eb0e1c70c 100644 --- a/lib/sessions/backend/ticket_create.rb +++ b/lib/sessions/backend/ticket_create.rb @@ -59,10 +59,10 @@ class Sessions::Backend::TicketCreate end @client.log 'notify', "push ticket_create for user #{ @user.id }" - @client.send({ + @client.send( collection: 'ticket_create_attributes', data: data, - }) + ) end end diff --git a/lib/sessions/backend/ticket_overview_index.rb b/lib/sessions/backend/ticket_overview_index.rb index e87e37f5a..aced54e92 100644 --- a/lib/sessions/backend/ticket_overview_index.rb +++ b/lib/sessions/backend/ticket_overview_index.rb @@ -57,10 +57,10 @@ class Sessions::Backend::TicketOverviewIndex end @client.log 'notify', "push overview_index for user #{ @user.id }" - @client.send({ + @client.send( event: ['ticket_overview_index'], data: data, - }) + ) end end diff --git a/lib/sessions/backend/ticket_overview_list.rb b/lib/sessions/backend/ticket_overview_list.rb index 6a65a954d..57905e119 100644 --- a/lib/sessions/backend/ticket_overview_list.rb +++ b/lib/sessions/backend/ticket_overview_list.rb @@ -106,11 +106,11 @@ class Sessions::Backend::TicketOverviewList @client.log 'notify', "push overview_list for user #{ @user.id }" # send update to browser - @client.send({ + @client.send( data: assets, event: [ 'loadAssets' ] - }) - @client.send({ + ) + @client.send( data: { view: item[:index].link.to_s, overview: overview_data[:overview], @@ -122,7 +122,7 @@ class Sessions::Backend::TicketOverviewList }, }, event: [ 'ticket_overview_rebuild' ], - }) + ) end } return results if !@client diff --git a/lib/static_assets.rb b/lib/static_assets.rb index d05b4eb76..7ebda92de 100644 --- a/lib/static_assets.rb +++ b/lib/static_assets.rb @@ -7,7 +7,7 @@ module StaticAssets data[:content] = Base64.decode64($2) return data end - raise "Unable to parse data url: #{data_url.substr(0,100)}" + raise "Unable to parse data url: #{data_url.substr(0, 100)}" end # store image 1:1 diff --git a/lib/time_calculation.rb b/lib/time_calculation.rb index 79bcbc3ab..d0b4bca2e 100644 --- a/lib/time_calculation.rb +++ b/lib/time_calculation.rb @@ -197,7 +197,7 @@ put working hours matrix and timezone in function, returns UTC working hours mat # keep it in current day if next_hour == 23 - start_time += diff-1 + start_time += diff - 1 else start_time += diff end @@ -334,7 +334,7 @@ put working hours matrix and timezone in function, returns UTC working hours mat # keep it in current day if next_hour == 23 - start_time += diff-1 + start_time += diff - 1 else start_time += diff end diff --git a/lib/user_agent.rb b/lib/user_agent.rb index 4cec34e3d..6f3b54b90 100644 --- a/lib/user_agent.rb +++ b/lib/user_agent.rb @@ -45,7 +45,7 @@ returns http = get_http(uri, options) # 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) request = set_basic_auth(request, options) @@ -93,7 +93,7 @@ returns http = get_http(uri, options) # 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 request = set_params(request, params, options) @@ -141,7 +141,7 @@ returns http = get_http(uri, options) # 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 request = set_params(request, params, options) @@ -185,7 +185,7 @@ returns http = get_http(uri, options) # 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) request = set_basic_auth(request, options) @@ -241,150 +241,150 @@ returns end private - def self.get_http(uri, options) - http = Net::HTTP.new(uri.host, uri.port) + def self.get_http(uri, options) + http = Net::HTTP.new(uri.host, uri.port) - http.open_timeout = options[:open_timeout] || 4 - http.read_timeout = options[:read_timeout] || 10 + http.open_timeout = options[:open_timeout] || 4 + http.read_timeout = options[:read_timeout] || 10 - if uri.scheme =~ /https/i - http.use_ssl = true - # @TODO verify_mode should be configurable - http.verify_mode = OpenSSL::SSL::VERIFY_NONE - end - - http + if uri.scheme =~ /https/i + http.use_ssl = true + # @TODO verify_mode should be configurable + http.verify_mode = OpenSSL::SSL::VERIFY_NONE end - def self.set_basic_auth(request, options) + http + end - # http basic auth (if needed) - if options[:user] && options[:user] != '' && options[:password] && options[:password] != '' - request.basic_auth options[:user], options[:password] - end - request + def self.set_basic_auth(request, options) + + # http basic auth (if needed) + if options[:user] && options[:user] != '' && options[:password] && options[:password] != '' + request.basic_auth options[:user], options[:password] end + request + end - def self.set_params(request, params, options) - if options[:json] - request.add_field('Content-Type', 'application/json') - if !params.empty? - request.body = params.to_json - end - else - if !params.empty? - request.set_form_data( params ) - end + def self.set_params(request, params, options) + if options[:json] + request.add_field('Content-Type', 'application/json') + if !params.empty? + request.body = params.to_json + end + else + if !params.empty? + request.set_form_data( params ) end - request end + request + end - def self.process(response, uri, count, params, options) - if !response - return Result.new( - error: "Can't connect to #{uri.to_s}, got no response!", - success: false, - code: 0, - ) - end - - case response - when Net::HTTPNotFound - return Result.new( - error: "No such file #{uri.to_s}, 404!", - success: false, - code: response.code, - ) - when Net::HTTPClientError - return Result.new( - error: "Client Error: #{response.inspect}!", - success: false, - code: response.code, - ) - when Net::HTTPInternalServerError - return Result.new( - error: "Server Error: #{response.inspect}!", - success: false, - code: response.code, - ) - when Net::HTTPRedirection - raise 'Too many redirections for the original URL, halting.' if count <= 0 - url = response['location'] - return get(url, params, options, count - 1) - when Net::HTTPOK - data = nil - if options[:json] && !options[:jsonParseDisable] && response.body - data = JSON.parse( response.body ) - end - return Result.new( - data: data, - body: response.body, - content_type: response['Content-Type'], - success: true, - code: response.code, - ) - when Net::HTTPCreated - data = nil - if options[:json] && !options[:jsonParseDisable] && response.body - data = JSON.parse( response.body ) - end - return Result.new( - data: data, - body: response.body, - content_type: response['Content-Type'], - success: true, - code: response.code, - ) - end - - raise "Unable to process http call '#{response.inspect}'" - end - - def self.ftp(uri,options) - host = uri.host - filename = File.basename(uri.path) - remote_dir = File.dirname(uri.path) - - temp_file = Tempfile.new("download-#{filename}") - temp_file.binmode - - begin - Net::FTP.open(host) do |ftp| - ftp.passive = true - if options[:user] && options[:password] - ftp.login( options[:user], options[:password] ) - else - ftp.login - end - ftp.chdir(remote_dir) unless remote_dir == '.' - - begin - ftp.getbinaryfile( filename, temp_file ) - rescue => e - return Result.new( - error: e.inspect, - success: false, - code: '550', - ) - end - end - rescue => e - return Result.new( - error: e.inspect, - success: false, - code: 0, - ) - end - - contents = temp_file.read - temp_file.close - Result.new( - body: contents, - success: true, - code: '200', + def self.process(response, uri, count, params, options) + if !response + return Result.new( + error: "Can't connect to #{uri.to_s}, got no response!", + success: false, + code: 0, ) end + case response + when Net::HTTPNotFound + return Result.new( + error: "No such file #{uri.to_s}, 404!", + success: false, + code: response.code, + ) + when Net::HTTPClientError + return Result.new( + error: "Client Error: #{response.inspect}!", + success: false, + code: response.code, + ) + when Net::HTTPInternalServerError + return Result.new( + error: "Server Error: #{response.inspect}!", + success: false, + code: response.code, + ) + when Net::HTTPRedirection + raise 'Too many redirections for the original URL, halting.' if count <= 0 + url = response['location'] + return get(url, params, options, count - 1) + when Net::HTTPOK + data = nil + if options[:json] && !options[:jsonParseDisable] && response.body + data = JSON.parse( response.body ) + end + return Result.new( + data: data, + body: response.body, + content_type: response['Content-Type'], + success: true, + code: response.code, + ) + when Net::HTTPCreated + data = nil + if options[:json] && !options[:jsonParseDisable] && response.body + data = JSON.parse( response.body ) + end + return Result.new( + data: data, + body: response.body, + content_type: response['Content-Type'], + success: true, + code: response.code, + ) + end + + raise "Unable to process http call '#{response.inspect}'" + end + + def self.ftp(uri, options) + host = uri.host + filename = File.basename(uri.path) + remote_dir = File.dirname(uri.path) + + temp_file = Tempfile.new("download-#{filename}") + temp_file.binmode + + begin + Net::FTP.open(host) do |ftp| + ftp.passive = true + if options[:user] && options[:password] + ftp.login( options[:user], options[:password] ) + else + ftp.login + end + ftp.chdir(remote_dir) unless remote_dir == '.' + + begin + ftp.getbinaryfile( filename, temp_file ) + rescue => e + return Result.new( + error: e.inspect, + success: false, + code: '550', + ) + end + end + rescue => e + return Result.new( + error: e.inspect, + success: false, + code: 0, + ) + end + + contents = temp_file.read + temp_file.close + Result.new( + body: contents, + success: true, + code: '200', + ) + end + class Result def initialize(options) @success = options[:success] diff --git a/script/source_code_filter.rb b/script/source_code_filter.rb index 5967888ca..81a8fd3ac 100755 --- a/script/source_code_filter.rb +++ b/script/source_code_filter.rb @@ -22,7 +22,7 @@ def checkForHeader(fileName) # detect file type if allLines[0] =~ /(^# Copyright)/ || allLines[1] =~ /(^# Copyright)/ foundHeader = true - elsif allLines[1] =~/^=begin/ #assume external script + elsif allLines[1] =~ /^=begin/ #assume external script foundHeader = true end if allLines[0] =~ /(^#!\/)/ @@ -67,7 +67,7 @@ def checkForHeader(fileName) end #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| puts 'Working on folder' + folder.to_s rbfiles = File.join("../#{folder}**", '*.{rb,coffee}') diff --git a/script/websocket-server.rb b/script/websocket-server.rb index aca2645b2..75c18eba6 100755 --- a/script/websocket-server.rb +++ b/script/websocket-server.rb @@ -64,19 +64,19 @@ puts "Starting websocket server on #{ @options[:b] }:#{ @options[:p] } (secure:# if ARGV[0] == 'stop' # read pid - pid =File.open( @options[:i].to_s ).read + pid = File.open( @options[:i].to_s ).read pid.gsub!(/\r|\n/, '') # kill Process.kill( 9, pid.to_i ) exit end -if ARGV[0] == 'start' && @options[:d] +if ARGV[0] == 'start' && @options[:d] Daemons.daemonize # 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.puts(Process.pid.to_s) $daemon_pid.close diff --git a/test/browser_test_helper.rb b/test/browser_test_helper.rb index c9126d3f8..b8d29ccf2 100644 --- a/test/browser_test_helper.rb +++ b/test/browser_test_helper.rb @@ -625,7 +625,7 @@ class TestCase < Test::Unit::TestCase raise "not matching '#{data[:title]}' in title '#{title}'" end end -puts "tv #{params.inspect}" + puts "tv #{params.inspect}" # verify modified if data.has_key?(:modified) exists = instance.find_elements( { css: '.tasks .active .icon' } )[0] diff --git a/test/integration/twitter_test.rb b/test/integration/twitter_test.rb index 112da0d52..bda96f896 100644 --- a/test/integration/twitter_test.rb +++ b/test/integration/twitter_test.rb @@ -73,7 +73,7 @@ class TwitterTest < ActiveSupport::TestCase ticket = Ticket.create( group_id: group.id, customer_id: user.id, - title: text[0,40], + title: text[0, 40], state_id: state.id, priority_id: priority.id, updated_by_id: 1, diff --git a/test/ui_test.rb b/test/ui_test.rb index 3f9920c8d..3c0ada201 100644 --- a/test/ui_test.rb +++ b/test/ui_test.rb @@ -18,7 +18,7 @@ class ExampleTest < Test::Unit::TestCase def test_first_page browser.get 'http://portal.znuny.com/' - assert_equal browser.current_url, 'https://portal.znuny.com/#login' + assert_equal browser.current_url, 'https://portal.znuny.com/#login' end def test_login_failed diff --git a/test/unit/activity_stream_test.rb b/test/unit/activity_stream_test.rb index a2f278bca..0f2efd033 100644 --- a/test/unit/activity_stream_test.rb +++ b/test/unit/activity_stream_test.rb @@ -35,7 +35,7 @@ class ActivityStreamTest < ActiveSupport::TestCase created_by_id: current_user.id, }, article: { - updated_by_id: current_user.id, + updated_by_id: current_user.id, created_by_id: current_user.id, type_id: Ticket::Article::Type.lookup( name: 'phone' ).id, sender_id: Ticket::Article::Sender.lookup( name: 'Customer' ).id, @@ -58,10 +58,10 @@ class ActivityStreamTest < ActiveSupport::TestCase }, }, check: [ - { + { result: true, - object: 'Ticket', - type: 'updated', + object: 'Ticket', + type: 'updated', }, { result: true, diff --git a/test/unit/email_process_test.rb b/test/unit/email_process_test.rb index 2f485695a..828d9864c 100644 --- a/test/unit/email_process_test.rb +++ b/test/unit/email_process_test.rb @@ -2153,7 +2153,7 @@ Some Text', assert( false, "No user '#{user_result[:email]}' found!" ) return end - user_result.each { |key,value| + user_result.each { |key, value| if user.respond_to?( key ) assert_equal( value, user.send(key), "user check #{ key }" ) else @@ -2169,7 +2169,7 @@ Some Text', elsif !file[:success] if result && result.class == Array && result[1] puts result.inspect - assert( false, 'ticket should not be created but is created' ) + assert( false, 'ticket should not be created but is created' ) else assert( true, 'ticket not created - nice' ) end diff --git a/test/unit/history_test.rb b/test/unit/history_test.rb index 6426c2fc0..a00bbad78 100644 --- a/test/unit/history_test.rb +++ b/test/unit/history_test.rb @@ -21,7 +21,7 @@ class HistoryTest < ActiveSupport::TestCase created_by_id: current_user.id, }, article: { - updated_by_id: current_user.id, + updated_by_id: current_user.id, created_by_id: current_user.id, type_id: Ticket::Article::Type.lookup( name: 'phone' ).id, sender_id: Ticket::Article::Sender.lookup( name: 'Customer' ).id, @@ -88,7 +88,7 @@ class HistoryTest < ActiveSupport::TestCase created_by_id: current_user.id, }, article: { - created_by_id: current_user.id, + created_by_id: current_user.id, updated_by_id: current_user.id, type_id: Ticket::Article::Type.lookup(name: 'phone' ).id, sender_id: Ticket::Article::Sender.lookup(name: 'Customer' ).id, diff --git a/test/unit/online_notifiaction_test.rb b/test/unit/online_notifiaction_test.rb index 47e3eefca..c07863b28 100644 --- a/test/unit/online_notifiaction_test.rb +++ b/test/unit/online_notifiaction_test.rb @@ -71,16 +71,16 @@ class OnlineNotificationTest < ActiveSupport::TestCase }, }, check: [ - { + { type: 'create', - object: 'Ticket', - created_by_id: agent_user1.id, + object: 'Ticket', + created_by_id: agent_user1.id, }, { - type: 'update', + type: 'update', object: 'Ticket', created_by_id: customer_user.id, - }, + }, ], }, @@ -122,16 +122,16 @@ class OnlineNotificationTest < ActiveSupport::TestCase }, }, check: [ - { + { type: 'create', - object: 'Ticket', - created_by_id: agent_user1.id, + object: 'Ticket', + created_by_id: agent_user1.id, }, { - type: 'update', + type: 'update', object: 'Ticket', created_by_id: customer_user.id, - }, + }, ], }, @@ -173,16 +173,16 @@ class OnlineNotificationTest < ActiveSupport::TestCase }, }, check: [ - { + { type: 'create', - object: 'Ticket', - created_by_id: agent_user1.id, + object: 'Ticket', + created_by_id: agent_user1.id, }, { - type: 'update', + type: 'update', object: 'Ticket', created_by_id: customer_user.id, - }, + }, ], }, @@ -224,16 +224,16 @@ class OnlineNotificationTest < ActiveSupport::TestCase }, }, check: [ - { + { type: 'create', - object: 'Ticket', - created_by_id: agent_user1.id, + object: 'Ticket', + created_by_id: agent_user1.id, }, { - type: 'update', + type: 'update', object: 'Ticket', created_by_id: customer_user.id, - }, + }, ], }, ] diff --git a/test/unit/session_basic_test.rb b/test/unit/session_basic_test.rb index 552a4f723..7cc27ff6b 100644 --- a/test/unit/session_basic_test.rb +++ b/test/unit/session_basic_test.rb @@ -3,7 +3,7 @@ require 'test_helper' class SessionBasicTest < ActiveSupport::TestCase 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' ) assert_equal( true, result, 'check 1' ) @@ -37,7 +37,7 @@ class SessionBasicTest < ActiveSupport::TestCase assert_equal( nil, result, 'check 2' ) # 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' ) assert_equal( true, result, 'check 1' ) Sessions::CacheIn.delete( 'last_run_delete' ) diff --git a/test/unit/session_enhanced_test.rb b/test/unit/session_enhanced_test.rb index 6c40120c7..ae4279bf0 100644 --- a/test/unit/session_enhanced_test.rb +++ b/test/unit/session_enhanced_test.rb @@ -116,7 +116,7 @@ class SessionEnhancedTest < ActiveSupport::TestCase assert_equal( true, messages[0]['data']['success'], 'messages 1') # broadcast to all clients - Sessions.broadcast( { msg: 'ooo123123123123123123'} ) + Sessions.broadcast( { msg: 'ooo123123123123123123' } ) messages = Sessions.queue(client_id1) assert_equal( messages.count, 1, 'messages count') 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') # send dedicated message to user - Sessions.send_to( agent1.id, { msg: 'ooo1231231231231231234'} ) + Sessions.send_to( agent1.id, { msg: 'ooo1231231231231231234' } ) messages = Sessions.queue(client_id1) assert_equal( messages.count, 1, 'messages count') assert_equal( 'ooo1231231231231231234', messages[0]['msg'], 'messages send 1') diff --git a/test/unit/ticket_notification_test.rb b/test/unit/ticket_notification_test.rb index 031f254d9..29157e490 100644 --- a/test/unit/ticket_notification_test.rb +++ b/test/unit/ticket_notification_test.rb @@ -407,7 +407,7 @@ class TicketNotificationTest < ActiveSupport::TestCase ) # 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['Pending till'], 'Check if attributes translated based on ObjectManager::Attribute' ) assert_equal( 'i18n(1 low)', human_changes['Priority'][0] ) @@ -511,7 +511,7 @@ class TicketNotificationTest < ActiveSupport::TestCase puts "hc #{human_changes.inspect}" # 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['Priority'], 'Check if attributes translated based on ObjectManager::Attribute' ) 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_till'] ) - human_changes = bg.human_changes(agent2,ticket1) + human_changes = bg.human_changes(agent2, ticket1) puts "hc2 #{human_changes.inspect}" template = bg.template_update(agent1, ticket1, article, human_changes) diff --git a/test/unit/ticket_sla_test.rb b/test/unit/ticket_sla_test.rb index e9852872c..b032d94b1 100644 --- a/test/unit/ticket_sla_test.rb +++ b/test/unit/ticket_sla_test.rb @@ -28,7 +28,7 @@ class TicketSlaTest < ActiveSupport::TestCase name: 'test sla 1', condition: {}, 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', 'end_of_workday' => '18:00', }, @@ -49,9 +49,9 @@ class TicketSlaTest < ActiveSupport::TestCase sla = Sla.create( name: 'test sla 2', - condition: { 'tickets.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', + 'Mon' => 'Mon', 'Tue' => 'Tue', 'Wed' => 'Wed', 'Thu' => 'Thu', 'Fri' => 'Fri', 'Sat' => 'Sat', 'Sun' => 'Sun', 'beginning_of_workday' => '8:00', 'end_of_workday' => '18:00', }, @@ -360,7 +360,7 @@ class TicketSlaTest < ActiveSupport::TestCase name: 'test sla 1', condition: {}, 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', 'end_of_workday' => '18:00', }, @@ -402,7 +402,7 @@ class TicketSlaTest < ActiveSupport::TestCase name: 'test sla 1', condition: {}, 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', 'end_of_workday' => '18:00', }, @@ -445,7 +445,7 @@ class TicketSlaTest < ActiveSupport::TestCase name: 'test sla 1', condition: {}, 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', 'end_of_workday' => '18:00', }, @@ -549,7 +549,7 @@ class TicketSlaTest < ActiveSupport::TestCase name: 'test sla 1', condition: {}, 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', 'end_of_workday' => '18:00', }, @@ -612,7 +612,7 @@ class TicketSlaTest < ActiveSupport::TestCase name: 'test sla 1', condition: {}, 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', 'end_of_workday' => '18:00', }, @@ -706,7 +706,7 @@ class TicketSlaTest < ActiveSupport::TestCase name: 'test sla 1', condition: {}, 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', 'end_of_workday' => '18:00', }, @@ -719,14 +719,14 @@ class TicketSlaTest < ActiveSupport::TestCase ) ticket = Ticket.find(ticket.id) - assert_equal( ticket.escalation_time.gmtime.to_s, '2013-06-04 13:30:00 UTC', 'ticket.escalation_time verify 1' ) - assert_equal( ticket.first_response_escal_date.gmtime.to_s, '2013-06-04 13:30:00 UTC', 'ticket.first_response_escal_date verify 1' ) - assert_equal( ticket.first_response_in_min, nil, 'ticket.first_response_in_min verify 3' ) - assert_equal( ticket.first_response_diff_in_min, nil, 'ticket.first_response_diff_in_min verify 3' ) - assert_equal( ticket.update_time_escal_date.gmtime.to_s, '2013-06-04 14:30:00 UTC', 'ticket.update_time_escal_date verify 1' ) - assert_equal( ticket.close_time_escal_date.gmtime.to_s, '2013-06-04 15:30:00 UTC', 'ticket.close_time_escal_date verify 1' ) - assert_equal( ticket.close_time_in_min, 30, 'ticket.close_time_in_min verify 3' ) - assert_equal( ticket.close_time_diff_in_min, 210, 'ticket.close_time_diff_in_min# verify 3' ) + assert_equal( ticket.escalation_time.gmtime.to_s, '2013-06-04 13:30:00 UTC', 'ticket.escalation_time verify 1' ) + assert_equal( ticket.first_response_escal_date.gmtime.to_s, '2013-06-04 13:30:00 UTC', 'ticket.first_response_escal_date verify 1' ) + assert_equal( ticket.first_response_in_min, nil, 'ticket.first_response_in_min verify 3' ) + assert_equal( ticket.first_response_diff_in_min, nil, 'ticket.first_response_diff_in_min verify 3' ) + assert_equal( ticket.update_time_escal_date.gmtime.to_s, '2013-06-04 14:30:00 UTC', 'ticket.update_time_escal_date verify 1' ) + assert_equal( ticket.close_time_escal_date.gmtime.to_s, '2013-06-04 15:30:00 UTC', 'ticket.close_time_escal_date verify 1' ) + assert_equal( ticket.close_time_in_min, 30, 'ticket.close_time_in_min verify 3' ) + assert_equal( ticket.close_time_diff_in_min, 210, 'ticket.close_time_diff_in_min# verify 3' ) delete = sla.destroy assert( delete, 'sla destroy' ) @@ -816,7 +816,7 @@ class TicketSlaTest < ActiveSupport::TestCase name: 'test sla 1', condition: {}, 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', 'end_of_workday' => '18:00', },