diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 87e6d4b9d..40e8ad027 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -119,7 +119,7 @@ class ApplicationController < ActionController::Base
content_encoding: request.headers['Content-Encoding'],
source: request.headers['User-Agent'] || request.headers['Server'],
}
- request.headers.each {|key, value|
+ request.headers.each { |key, value|
next if key[0, 5] != 'HTTP_'
request_data[:content] += if key == 'HTTP_COOKIE'
"#{key}: xxxxx\n"
@@ -141,7 +141,7 @@ class ApplicationController < ActionController::Base
content_encoding: nil,
source: nil,
}
- response.headers.each {|key, value|
+ response.headers.each { |key, value|
response_data[:content] += "#{key}: #{value}\n"
}
body = response.body
@@ -473,7 +473,7 @@ class ApplicationController < ActionController::Base
if params[:expand]
list = []
- generic_objects.each {|generic_object|
+ generic_objects.each { |generic_object|
list.push generic_object.attributes_with_relation_names
}
render json: list, status: :ok
@@ -483,7 +483,7 @@ class ApplicationController < ActionController::Base
if params[:full]
assets = {}
item_ids = []
- generic_objects.each {|item|
+ generic_objects.each { |item|
item_ids.push item.id
assets = item.assets(assets)
}
@@ -495,7 +495,7 @@ class ApplicationController < ActionController::Base
end
generic_objects_with_associations = []
- generic_objects.each {|item|
+ generic_objects.each { |item|
generic_objects_with_associations.push item.attributes_with_associations
}
model_index_render_result(generic_objects_with_associations)
diff --git a/app/controllers/calendars_controller.rb b/app/controllers/calendars_controller.rb
index b21a98d74..3591c1f47 100644
--- a/app/controllers/calendars_controller.rb
+++ b/app/controllers/calendars_controller.rb
@@ -9,7 +9,7 @@ class CalendarsController < ApplicationController
# calendars
assets = {}
calendar_ids = []
- Calendar.all.order(:name, :created_at).each {|calendar|
+ Calendar.all.order(:name, :created_at).each { |calendar|
calendar_ids.push calendar.id
assets = calendar.assets(assets)
}
diff --git a/app/controllers/channels_controller.rb b/app/controllers/channels_controller.rb
index f5cf18316..a88bb62d1 100644
--- a/app/controllers/channels_controller.rb
+++ b/app/controllers/channels_controller.rb
@@ -47,11 +47,11 @@ curl http://localhost/api/v1/channels.json -v -u #{login}:#{password} -H "Conten
def twitter_index
assets = {}
- ExternalCredential.where(name: 'twitter').each {|external_credential|
+ ExternalCredential.where(name: 'twitter').each { |external_credential|
assets = external_credential.assets(assets)
}
channel_ids = []
- Channel.order(:id).each {|channel|
+ Channel.order(:id).each { |channel|
next if channel.area != 'Twitter::Account'
assets = channel.assets(assets)
channel_ids.push channel.id
@@ -70,11 +70,11 @@ curl http://localhost/api/v1/channels.json -v -u #{login}:#{password} -H "Conten
def facebook_index
assets = {}
- ExternalCredential.where(name: 'facebook').each {|external_credential|
+ ExternalCredential.where(name: 'facebook').each { |external_credential|
assets = external_credential.assets(assets)
}
channel_ids = []
- Channel.order(:id).each {|channel|
+ Channel.order(:id).each { |channel|
next if channel.area != 'Facebook::Account'
assets = channel.assets(assets)
channel_ids.push channel.id
@@ -100,10 +100,10 @@ curl http://localhost/api/v1/channels.json -v -u #{login}:#{password} -H "Conten
not_used_email_address_ids = []
accounts_fixed = []
assets = {}
- Channel.order(:id).each {|channel|
+ Channel.order(:id).each { |channel|
if system_online_service && channel.preferences && channel.preferences['online_service_disable']
email_addresses = EmailAddress.where(channel_id: channel.id)
- email_addresses.each {|email_address|
+ email_addresses.each { |email_address|
accounts_fixed.push email_address
}
next
@@ -116,7 +116,7 @@ curl http://localhost/api/v1/channels.json -v -u #{login}:#{password} -H "Conten
assets = channel.assets(assets)
end
}
- EmailAddress.all.each {|email_address|
+ EmailAddress.all.each { |email_address|
next if system_online_service && email_address.preferences && email_address.preferences['online_service_disable']
email_address_ids.push email_address.id
assets = email_address.assets(assets)
@@ -299,7 +299,7 @@ curl http://localhost/api/v1/channels.json -v -u #{login}:#{password} -H "Conten
# save settings
if result[:result] == 'ok'
- Channel.where(area: 'Email::Notification').each {|channel|
+ Channel.where(area: 'Email::Notification').each { |channel|
active = false
if adapter =~ /^#{channel.options[:outbound][:adapter]}$/i
active = true
@@ -322,7 +322,7 @@ curl http://localhost/api/v1/channels.json -v -u #{login}:#{password} -H "Conten
private
def email_account_duplicate?(result, channel_id = nil)
- Channel.where(area: 'Email::Account').each {|channel|
+ Channel.where(area: 'Email::Account').each { |channel|
next if !channel.options
next if !channel.options[:inbound]
next if !channel.options[:inbound][:adapter]
diff --git a/app/controllers/chats_controller.rb b/app/controllers/chats_controller.rb
index e50da70c1..8e0bfb0cc 100644
--- a/app/controllers/chats_controller.rb
+++ b/app/controllers/chats_controller.rb
@@ -7,7 +7,7 @@ class ChatsController < ApplicationController
deny_if_not_role(Z_ROLENAME_ADMIN)
chat_ids = []
assets = {}
- Chat.order(:id).each {|chat|
+ Chat.order(:id).each { |chat|
chat_ids.push chat.id
assets = chat.assets(assets)
}
diff --git a/app/controllers/first_steps_controller.rb b/app/controllers/first_steps_controller.rb
index bce7a8211..dbfd536fd 100644
--- a/app/controllers/first_steps_controller.rb
+++ b/app/controllers/first_steps_controller.rb
@@ -246,9 +246,9 @@ class FirstStepsController < ApplicationController
test_ticket_active = false
end
return result if test_ticket_active
- result.each {|item|
+ result.each { |item|
items = []
- item[:items].each {|local_item|
+ item[:items].each { |local_item|
next if local_item[:name] == 'Create a Test Ticket'
items.push local_item
}
diff --git a/app/controllers/getting_started_controller.rb b/app/controllers/getting_started_controller.rb
index 57de10a33..aee2bef19 100644
--- a/app/controllers/getting_started_controller.rb
+++ b/app/controllers/getting_started_controller.rb
@@ -179,7 +179,7 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
end
# set changed settings
- settings.each {|key, value|
+ settings.each { |key, value|
Setting.set(key, value)
}
diff --git a/app/controllers/import_otrs_controller.rb b/app/controllers/import_otrs_controller.rb
index 42f4434f3..aaea87606 100644
--- a/app/controllers/import_otrs_controller.rb
+++ b/app/controllers/import_otrs_controller.rb
@@ -26,7 +26,7 @@ class ImportOtrsController < ApplicationController
if !response.success? && response.code.to_s !~ /^40.$/
message_human = ''
- translation_map.each {|key, message|
+ translation_map.each { |key, message|
if response.error.to_s =~ /#{Regexp.escape(key)}/i
message_human = message
end
diff --git a/app/controllers/import_zendesk_controller.rb b/app/controllers/import_zendesk_controller.rb
index 0cffb6557..7d8af5d1c 100644
--- a/app/controllers/import_zendesk_controller.rb
+++ b/app/controllers/import_zendesk_controller.rb
@@ -27,7 +27,7 @@ class ImportZendeskController < ApplicationController
if !response.success?
message_human = ''
- translation_map.each {|key, message|
+ translation_map.each { |key, message|
if response.error.to_s =~ /#{Regexp.escape(key)}/i
message_human = message
end
diff --git a/app/controllers/integration/sipgate_controller.rb b/app/controllers/integration/sipgate_controller.rb
index 76bb7e006..7bd651832 100644
--- a/app/controllers/integration/sipgate_controller.rb
+++ b/app/controllers/integration/sipgate_controller.rb
@@ -16,7 +16,7 @@ class Integration::SipgateController < ApplicationController
block_caller_ids = config_inbound[:block_caller_ids] || []
# check if call need to be blocked
- block_caller_ids.each {|item|
+ block_caller_ids.each { |item|
next unless item[:caller_id] == params['from']
xml = Builder::XmlMarkup.new(indent: 2)
xml.instruct!
@@ -61,7 +61,7 @@ class Integration::SipgateController < ApplicationController
to = params[:to]
from = nil
if to
- config_outbound.each {|row|
+ config_outbound.each { |row|
dest = row[:dest].gsub(/\*/, '.+?')
next if to !~ /^#{dest}$/
from = row[:caller_id]
@@ -173,7 +173,7 @@ class Integration::SipgateController < ApplicationController
preferences_maybe = {}
preferences_maybe[direction] = []
caller_ids = Cti::CallerId.lookup(params[direction])
- caller_ids.each {|record|
+ caller_ids.each { |record|
if record.level == 'known'
preferences_known[direction].push record
else
diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb
index 2e04e819c..46649c67e 100644
--- a/app/controllers/organizations_controller.rb
+++ b/app/controllers/organizations_controller.rb
@@ -67,7 +67,7 @@ curl http://localhost/api/v1/organizations -v -u #{login}:#{password}
if params[:expand]
list = []
- organizations.each {|organization|
+ organizations.each { |organization|
list.push organization.attributes_with_relation_names
}
render json: list, status: :ok
@@ -77,7 +77,7 @@ curl http://localhost/api/v1/organizations -v -u #{login}:#{password}
if params[:full]
assets = {}
item_ids = []
- organizations.each {|item|
+ organizations.each { |item|
item_ids.push item.id
assets = item.assets(assets)
}
@@ -246,7 +246,7 @@ curl http://localhost/api/v1/organization/{id} -v -u #{login}:#{password} -H "Co
if params[:expand]
list = []
- organization_all.each {|organization|
+ organization_all.each { |organization|
list.push organization.attributes_with_relation_names
}
render json: list, status: :ok
diff --git a/app/controllers/reports_controller.rb b/app/controllers/reports_controller.rb
index fa8c2e15d..741ff14b2 100644
--- a/app/controllers/reports_controller.rb
+++ b/app/controllers/reports_controller.rb
@@ -22,7 +22,7 @@ class ReportsController < ApplicationController
return if !get_params
result = {}
- get_params[:metric][:backend].each {|backend|
+ get_params[:metric][:backend].each { |backend|
condition = get_params[:profile].condition
if backend[:condition]
backend[:condition].merge(condition)
@@ -75,7 +75,7 @@ class ReportsController < ApplicationController
# get data
result = {}
- get_params[:metric][:backend].each {|backend|
+ get_params[:metric][:backend].each { |backend|
next if params[:downloadBackendSelected] != backend[:name]
condition = get_params[:profile].condition
if backend[:condition]
@@ -116,7 +116,7 @@ class ReportsController < ApplicationController
if params[:profile_id]
profile = Report::Profile.find(params[:profile_id])
else
- params[:profiles].each {|profile_id, active|
+ params[:profiles].each { |profile_id, active|
next if !active
profile = Report::Profile.find(profile_id)
}
@@ -203,7 +203,7 @@ class ReportsController < ApplicationController
worksheet.write(2, 7, 'Closed at', format_header )
row = 2
- result[:ticket_ids].each {|ticket_id|
+ result[:ticket_ids].each { |ticket_id|
ticket = Ticket.lookup(id: ticket_id)
row += 1
worksheet.write(row, 0, ticket.number )
diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb
index 3c91514e7..03a4f54ff 100644
--- a/app/controllers/search_controller.rb
+++ b/app/controllers/search_controller.rb
@@ -34,7 +34,7 @@ class SearchController < ApplicationController
next if !preferences
objects_in_order_hash[preferences[:prio]] = object
}
- objects_in_order_hash.keys.sort.reverse_each {|prio|
+ objects_in_order_hash.keys.sort.reverse_each { |prio|
objects_in_order.push objects_in_order_hash[prio]
}
@@ -78,7 +78,7 @@ class SearchController < ApplicationController
# sort order by object priority
result_in_order = []
objects_in_order.each { |object|
- result.each {|item|
+ result.each { |item|
next if item[:type] != object
item[:id] = item[:id].to_i
result_in_order.push item
diff --git a/app/controllers/sessions/collection_base.rb b/app/controllers/sessions/collection_base.rb
index 7a946fa93..bde5a8f5f 100644
--- a/app/controllers/sessions/collection_base.rb
+++ b/app/controllers/sessions/collection_base.rb
@@ -7,7 +7,7 @@ module ExtraCollection
collections[ Locale.to_app_model ] = Locale.where(active: true)
collections[ Taskbar.to_app_model ] = Taskbar.where(user_id: user.id)
- collections[ Taskbar.to_app_model ].each {|item|
+ collections[ Taskbar.to_app_model ].each { |item|
assets = item.assets(assets)
}
@@ -18,18 +18,18 @@ module ExtraCollection
assets = RecentView.assets_of_object_list(collections[ RecentView.to_app_model ], assets)
collections[ Role.to_app_model ] = []
- Role.all.each {|item|
+ Role.all.each { |item|
assets = item.assets(assets)
}
collections[ Group.to_app_model ] = []
- Group.all.each {|item|
+ Group.all.each { |item|
assets = item.assets(assets)
}
collections[ Organization.to_app_model ] = []
if user.organization_id
- Organization.where(id: user.organization_id).each {|item|
+ Organization.where(id: user.organization_id).each { |item|
assets = item.assets(assets)
}
end
diff --git a/app/controllers/sessions/collection_ticket.rb b/app/controllers/sessions/collection_ticket.rb
index 201ef3b1a..87fcb39f9 100644
--- a/app/controllers/sessions/collection_ticket.rb
+++ b/app/controllers/sessions/collection_ticket.rb
@@ -5,40 +5,40 @@ module ExtraCollection
# all ticket stuff
collections[ Macro.to_app_model ] = []
- Macro.all.each {|item|
+ Macro.all.each { |item|
assets = item.assets(assets)
}
collections[ Ticket::StateType.to_app_model ] = []
- Ticket::StateType.all.each {|item|
+ Ticket::StateType.all.each { |item|
assets = item.assets(assets)
}
collections[ Ticket::State.to_app_model ] = []
- Ticket::State.all.each {|item|
+ Ticket::State.all.each { |item|
assets = item.assets(assets)
}
collections[ Ticket::Priority.to_app_model ] = []
- Ticket::Priority.all.each {|item|
+ Ticket::Priority.all.each { |item|
assets = item.assets(assets)
}
collections[ Ticket::Article::Type.to_app_model ] = []
- Ticket::Article::Type.all.each {|item|
+ Ticket::Article::Type.all.each { |item|
assets = item.assets(assets)
}
collections[ Ticket::Article::Sender.to_app_model ] = []
- Ticket::Article::Sender.all.each {|item|
+ Ticket::Article::Sender.all.each { |item|
assets = item.assets(assets)
}
if !user.role?(Z_ROLENAME_CUSTOMER)
# all signatures
collections[ Signature.to_app_model ] = []
- Signature.all.each {|item|
+ Signature.all.each { |item|
assets = item.assets(assets)
}
# all email addresses
collections[ EmailAddress.to_app_model ] = []
- EmailAddress.all.each {|item|
+ EmailAddress.all.each { |item|
assets = item.assets(assets)
}
end
diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb
index f3224cb1f..c5f21c937 100644
--- a/app/controllers/sessions_controller.rb
+++ b/app/controllers/sessions_controller.rb
@@ -280,7 +280,7 @@ class SessionsController < ApplicationController
deny_if_not_role(Z_ROLENAME_ADMIN)
assets = {}
sessions_clean = []
- SessionHelper.list.each {|session|
+ SessionHelper.list.each { |session|
next if !session.data['user_id']
sessions_clean.push session
if session.data['user_id']
diff --git a/app/controllers/slas_controller.rb b/app/controllers/slas_controller.rb
index 6c02b603d..61a420759 100644
--- a/app/controllers/slas_controller.rb
+++ b/app/controllers/slas_controller.rb
@@ -54,13 +54,13 @@ curl http://localhost/api/v1/slas.json -v -u #{login}:#{password}
# calendars
assets = {}
calendar_ids = []
- Calendar.all.each {|calendar|
+ Calendar.all.each { |calendar|
assets = calendar.assets(assets)
}
# slas
sla_ids = []
- Sla.all.each {|item|
+ Sla.all.each { |item|
sla_ids.push item.id
assets = item.assets(assets)
}
diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb
index 8556ae2ba..35f809efa 100644
--- a/app/controllers/tags_controller.rb
+++ b/app/controllers/tags_controller.rb
@@ -7,7 +7,7 @@ class TagsController < ApplicationController
def search
list = Tag::Item.where('name_downcase LIKE ?', "#{params[:term].strip.downcase}%").order('name ASC').limit(params[:limit] || 10)
results = []
- list.each {|item|
+ list.each { |item|
result = {
id: item.id,
value: item.name,
@@ -62,7 +62,7 @@ class TagsController < ApplicationController
def admin_list
list = Tag::Item.order('name ASC').limit(params[:limit] || 1000)
results = []
- list.each {|item|
+ list.each { |item|
result = {
id: item.id,
name: item.name,
diff --git a/app/controllers/ticket_articles_controller.rb b/app/controllers/ticket_articles_controller.rb
index 448b642aa..626e8720a 100644
--- a/app/controllers/ticket_articles_controller.rb
+++ b/app/controllers/ticket_articles_controller.rb
@@ -45,7 +45,7 @@ class TicketArticlesController < ApplicationController
articles = []
if params[:expand]
- ticket.articles.each {|article|
+ ticket.articles.each { |article|
# ignore internal article if customer is requesting
next if article.internal == true && role?(Z_ROLENAME_CUSTOMER)
@@ -64,7 +64,7 @@ class TicketArticlesController < ApplicationController
if params[:full]
assets = {}
record_ids = []
- ticket.articles.each {|article|
+ ticket.articles.each { |article|
# ignore internal article if customer is requesting
next if article.internal == true && role?(Z_ROLENAME_CUSTOMER)
@@ -79,7 +79,7 @@ class TicketArticlesController < ApplicationController
return
end
- ticket.articles.each {|article|
+ ticket.articles.each { |article|
# ignore internal article if customer is requesting
next if article.internal == true && role?(Z_ROLENAME_CUSTOMER)
@@ -220,7 +220,7 @@ class TicketArticlesController < ApplicationController
list = article.attachments || []
access = false
- list.each {|item|
+ list.each { |item|
if item.id.to_i == params[:id].to_i
access = true
end
diff --git a/app/controllers/ticket_overviews_controller.rb b/app/controllers/ticket_overviews_controller.rb
index 69c471809..6c2012a8f 100644
--- a/app/controllers/ticket_overviews_controller.rb
+++ b/app/controllers/ticket_overviews_controller.rb
@@ -36,7 +36,7 @@ class TicketOverviewsController < ApplicationController
overview = Overview.lookup(id: index[:overview][:id])
assets = overview.assets(assets)
- index[:tickets].each {|ticket_meta|
+ index[:tickets].each { |ticket_meta|
ticket = Ticket.lookup(id: ticket_meta[:id])
assets = ticket.assets(assets)
}
diff --git a/app/controllers/tickets_controller.rb b/app/controllers/tickets_controller.rb
index 79cb2040a..240eaf703 100644
--- a/app/controllers/tickets_controller.rb
+++ b/app/controllers/tickets_controller.rb
@@ -18,7 +18,7 @@ class TicketsController < ApplicationController
if params[:expand]
list = []
- tickets.each {|ticket|
+ tickets.each { |ticket|
list.push ticket.attributes_with_relation_names
}
render json: list, status: :ok
@@ -28,7 +28,7 @@ class TicketsController < ApplicationController
if params[:full]
assets = {}
item_ids = []
- tickets.each {|item|
+ tickets.each { |item|
item_ids.push item.id
assets = item.assets(assets)
}
@@ -90,7 +90,7 @@ class TicketsController < ApplicationController
# create tags if given
if params[:tags] && !params[:tags].empty?
tags = params[:tags].split(/,/)
- tags.each {|tag|
+ tags.each { |tag|
Tag.tag_add(
object: 'Ticket',
o_id: ticket.id,
@@ -215,14 +215,14 @@ class TicketsController < ApplicationController
# get related assets
ticket_ids_by_customer = []
- ticket_lists.each {|ticket_list|
+ ticket_lists.each { |ticket_list|
ticket_ids_by_customer.push ticket_list.id
assets = ticket_list.assets(assets)
}
ticket_ids_recent_viewed = []
recent_views = RecentView.list(current_user, 8, 'Ticket')
- recent_views.each {|recent_view|
+ recent_views.each { |recent_view|
next if recent_view['object'] != 'Ticket'
ticket_ids_recent_viewed.push recent_view['o_id']
recent_view_ticket = Ticket.find(recent_view['o_id'])
@@ -332,7 +332,7 @@ class TicketsController < ApplicationController
if params[:expand]
list = []
- tickets.each {|ticket|
+ tickets.each { |ticket|
list.push ticket.attributes_with_relation_names
}
render json: list, status: :ok
@@ -433,7 +433,7 @@ class TicketsController < ApplicationController
user_tickets_closed_ids = assets_of_tickets(user_tickets_closed, assets)
# generate stats by user
- (0..11).each {|month_back|
+ (0..11).each { |month_back|
date_to_check = now - month_back.month
date_start = "#{date_to_check.year}-#{date_to_check.month}-01 00:00:00"
date_end = "#{date_to_check.year}-#{date_to_check.month}-#{date_to_check.end_of_month.day} 00:00:00"
@@ -507,7 +507,7 @@ class TicketsController < ApplicationController
org_tickets_closed_ids = assets_of_tickets(org_tickets_closed, assets)
# generate stats by org
- (0..11).each {|month_back|
+ (0..11).each { |month_back|
date_to_check = now - month_back.month
date_start = "#{date_to_check.year}-#{date_to_check.month}-01 00:00:00"
date_end = "#{date_to_check.year}-#{date_to_check.month}-#{date_to_check.end_of_month.day} 00:00:00"
@@ -624,7 +624,7 @@ class TicketsController < ApplicationController
# get related users
article_ids = []
- articles.each {|article|
+ articles.each { |article|
# ignore internal article if customer is requesting
next if article.internal == true && role?(Z_ROLENAME_CUSTOMER)
diff --git a/app/controllers/user_devices_controller.rb b/app/controllers/user_devices_controller.rb
index f57f3a572..3b9c9a3da 100644
--- a/app/controllers/user_devices_controller.rb
+++ b/app/controllers/user_devices_controller.rb
@@ -6,7 +6,7 @@ class UserDevicesController < ApplicationController
def index
devices = UserDevice.where(user_id: current_user.id).order('updated_at DESC, name ASC')
devices_full = []
- devices.each {|device|
+ devices.each { |device|
attributes = device.attributes
if device.location_details['city_name'] && !device.location_details['city_name'].empty?
attributes['location'] += ", #{device.location_details['city_name']}"
@@ -30,7 +30,7 @@ class UserDevicesController < ApplicationController
# delete device and session's
if user_device
- SessionHelper.list.each {|session|
+ SessionHelper.list.each { |session|
next if !session.data['user_id']
next if !session.data['user_device_id']
next if session.data['user_device_id'] != user_device.id
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 23a12fb82..67836bcaf 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -29,7 +29,7 @@ class UsersController < ApplicationController
if params[:expand]
list = []
- users.each {|user|
+ users.each { |user|
list.push user.attributes_with_relation_names
}
render json: list, status: :ok
@@ -39,7 +39,7 @@ class UsersController < ApplicationController
if params[:full]
assets = {}
item_ids = []
- users.each {|item|
+ users.each { |item|
item_ids.push item.id
assets = item.assets(assets)
}
@@ -51,7 +51,7 @@ class UsersController < ApplicationController
end
users_all = []
- users.each {|user|
+ users.each { |user|
users_all.push User.lookup(id: user.id).attributes_with_associations
}
render json: users_all, status: :ok
@@ -341,7 +341,7 @@ class UsersController < ApplicationController
if params[:expand]
list = []
- user_all.each {|user|
+ user_all.each { |user|
list.push user.attributes_with_relation_names
}
render json: list, status: :ok
@@ -753,7 +753,7 @@ curl http://localhost/api/v1/users/preferences.json -v -u #{login}:#{password} -
if params[:user]
user = User.find(current_user.id)
- params[:user].each {|key, value|
+ params[:user].each { |key, value|
user.preferences[key.to_sym] = value
}
user.save
@@ -954,7 +954,7 @@ curl http://localhost/api/v1/users/avatar -v -u #{login}:#{password} -H "Content
if params[:role_ids].class != Array
params[:role_ids] = [params[:role_ids]]
end
- params[:role_ids].each {|role_id|
+ params[:role_ids].each { |role_id|
role_local = Role.lookup(id: role_id)
if !role_local
logger.info "Invalid role_ids for current_user_id: #{current_user.id} role_ids #{role_id}"
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
deleted file mode 100644
index 02ca60ce6..000000000
--- a/app/helpers/application_helper.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
-
-module ApplicationHelper
- def inline_svg(path)
- File.open("public/assets/images/#{path}", 'rb') do |file|
- raw file.read
- end
- end
-end
diff --git a/app/helpers/posts_helper.rb b/app/helpers/posts_helper.rb
deleted file mode 100644
index b8a3288db..000000000
--- a/app/helpers/posts_helper.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
-
-module PostsHelper
-end
diff --git a/app/models/application_model.rb b/app/models/application_model.rb
index 0d4ba0e14..f05412853 100644
--- a/app/models/application_model.rb
+++ b/app/models/application_model.rb
@@ -80,7 +80,7 @@ returns
end
data = {}
- params.each {|key, value|
+ params.each { |key, value|
data[key.to_sym] = value
}
@@ -91,7 +91,7 @@ returns
# only use object attributes
clean_params = {}
- new.attributes.each {|attribute, _value|
+ new.attributes.each { |attribute, _value|
next if !data.key?(attribute.to_sym)
clean_params[attribute.to_sym] = data[attribute.to_sym]
}
@@ -125,7 +125,7 @@ returns
list_of_items = [ params[real_ids] ]
end
list = []
- list_of_items.each {|item_id|
+ list_of_items.each { |item_id|
next if !item_id
lookup = assoc.klass.lookup(id: item_id)
@@ -150,7 +150,7 @@ returns
next if params[real_values].class != Array
list = []
class_object = assoc.klass
- params[real_values].each {|value|
+ params[real_values].each { |value|
lookup = nil
if class_object == User
if !lookup
@@ -222,7 +222,7 @@ returns
next if !ref
if ref.respond_to?(:first)
attributes[assoc.name.to_s] = []
- ref.each {|item|
+ ref.each { |item|
if item[:login]
attributes[assoc.name.to_s].push item[:login]
next
@@ -247,7 +247,7 @@ returns
{
'created_by_id' => 'created_by',
'updated_by_id' => 'updated_by',
- }.each {|source, destination|
+ }.each { |source, destination|
next if !attributes[source]
user = User.lookup(id: attributes[source])
next if !user
@@ -255,7 +255,7 @@ returns
}
# remove forbitten attributes
- %w(password token tokens token_ids).each {|item|
+ %w(password token tokens token_ids).each { |item|
attributes.delete(item)
}
@@ -277,7 +277,7 @@ returns
def self.param_validation(data)
# we do want to set this via database
- [:action, :controller, :updated_at, :created_at, :updated_by_id, :created_by_id, :updated_by, :created_by].each {|key|
+ [:action, :controller, :updated_at, :created_at, :updated_by_id, :created_by_id, :updated_by, :created_by].each { |key|
data.delete(key)
}
@@ -317,7 +317,7 @@ returns
def self.param_association_lookup(params)
data = {}
- params.each {|key, value|
+ params.each { |key, value|
data[key.to_sym] = value
}
@@ -376,7 +376,7 @@ returns
# get association class and do lookup
class_object = assoc.klass
lookup_ids = []
- value.each {|item|
+ value.each { |item|
lookup = nil
if class_object == User
if item.class == String
@@ -528,7 +528,7 @@ returns
def self.genrate_uniq_name(name)
return name if !find_by(name: name)
- (1..100).each {|counter|
+ (1..100).each { |counter|
name = "#{name}_#{counter}"
exists = find_by(name: name)
next if exists
@@ -570,7 +570,7 @@ returns
else
where(name: data[:name])
end
- records.each {|loop_record|
+ records.each { |loop_record|
if loop_record.name == data[:name]
cache_set(data[:name], loop_record)
return loop_record
@@ -587,7 +587,7 @@ returns
else
where(login: data[:login])
end
- records.each {|loop_record|
+ records.each { |loop_record|
if loop_record.login == data[:login]
cache_set(data[:login], loop_record)
return loop_record
@@ -604,7 +604,7 @@ returns
else
where(email: data[:email])
end
- records.each {|loop_record|
+ records.each { |loop_record|
if loop_record.email == data[:email]
cache_set(data[:email], loop_record)
return loop_record
@@ -640,7 +640,7 @@ returns
else
where(name: data[:name])
end
- records.each {|loop_record|
+ records.each { |loop_record|
return loop_record if loop_record.name == data[:name]
}
elsif data[:login]
@@ -651,7 +651,7 @@ returns
else
where(login: data[:login])
end
- records.each {|loop_record|
+ records.each { |loop_record|
return loop_record if loop_record.login == data[:login]
}
elsif data[:email]
@@ -662,7 +662,7 @@ returns
else
where(email: data[:email])
end
- records.each {|loop_record|
+ records.each { |loop_record|
return loop_record if loop_record.email == data[:email]
}
elsif data[:locale] && data[:source]
@@ -673,7 +673,7 @@ returns
else
where(locale: data[:locale], source: data[:source])
end
- records.each {|loop_record|
+ records.each { |loop_record|
return loop_record if loop_record.source == data[:source]
}
end
@@ -727,7 +727,7 @@ returns
else
where(name: data[:name])
end
- records.each {|loop_record|
+ records.each { |loop_record|
if loop_record.name == data[:name]
loop_record.update_attributes(data)
return loop_record
@@ -744,7 +744,7 @@ returns
else
where(login: data[:login])
end
- records.each {|loop_record|
+ records.each { |loop_record|
if loop_record.login.casecmp(data[:login]).zero?
loop_record.update_attributes(data)
return loop_record
@@ -761,7 +761,7 @@ returns
else
where(email: data[:email])
end
- records.each {|loop_record|
+ records.each { |loop_record|
if loop_record.email.casecmp(data[:email]).zero?
loop_record.update_attributes(data)
return loop_record
@@ -778,7 +778,7 @@ returns
else
where(locale: data[:locale])
end
- records.each {|loop_record|
+ records.each { |loop_record|
if loop_record.locale.casecmp(data[:locale]).zero?
loop_record.update_attributes(data)
return loop_record
@@ -1130,13 +1130,13 @@ log object update activity stream, if configured - will be executed automaticall
updated_by_id: true,
}
if self.class.activity_stream_support_config[:ignore_attributes]
- self.class.activity_stream_support_config[:ignore_attributes].each {|key, value|
+ self.class.activity_stream_support_config[:ignore_attributes].each { |key, value|
ignore_attributes[key] = value
}
end
log = false
- changes.each {|key, _value|
+ changes.each { |key, _value|
# do not log created_at and updated_at attributes
next if ignore_attributes[key.to_sym] == true
@@ -1217,7 +1217,7 @@ log object update history with all updated attributes, if configured - will be e
# new record also triggers update, so ignore new records
changes = self.changes
if history_changes_last_done
- history_changes_last_done.each {|key, value|
+ history_changes_last_done.each { |key, value|
if changes.key?(key) && changes[key] == value
changes.delete(key)
end
@@ -1236,12 +1236,12 @@ log object update history with all updated attributes, if configured - will be e
updated_by_id: true,
}
if self.class.history_support_config[:ignore_attributes]
- self.class.history_support_config[:ignore_attributes].each {|key, value|
+ self.class.history_support_config[:ignore_attributes].each { |key, value|
ignore_attributes[key] = value
}
end
- changes.each {|key, value|
+ changes.each { |key, value|
# do not log created_at and updated_at attributes
next if ignore_attributes[key.to_sym] == true
@@ -1384,7 +1384,7 @@ get assets of object list
=end
def self.assets_of_object_list(list, assets = {})
- list.each {|item|
+ list.each { |item|
require item['object'].to_filename
record = Kernel.const_get(item['object']).find(item['o_id'])
assets = record.assets(assets)
@@ -1414,7 +1414,7 @@ get assets and record_ids of selector
# get assets of condition
models = Models.all
- send(selector).each {|item, content|
+ send(selector).each { |item, content|
attribute = item.split(/\./)
next if !attribute[1]
begin
@@ -1431,7 +1431,7 @@ get assets and record_ids of selector
next if !models[attribute_class][:reflections][reflection].klass
attribute_ref_class = models[attribute_class][:reflections][reflection].klass
if content['value'].class == Array
- content['value'].each {|item_id|
+ content['value'].each { |item_id|
attribute_object = attribute_ref_class.find_by(id: item_id)
if attribute_object
assets = attribute_object.assets(assets)
@@ -1520,7 +1520,7 @@ check string/varchar size and cut them if needed
=end
def check_limits
- attributes.each {|attribute|
+ attributes.each { |attribute|
next if !self[ attribute[0] ]
next if self[ attribute[0] ].class != String
next if self[ attribute[0] ].empty?
diff --git a/app/models/application_model/assets.rb b/app/models/application_model/assets.rb
index 92b56d474..2fed16cbc 100644
--- a/app/models/application_model/assets.rb
+++ b/app/models/application_model/assets.rb
@@ -29,7 +29,7 @@ returns
end
return data if !self['created_by_id'] && !self['updated_by_id']
- %w(created_by_id updated_by_id).each {|local_user_id|
+ %w(created_by_id updated_by_id).each { |local_user_id|
next if !self[ local_user_id ]
next if data[ User.to_app_model ] && data[ User.to_app_model ][ self[ local_user_id ] ]
user = User.lookup(id: self[ local_user_id ])
diff --git a/app/models/application_model/history_log_base.rb b/app/models/application_model/history_log_base.rb
index 1e6f6df69..310c533cc 100644
--- a/app/models/application_model/history_log_base.rb
+++ b/app/models/application_model/history_log_base.rb
@@ -82,7 +82,7 @@ returns
# get related objects
history = History.list(self.class.name, self['id'], nil, true)
- history[:list].each {|item|
+ history[:list].each { |item|
record = Kernel.const_get(item['object']).find(item['o_id'])
history[:assets] = record.assets(history[:assets])
diff --git a/app/models/application_model/search_index_base.rb b/app/models/application_model/search_index_base.rb
index e3d501b79..b9d789ce6 100644
--- a/app/models/application_model/search_index_base.rb
+++ b/app/models/application_model/search_index_base.rb
@@ -20,7 +20,7 @@ returns
# default ignored attributes
ignore_attributes = {}
if self.class.search_index_support_config[:ignore_attributes]
- self.class.search_index_support_config[:ignore_attributes].each {|key, value|
+ self.class.search_index_support_config[:ignore_attributes].each { |key, value|
ignore_attributes[key] = value
}
end
@@ -31,7 +31,7 @@ returns
# remove ignored attributes
attributes = data.attributes
- ignore_attributes.each {|key, value|
+ ignore_attributes.each { |key, value|
next if value != true
attributes.delete(key.to_s)
}
@@ -86,7 +86,7 @@ returns
def search_index_attribute_lookup(attributes, ref_object)
attributes_new = {}
- attributes.each {|key, value|
+ attributes.each { |key, value|
next if !value
# get attribute name
diff --git a/app/models/calendar.rb b/app/models/calendar.rb
index d22f6bcbc..5335b7f07 100644
--- a/app/models/calendar.rb
+++ b/app/models/calendar.rb
@@ -157,7 +157,7 @@ returns
'Venezuela' => 'en.ve',
}
all_feeds = {}
- gfeeds.each {|key, name|
+ gfeeds.each { |key, name|
all_feeds["http://www.google.com/calendar/ical/#{name}%23holiday%40group.v.calendar.google.com/public/basic.ics"] = key
}
all_feeds
@@ -232,14 +232,14 @@ returns
end
# remove old ical entries if feed has changed
- public_holidays.each {|day, meta|
+ public_holidays.each { |day, meta|
next if !public_holidays[day]['feed']
next if meta['feed'] == Digest::MD5.hexdigest(ical_url)
public_holidays.delete(day)
}
# sync new ical feed dates
- events.each {|day, summary|
+ events.each { |day, summary|
if !public_holidays[day]
public_holidays[day] = {}
end
@@ -280,7 +280,7 @@ returns
cals = Icalendar.parse(cal_file)
cal = cals.first
events = {}
- cal.events.each {|event|
+ cal.events.each { |event|
next if event.dtstart < Time.zone.now - 1.year
next if event.dtstart > Time.zone.now + 3.years
day = "#{event.dtstart.year}-#{format('%02d', event.dtstart.month)}-#{format('%02d', event.dtstart.day)}"
@@ -302,7 +302,7 @@ returns
# if changed calendar is default, set all others default to false
def sync_default
return if !default
- Calendar.all.each {|calendar|
+ Calendar.all.each { |calendar|
next if calendar.id == id
next if !calendar.default
calendar.default = false
@@ -312,7 +312,7 @@ returns
# check if min one is set to default true
def min_one_check
- Calendar.all.each {|calendar|
+ Calendar.all.each { |calendar|
return true if calendar.default
}
first = Calendar.order(:created_at, :id).limit(1).first
@@ -320,7 +320,7 @@ returns
first.save
# check if sla's are refer to an existing calendar
- Sla.all.each {|sla|
+ Sla.all.each { |sla|
if !sla.calendar_id
sla.calendar_id = first.id
sla.save
@@ -342,7 +342,7 @@ returns
def validate_public_holidays
# fillup feed info
- public_holidays.each {|day, meta|
+ public_holidays.each { |day, meta|
if public_holidays_was && public_holidays_was[day] && public_holidays_was[day]['feed']
meta['feed'] = public_holidays_was[day]['feed']
end
diff --git a/app/models/channel.rb b/app/models/channel.rb
index 457ce5d16..c3c58fcc3 100644
--- a/app/models/channel.rb
+++ b/app/models/channel.rb
@@ -138,7 +138,7 @@ stream all accounts
logger.debug 'stream controll loop'
current_channels = []
channels = Channel.where('active = ? AND area LIKE ?', true, '%::Account')
- channels.each {|channel|
+ channels.each { |channel|
next if channel.options[:adapter] != 'twitter'
current_channels.push channel.id
@@ -181,7 +181,7 @@ stream all accounts
}
# cleanup deleted channels
- last_channels.each {|channel_id|
+ last_channels.each { |channel_id|
next if !@@channel_stream[channel_id]
next if current_channels.include?(channel_id)
logger.debug "channel (#{channel_id}) not longer active, stop thread"
diff --git a/app/models/channel/assets.rb b/app/models/channel/assets.rb
index e0e321000..6d7fe2220 100644
--- a/app/models/channel/assets.rb
+++ b/app/models/channel/assets.rb
@@ -38,7 +38,7 @@ returns
end
end
if !access
- %w(inbound outbound).each {|key|
+ %w(inbound outbound).each { |key|
if attributes['options'] && attributes['options'][key] && attributes['options'][key]['options']
attributes['options'][key]['options'].delete('password')
end
@@ -49,7 +49,7 @@ returns
end
return data if !self['created_by_id'] && !self['updated_by_id']
- %w(created_by_id updated_by_id).each {|local_user_id|
+ %w(created_by_id updated_by_id).each { |local_user_id|
next if !self[ local_user_id ]
next if data[ User.to_app_model ] && data[ User.to_app_model ][ self[ local_user_id ] ]
user = User.lookup(id: self[ local_user_id ])
diff --git a/app/models/channel/driver/facebook.rb b/app/models/channel/driver/facebook.rb
index 45d66eace..c7fff2561 100644
--- a/app/models/channel/driver/facebook.rb
+++ b/app/models/channel/driver/facebook.rb
@@ -24,7 +24,7 @@ class Channel::Driver::Facebook
def send(options, fb_object_id, article, _notification = false)
access_token = nil
- options['pages'].each {|page|
+ options['pages'].each { |page|
next if page['id'].to_s != fb_object_id.to_s
access_token = page['access_token']
}
@@ -52,7 +52,7 @@ class Channel::Driver::Facebook
private
def get_page(page_id)
- @pages.each {|page|
+ @pages.each { |page|
return page if page['id'].to_s == page_id.to_s
}
nil
@@ -62,7 +62,7 @@ class Channel::Driver::Facebook
return if !@sync
return if !@sync['pages']
- @sync['pages'].each {|page_to_sync_id, page_to_sync_params|
+ @sync['pages'].each { |page_to_sync_id, page_to_sync_params|
page = get_page(page_to_sync_id)
next if !page
next if !page_to_sync_params['group_id']
@@ -70,7 +70,7 @@ class Channel::Driver::Facebook
page_client = Facebook.new(page['access_token'])
posts = page_client.client.get_connection('me', 'feed', fields: 'id,from,to,message,created_time,comments')
- posts.each {|post|
+ posts.each { |post|
page_client.to_group(post, page_to_sync_params['group_id'], @channel, page)
}
}
diff --git a/app/models/channel/driver/twitter.rb b/app/models/channel/driver/twitter.rb
index fe3ceb3d8..083f85e0a 100644
--- a/app/models/channel/driver/twitter.rb
+++ b/app/models/channel/driver/twitter.rb
@@ -189,7 +189,7 @@ returns
filter = {}
if sync['search']
hashtags = []
- sync['search'].each {|item|
+ sync['search'].each { |item|
hashtags.push item['term']
}
filter[:track] = hashtags.join(',')
@@ -219,7 +219,7 @@ returns
if sync['mentions'] && sync['mentions']['group_id'] != ''
hit = false
if tweet.user_mentions
- tweet.user_mentions.each {|user|
+ tweet.user_mentions.each { |user|
if user.id.to_s == @channel.options['user']['id'].to_s
hit = true
end
@@ -234,8 +234,8 @@ returns
# check hashtags
if sync['search'] && tweet.hashtags
hit = false
- sync['search'].each {|item|
- tweet.hashtags.each {|hashtag|
+ sync['search'].each { |item|
+ tweet.hashtags.each { |hashtag|
next if item['term'] !~ /^#/
if item['term'].sub(/^#/, '') == hashtag.text
hit = item
@@ -252,7 +252,7 @@ returns
if sync['search']
hit = false
body = tweet.text
- sync['search'].each {|item|
+ sync['search'].each { |item|
next if item['term'] =~ /^#/
if body =~ /#{item['term']}/
hit = item
diff --git a/app/models/channel/email_parser.rb b/app/models/channel/email_parser.rb
index 832f3dc31..d307d6dec 100644
--- a/app/models/channel/email_parser.rb
+++ b/app/models/channel/email_parser.rb
@@ -280,7 +280,7 @@ class Channel::EmailParser
# check if sub parts are available
if !file.parts.empty?
a = []
- file.parts.each {|p|
+ file.parts.each { |p|
attachment = _get_attachment(p, attachments, mail)
a.concat(attachment)
}
@@ -324,10 +324,10 @@ class Channel::EmailParser
# generate file name
if !filename || filename.empty?
attachment_count = 0
- (1..1000).each {|count|
+ (1..1000).each { |count|
filename_exists = false
filename = 'file-' + count.to_s
- attachments.each {|attachment|
+ attachments.each { |attachment|
if attachment[:filename] == filename
filename_exists = true
end
@@ -394,10 +394,10 @@ retrns
# run postmaster pre filter
UserInfo.current_user_id = 1
filters = {}
- Setting.where(area: 'Postmaster::PreFilter').order(:name).each {|setting|
+ Setting.where(area: 'Postmaster::PreFilter').order(:name).each { |setting|
filters[setting.name] = Kernel.const_get(Setting.get(setting.name))
}
- filters.each {|_prio, backend|
+ filters.each { |_prio, backend|
Rails.logger.debug "run postmaster pre filter #{backend}"
begin
backend.run(channel, mail)
@@ -550,10 +550,10 @@ retrns
# run postmaster post filter
filters = {}
- Setting.where(area: 'Postmaster::PostFilter').order(:name).each {|setting|
+ Setting.where(area: 'Postmaster::PostFilter').order(:name).each { |setting|
filters[setting.name] = Kernel.const_get(Setting.get(setting.name))
}
- filters.each {|_prio, backend|
+ filters.each { |_prio, backend|
Rails.logger.debug "run postmaster post filter #{backend}"
begin
backend.run(channel, mail, ticket, article, user)
@@ -570,7 +570,7 @@ retrns
def set_attributes_by_x_headers(item_object, header_name, mail, suffix = false)
# 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_by_id'
diff --git a/app/models/channel/filter/bounce_check.rb b/app/models/channel/filter/bounce_check.rb
index 80c988ae4..f657bb3b5 100644
--- a/app/models/channel/filter/bounce_check.rb
+++ b/app/models/channel/filter/bounce_check.rb
@@ -9,7 +9,7 @@ module Channel::Filter::BounceCheck
return if !mail[:attachments]
return if mail[ 'x-zammad-ticket-id'.to_sym ]
- mail[:attachments].each {|attachment|
+ mail[:attachments].each { |attachment|
next if !attachment[:preferences]
next if attachment[:preferences]['Mime-Type'] != 'message/rfc822'
next if !attachment[:data]
diff --git a/app/models/channel/filter/database.rb b/app/models/channel/filter/database.rb
index da66dd579..fae850f29 100644
--- a/app/models/channel/filter/database.rb
+++ b/app/models/channel/filter/database.rb
@@ -7,11 +7,11 @@ module Channel::Filter::Database
# process postmaster filter
filters = PostmasterFilter.where( active: true, channel: 'email' ).order(:name, :created_at)
- filters.each {|filter|
+ filters.each { |filter|
Rails.logger.info " proccess filter #{filter.name} ..."
all_matches_ok = true
min_one_rule_exists = false
- filter[:match].each {|key, meta|
+ filter[:match].each { |key, meta|
begin
next if !meta || !meta['value'] || meta['value'].empty?
min_one_rule_exists = true
@@ -41,7 +41,7 @@ module Channel::Filter::Database
next if !min_one_rule_exists
next if !all_matches_ok
- filter[:perform].each {|key, meta|
+ filter[:perform].each { |key, meta|
Rails.logger.info " perform '#{key.downcase}' = '#{meta.inspect}'"
mail[ key.downcase.to_sym ] = meta['value']
}
diff --git a/app/models/channel/filter/follow_up_check.rb b/app/models/channel/filter/follow_up_check.rb
index cdb522363..5c9478d8c 100644
--- a/app/models/channel/filter/follow_up_check.rb
+++ b/app/models/channel/filter/follow_up_check.rb
@@ -28,7 +28,7 @@ module Channel::Filter::FollowUpCheck
# get ticket# from attachment
if setting.include?('attachment') && mail[:attachments]
- mail[:attachments].each {|attachment|
+ mail[:attachments].each { |attachment|
next if !attachment[:data]
ticket = Ticket::Number.check(attachment[:data])
next if !ticket
@@ -54,7 +54,7 @@ module Channel::Filter::FollowUpCheck
end
if references != ''
message_ids = references.split(/\s+/)
- message_ids.each {|message_id|
+ message_ids.each { |message_id|
message_id_md5 = Digest::MD5.hexdigest(message_id)
article = Ticket::Article.where(message_id_md5: message_id_md5).order('created_at DESC, id DESC').limit(1).first
next if !article
diff --git a/app/models/channel/filter/identify_sender.rb b/app/models/channel/filter/identify_sender.rb
index 0ebfe310a..369a5c495 100644
--- a/app/models/channel/filter/identify_sender.rb
+++ b/app/models/channel/filter/identify_sender.rb
@@ -47,7 +47,7 @@ module Channel::Filter::IdentifySender
begin
next if !mail[item.to_sym].addrs
items = mail[item.to_sym].addrs
- items.each {|address_data|
+ items.each { |address_data|
user_create(
firstname: address_data.display_name,
lastname: '',
@@ -60,7 +60,7 @@ module Channel::Filter::IdentifySender
Rails.logger.error 'ERROR: ' + e.inspect
Rails.logger.error 'ERROR: try it by my self'
recipients = mail[item.to_sym].to_s.split(',')
- recipients.each {|recipient|
+ recipients.each { |recipient|
address = nil
display_name = nil
if recipient =~ /<(.+?)>/
diff --git a/app/models/channel/filter/monitoring_base.rb b/app/models/channel/filter/monitoring_base.rb
index cc8ca116e..31b8b6b06 100644
--- a/app/models/channel/filter/monitoring_base.rb
+++ b/app/models/channel/filter/monitoring_base.rb
@@ -47,7 +47,7 @@ class Channel::Filter::MonitoringBase
# follow up detection by meta data
open_states = Ticket::State.by_category('open')
- Ticket.where(state: open_states).each {|ticket|
+ Ticket.where(state: open_states).each { |ticket|
next if !ticket.preferences
next if !ticket.preferences['integration']
next if ticket.preferences['integration'] != integration
@@ -77,7 +77,7 @@ class Channel::Filter::MonitoringBase
preferences = {}
preferences['integration'] = integration
preferences[integration] = result
- preferences.each {|key, value|
+ preferences.each { |key, value|
mail[ 'x-zammad-ticket-preferences'.to_sym ][key] = value
}
end
diff --git a/app/models/channel/filter/trusted.rb b/app/models/channel/filter/trusted.rb
index 66b60ead9..f03e5fcf6 100644
--- a/app/models/channel/filter/trusted.rb
+++ b/app/models/channel/filter/trusted.rb
@@ -7,7 +7,7 @@ module Channel::Filter::Trusted
# check if trust x-headers
if !channel[:trusted]
- mail.each {|key, _value|
+ mail.each { |key, _value|
next if key !~ /^x-zammad/i
mail.delete(key)
}
diff --git a/app/models/chat.rb b/app/models/chat.rb
index ee0320cd6..8aadf00df 100644
--- a/app/models/chat.rb
+++ b/app/models/chat.rb
@@ -65,16 +65,16 @@ class Chat < ApplicationModel
def self.agent_state(user_id)
return { state: 'chat_disabled' } if !Setting.get('chat')
assets = {}
- Chat.where(active: true).each {|chat|
+ Chat.where(active: true).each { |chat|
assets = chat.assets(assets)
}
active_agent_ids = []
- active_agents.each {|user|
+ active_agents.each { |user|
active_agent_ids.push user.id
assets = user.assets(assets)
}
runningchat_session_list_local = running_chat_session_list
- runningchat_session_list_local.each {|session|
+ runningchat_session_list_local.each { |session|
next if !session['user_id']
user = User.lookup(id: session['user_id'])
next if !user
@@ -107,7 +107,7 @@ class Chat < ApplicationModel
def self.waiting_chat_session_list
sessions = []
- Chat::Session.where(state: ['waiting']).each {|session|
+ Chat::Session.where(state: ['waiting']).each { |session|
sessions.push session.attributes
}
sessions
@@ -119,7 +119,7 @@ class Chat < ApplicationModel
def self.running_chat_session_list
sessions = []
- Chat::Session.where(state: ['running']).each {|session|
+ Chat::Session.where(state: ['running']).each { |session|
sessions.push session.attributes
}
sessions
@@ -131,7 +131,7 @@ class Chat < ApplicationModel
def self.available_agents(diff = 2.minutes)
agents = {}
- Chat::Agent.where(active: true).where('updated_at > ?', Time.zone.now - diff).each {|record|
+ Chat::Agent.where(active: true).where('updated_at > ?', Time.zone.now - diff).each { |record|
agents[record.updated_by_id] = record.concurrent
}
agents
@@ -143,7 +143,7 @@ class Chat < ApplicationModel
def self.active_agents(diff = 2.minutes)
users = []
- Chat::Agent.where(active: true).where('updated_at > ?', Time.zone.now - diff).each {|record|
+ Chat::Agent.where(active: true).where('updated_at > ?', Time.zone.now - diff).each { |record|
user = User.lookup(id: record.updated_by_id)
next if !user
users.push user
@@ -153,7 +153,7 @@ class Chat < ApplicationModel
def self.seads_total(diff = 2.minutes)
total = 0
- available_agents(diff).each {|_user_id, concurrent|
+ available_agents(diff).each { |_user_id, concurrent|
total += concurrent
}
total
@@ -178,7 +178,7 @@ optional you can ignore it for dedecated user
def self.broadcast_agent_state_update(ignore_user_id = nil)
# send broadcast to agents
- Chat::Agent.where('active = ? OR updated_at > ?', true, Time.zone.now - 8.hours).each {|item|
+ Chat::Agent.where('active = ? OR updated_at > ?', true, Time.zone.now - 8.hours).each { |item|
next if item.updated_by_id == ignore_user_id
data = {
event: 'chat_status_agent',
@@ -200,7 +200,7 @@ broadcast new customer queue position to all waiting customers
# send position update to other waiting sessions
position = 0
- Chat::Session.where(state: 'waiting').order('created_at ASC').each {|local_chat_session|
+ Chat::Session.where(state: 'waiting').order('created_at ASC').each { |local_chat_session|
position += 1
data = {
event: 'chat_session_queue',
@@ -227,7 +227,7 @@ optional you can parse the max oldest chat entries
=end
def self.cleanup(diff = 3.months)
- Chat::Session.where(state: 'closed').where('updated_at < ?', Time.zone.now - diff).each {|chat_session|
+ Chat::Session.where(state: 'closed').where('updated_at < ?', Time.zone.now - diff).each { |chat_session|
Chat::Message.where(chat_session_id: chat_session.id).delete_all
chat_session.destroy
}
@@ -248,7 +248,7 @@ optional you can parse the max oldest chat sessions
=end
def self.cleanup_close(diff = 5.minutes)
- Chat::Session.where.not(state: 'closed').where('updated_at < ?', Time.zone.now - diff).each {|chat_session|
+ Chat::Session.where.not(state: 'closed').where('updated_at < ?', Time.zone.now - diff).each { |chat_session|
next if chat_session.recipients_active?
chat_session.state = 'closed'
chat_session.save
diff --git a/app/models/chat/session.rb b/app/models/chat/session.rb
index 3742bee69..14d5a2d91 100644
--- a/app/models/chat/session.rb
+++ b/app/models/chat/session.rb
@@ -22,7 +22,7 @@ class Chat::Session < ApplicationModel
return true if !preferences
return true if !preferences[:participants]
count = 0
- preferences[:participants].each {|client_id|
+ preferences[:participants].each { |client_id|
next if !Sessions.session_exists?(client_id)
count += 1
}
@@ -31,7 +31,7 @@ class Chat::Session < ApplicationModel
end
def send_to_recipients(message, ignore_client_id = nil)
- preferences[:participants].each {|local_client_id|
+ preferences[:participants].each { |local_client_id|
next if local_client_id == ignore_client_id
Sessions.send(local_client_id, message)
}
@@ -41,7 +41,7 @@ class Chat::Session < ApplicationModel
def position
return if state != 'waiting'
position = 0
- Chat::Session.where(state: 'waiting').order('created_at ASC').each {|chat_session|
+ Chat::Session.where(state: 'waiting').order('created_at ASC').each { |chat_session|
position += 1
break if chat_session.id == id
}
@@ -60,7 +60,7 @@ class Chat::Session < ApplicationModel
def self.active_chats_by_user_id(user_id)
actice_sessions = []
- Chat::Session.where(state: 'running', user_id: user_id).order('created_at ASC').each {|session|
+ Chat::Session.where(state: 'running', user_id: user_id).order('created_at ASC').each { |session|
session_attributes = session.attributes
session_attributes['messages'] = []
Chat::Message.where(chat_session_id: session.id).each { |message|
diff --git a/app/models/cti/caller_id.rb b/app/models/cti/caller_id.rb
index e3bd75335..f016d7d42 100644
--- a/app/models/cti/caller_id.rb
+++ b/app/models/cti/caller_id.rb
@@ -79,7 +79,7 @@ returns
map = config
level = nil
model = nil
- map.each {|item|
+ map.each { |item|
next if item[:model] != record.class
level = item[:level]
model = item[:model]
@@ -114,7 +114,7 @@ returns
# get caller ids
caller_ids = []
attributes = record.attributes
- attributes.each {|_attribute, value|
+ attributes.each { |_attribute, value|
next if value.class != String
next if value.empty?
local_caller_ids = Cti::CallerId.parse_text(value)
@@ -124,7 +124,7 @@ returns
# store caller ids
Cti::CallerId.where(object: model.to_s, o_id: record.id).destroy_all
- caller_ids.each {|caller_id|
+ caller_ids.each { |caller_id|
Cti::CallerId.maybe_add(
caller_id: caller_id,
level: level,
@@ -145,7 +145,7 @@ returns
def self.rebuild
Cti::CallerId.delete_all
map = config
- map.each {|item|
+ map.each { |item|
level = item[:level]
model = item[:model]
item[:model].find_each(batch_size: 500) do |record|
diff --git a/app/models/cti/log.rb b/app/models/cti/log.rb
index d72de8ce0..5b8ddfc1f 100644
--- a/app/models/cti/log.rb
+++ b/app/models/cti/log.rb
@@ -235,11 +235,11 @@ returns
# add assets
assets = {}
- list.each {|item|
+ list.each { |item|
next if !item.preferences
- %w(from to).each {|direction|
+ %w(from to).each { |direction|
next if !item.preferences[direction]
- item.preferences[direction].each {|caller_id|
+ item.preferences[direction].each { |caller_id|
next if !caller_id['user_id']
user = User.lookup(id: caller_id['user_id'])
next if !user
@@ -256,7 +256,7 @@ returns
def push_event
users = User.of_role('CTI')
- users.each {|user|
+ users.each { |user|
# send notify about event
Sessions.send_to(
@@ -273,7 +273,7 @@ returns
list = Cti::Log.log
users = User.of_role('CTI')
- users.each {|user|
+ users.each { |user|
# send notify on create/update/delete
Sessions.send_to(
diff --git a/app/models/email_address.rb b/app/models/email_address.rb
index 74bba6007..7783ec819 100644
--- a/app/models/email_address.rb
+++ b/app/models/email_address.rb
@@ -23,7 +23,7 @@ check and if channel not exists reset configured channels for email addresses
=end
def self.channel_cleanup
- EmailAddress.all.each {|email_address|
+ EmailAddress.all.each { |email_address|
# set to active if channel exists
if email_address.channel_id && Channel.find_by(id: email_address.channel_id)
diff --git a/app/models/job/assets.rb b/app/models/job/assets.rb
index 620fb3914..3719b6211 100644
--- a/app/models/job/assets.rb
+++ b/app/models/job/assets.rb
@@ -34,7 +34,7 @@ returns
data = assets_of_selector('condition', data)
data = assets_of_selector('perform', data)
end
- %w(created_by_id updated_by_id).each {|local_user_id|
+ %w(created_by_id updated_by_id).each { |local_user_id|
next if !self[ local_user_id ]
next if data[ User.to_app_model ][ self[ local_user_id ] ]
user = User.lookup(id: self[ local_user_id ])
diff --git a/app/models/link.rb b/app/models/link.rb
index 76178eafa..f20faab82 100644
--- a/app/models/link.rb
+++ b/app/models/link.rb
@@ -140,7 +140,7 @@ class Link < ApplicationModel
)
# touch references
- links.each {|link|
+ links.each { |link|
link.destroy
touch_reference_by_params(
object: Link::Object.lookup(id: link.link_object_source_id).name,
@@ -166,7 +166,7 @@ class Link < ApplicationModel
)
# touch references
- links.each {|link|
+ links.each { |link|
link.destroy
touch_reference_by_params(
object: Link::Object.lookup(id: link.link_object_source_id).name,
diff --git a/app/models/locale.rb b/app/models/locale.rb
index 7332ea10f..adf138c0d 100644
--- a/app/models/locale.rb
+++ b/app/models/locale.rb
@@ -30,7 +30,7 @@ class Locale < ApplicationModel
raise "Can't load locales from #{url}: #{result.error}" if !result.success?
ActiveRecord::Base.transaction do
- result.data.each {|locale|
+ result.data.each { |locale|
exists = Locale.find_by(locale: locale['locale'])
if exists
exists.update(locale.symbolize_keys!)
diff --git a/app/models/object_manager/attribute.rb b/app/models/object_manager/attribute.rb
index 23f0fa926..bd8c5b6d5 100644
--- a/app/models/object_manager/attribute.rb
+++ b/app/models/object_manager/attribute.rb
@@ -27,7 +27,7 @@ list of all attributes
result = ObjectManager::Attribute.all.order('position ASC, name ASC')
attributes = []
assets = {}
- result.each {|item|
+ result.each { |item|
attribute = item.attributes
attribute[:object] = ObjectLookup.by_id(item.object_lookup_id)
attribute.delete('object_lookup_id')
@@ -240,7 +240,7 @@ possible types
end
# update attributes
- data.each {|key, value|
+ data.each { |key, value|
record[key.to_sym] = value
}
@@ -376,7 +376,7 @@ returns:
to_delete: false,
).order('position ASC, name ASC')
attributes = []
- result.each {|item|
+ result.each { |item|
data = {
name: item.name,
display: item.display,
@@ -385,9 +385,9 @@ returns:
}
if item.screens
data[:screen] = {}
- item.screens.each {|screen, roles_options|
+ item.screens.each { |screen, roles_options|
data[:screen][screen] = {}
- roles_options.each {|role, options|
+ roles_options.each { |role, options|
if role == '-all-'
data[:screen][screen] = options
elsif user && user.role?(role)
@@ -423,7 +423,7 @@ returns:
def self.by_object_as_hash(object, user)
list = by_object(object, user)
hash = {}
- list.each {|item|
+ list.each { |item|
hash[ item[:name] ] = item
}
hash
@@ -443,7 +443,7 @@ returns
def self.discard_changes
ObjectManager::Attribute.where('to_create = ?', true).each(&:destroy)
- ObjectManager::Attribute.where('to_delete = ? OR to_config = ?', true, true).each {|attribute|
+ ObjectManager::Attribute.where('to_delete = ? OR to_config = ?', true, true).each { |attribute|
attribute.to_migrate = false
attribute.to_delete = false
attribute.to_config = false
@@ -507,7 +507,7 @@ to send no browser reload event, pass false
# check if field already exists
execute_db_count = 0
execute_config_count = 0
- migrations.each {|attribute|
+ migrations.each { |attribute|
model = Kernel.const_get(attribute.object_lookup.name)
# remove field
@@ -701,7 +701,7 @@ to send no browser reload event, pass false
end
if data_type == 'integer'
- [:min, :max].each {|item|
+ [:min, :max].each { |item|
raise "Need data_option[#{item.inspect}] param" if !data_option[item]
raise "Invalid data_option[#{item.inspect}] param #{data_option[item]}" if data_option[item].to_s !~ /^\d+?$/
}
diff --git a/app/models/observer/organization/ref_object_touch.rb b/app/models/observer/organization/ref_object_touch.rb
index 84c617edf..b97009e6c 100644
--- a/app/models/observer/organization/ref_object_touch.rb
+++ b/app/models/observer/organization/ref_object_touch.rb
@@ -24,7 +24,7 @@ class Observer::Organization::RefObjectTouch < ActiveRecord::Observer
Ticket.select('id').where( organization_id: record.id ).each(&:touch)
# touch current members
- record.member_ids.uniq.each {|user_id|
+ record.member_ids.uniq.each { |user_id|
User.find(user_id).touch
}
end
diff --git a/app/models/observer/sla/ticket_rebuild_escalation.rb b/app/models/observer/sla/ticket_rebuild_escalation.rb
index df91dcbc2..466d10432 100644
--- a/app/models/observer/sla/ticket_rebuild_escalation.rb
+++ b/app/models/observer/sla/ticket_rebuild_escalation.rb
@@ -31,7 +31,7 @@ class Observer::Sla::TicketRebuildEscalation < ActiveRecord::Observer
# check if condition has changed
changed = false
- %w(condition calendar_id first_response_time update_time solution_time).each {|item|
+ %w(condition calendar_id first_response_time update_time solution_time).each { |item|
next if !record.changes[item]
next if record.changes[item][0] == record.changes[item][1]
changed = true
diff --git a/app/models/observer/ticket/article/communicate_twitter/background_job.rb b/app/models/observer/ticket/article/communicate_twitter/background_job.rb
index f27df7ae6..6c99790cc 100644
--- a/app/models/observer/ticket/article/communicate_twitter/background_job.rb
+++ b/app/models/observer/ticket/article/communicate_twitter/background_job.rb
@@ -48,7 +48,7 @@ class Observer::Ticket::Article::CommunicateTwitter::BackgroundJob
if tweet.user_mentions
to = ''
twitter_mention_ids = []
- tweet.user_mentions.each {|user|
+ tweet.user_mentions.each { |user|
if to != ''
to += ' '
end
diff --git a/app/models/observer/ticket/online_notification_seen/background_job.rb b/app/models/observer/ticket/online_notification_seen/background_job.rb
index 4494fd0e0..40578883c 100644
--- a/app/models/observer/ticket/online_notification_seen/background_job.rb
+++ b/app/models/observer/ticket/online_notification_seen/background_job.rb
@@ -9,7 +9,7 @@ class Observer::Ticket::OnlineNotificationSeen::BackgroundJob
# set all online notifications to seen
ActiveRecord::Base.transaction do
ticket = Ticket.lookup(id: @ticket_id)
- OnlineNotification.list_by_object('Ticket', @ticket_id).each {|notification|
+ OnlineNotification.list_by_object('Ticket', @ticket_id).each { |notification|
next if notification.seen
seen = ticket.online_notification_seen_state(notification.user_id)
next if !seen
diff --git a/app/models/observer/transaction.rb b/app/models/observer/transaction.rb
index abd37db73..c0d3f056e 100644
--- a/app/models/observer/transaction.rb
+++ b/app/models/observer/transaction.rb
@@ -28,18 +28,18 @@ class Observer::Transaction < ActiveRecord::Observer
# get asyn backends
sync_backends = []
- Setting.where(area: 'Transaction::Backend::Sync').order(:name).each {|setting|
+ Setting.where(area: 'Transaction::Backend::Sync').order(:name).each { |setting|
backend = Setting.get(setting.name)
sync_backends.push Kernel.const_get(backend)
}
# get uniq objects
list_objects = get_uniq_changes(list)
- list_objects.each {|_object, objects|
- objects.each {|_id, item|
+ list_objects.each { |_object, objects|
+ objects.each { |_id, item|
# execute sync backends
- sync_backends.each {|backend|
+ sync_backends.each { |backend|
execute_singel_backend(backend, item, params)
}
@@ -150,7 +150,7 @@ class Observer::Transaction < ActiveRecord::Observer
if !store[:changes]
store[:changes] = event[:changes]
else
- event[:changes].each {|key, value|
+ event[:changes].each { |key, value|
if !store[:changes][key]
store[:changes][key] = value
else
@@ -190,7 +190,7 @@ class Observer::Transaction < ActiveRecord::Observer
# ignore certain attributes
real_changes = {}
- record.changes.each {|key, value|
+ record.changes.each { |key, value|
next if key == 'updated_at'
next if key == 'first_response'
next if key == 'close_time'
diff --git a/app/models/observer/user/ref_object_touch.rb b/app/models/observer/user/ref_object_touch.rb
index d35c30295..dfb8bfbc2 100644
--- a/app/models/observer/user/ref_object_touch.rb
+++ b/app/models/observer/user/ref_object_touch.rb
@@ -38,7 +38,7 @@ class Observer::User::RefObjectTouch < ActiveRecord::Observer
end
# touch old/current customer
- member_ids.uniq.each {|user_id|
+ member_ids.uniq.each { |user_id|
if user_id != record.id
User.find(user_id).touch
end
diff --git a/app/models/observer/user/ticket_organization.rb b/app/models/observer/user/ticket_organization.rb
index ad5cc24a0..4e7d45a7a 100644
--- a/app/models/observer/user/ticket_organization.rb
+++ b/app/models/observer/user/ticket_organization.rb
@@ -19,7 +19,7 @@ class Observer::User::TicketOrganization < ActiveRecord::Observer
# update last 100 tickets of user
tickets = Ticket.where(customer_id: record.id).limit(100)
- tickets.each {|ticket|
+ tickets.each { |ticket|
if ticket.organization_id != record.organization_id
ticket.organization_id = record.organization_id
ticket.save
diff --git a/app/models/online_notification.rb b/app/models/online_notification.rb
index 6388d9e60..af4841a90 100644
--- a/app/models/online_notification.rb
+++ b/app/models/online_notification.rb
@@ -218,7 +218,7 @@ returns:
def self.all_seen?(object, o_id)
notifications = OnlineNotification.list_by_object(object, o_id)
- notifications.each {|onine_notification|
+ notifications.each { |onine_notification|
return false if !onine_notification['seen']
}
true
@@ -240,7 +240,7 @@ returns:
def self.exists?(user, object, o_id, type, created_by_user, seen)
# rubocop:enable Metrics/ParameterLists
notifications = OnlineNotification.list(user, 10)
- notifications.each {|notification|
+ notifications.each { |notification|
next if notification['o_id'] != o_id
next if notification['object'] != object
next if notification['type'] != type
@@ -269,7 +269,7 @@ with dedicated times
def self.cleanup(max_age = Time.zone.now - 9.months, max_own_seen = Time.zone.now - 10.minutes, max_auto_seen = Time.zone.now - 8.hours)
OnlineNotification.where('created_at < ?', max_age).delete_all
- OnlineNotification.where('seen = ? AND updated_at < ?', true, max_own_seen).each {|notification|
+ OnlineNotification.where('seen = ? AND updated_at < ?', true, max_own_seen).each { |notification|
# delete own "seen" notificatons after 1 hour
next if notification.user_id == notification.updated_by_id && notification.updated_at > max_own_seen
@@ -281,7 +281,7 @@ with dedicated times
}
# notify all agents
- User.of_role('Agent').each {|user|
+ User.of_role('Agent').each { |user|
Sessions.send_to(
user.id,
{
diff --git a/app/models/organization/assets.rb b/app/models/organization/assets.rb
index 3784c063d..79f600c2f 100644
--- a/app/models/organization/assets.rb
+++ b/app/models/organization/assets.rb
@@ -45,7 +45,7 @@ returns
end
local_attributes['member_ids'] = local_member_ids
if local_member_ids
- local_member_ids.each {|local_user_id|
+ local_member_ids.each { |local_user_id|
next if data[ User.to_app_model ][ local_user_id ]
user = User.lookup(id: local_user_id)
next if !user
@@ -55,7 +55,7 @@ returns
data[ Organization.to_app_model ][ id ] = local_attributes
end
- %w(created_by_id updated_by_id).each {|local_user_id|
+ %w(created_by_id updated_by_id).each { |local_user_id|
next if !self[ local_user_id ]
next if data[ User.to_app_model ][ self[ local_user_id ] ]
user = User.lookup(id: self[ local_user_id ])
diff --git a/app/models/organization/search.rb b/app/models/organization/search.rb
index 70144d51f..bc640606b 100644
--- a/app/models/organization/search.rb
+++ b/app/models/organization/search.rb
@@ -78,9 +78,9 @@ returns
organizations_by_user = Organization.select('DISTINCT(organizations.id), organizations.name').joins('LEFT OUTER JOIN users ON users.organization_id = organizations.id').where(
'users.firstname LIKE ? or users.lastname LIKE ? or users.email LIKE ?', "%#{query}%", "%#{query}%", "%#{query}%"
).order('organizations.name').limit(limit)
- organizations_by_user.each {|organization_by_user|
+ organizations_by_user.each { |organization_by_user|
organization_exists = false
- organizations.each {|organization|
+ organizations.each { |organization|
if organization.id == organization_by_user.id
organization_exists = true
end
diff --git a/app/models/organization/search_index.rb b/app/models/organization/search_index.rb
index 2b9adc282..a70085c0b 100644
--- a/app/models/organization/search_index.rb
+++ b/app/models/organization/search_index.rb
@@ -18,7 +18,7 @@ returns
def search_index_attribute_lookup(attributes, ref_object)
attributes_new = {}
- attributes.each {|key, value|
+ attributes.each { |key, value|
next if !value
# get attribute name
diff --git a/app/models/overview/assets.rb b/app/models/overview/assets.rb
index 48d9da93e..d29e8718f 100644
--- a/app/models/overview/assets.rb
+++ b/app/models/overview/assets.rb
@@ -32,7 +32,7 @@ returns
if !data[ Overview.to_app_model ][ id ]
data[ Overview.to_app_model ][ id ] = attributes_with_associations
if user_ids
- user_ids.each {|local_user_id|
+ user_ids.each { |local_user_id|
next if data[ User.to_app_model ][ local_user_id ]
user = User.lookup(id: local_user_id)
next if !user
@@ -43,7 +43,7 @@ returns
data = assets_of_selector('condition', data)
end
- %w(created_by_id updated_by_id).each {|local_user_id|
+ %w(created_by_id updated_by_id).each { |local_user_id|
next if !self[ local_user_id ]
next if data[ User.to_app_model ][ self[ local_user_id ] ]
user = User.lookup(id: self[ local_user_id ])
diff --git a/app/models/package.rb b/app/models/package.rb
index 8cafb3880..665332b1d 100644
--- a/app/models/package.rb
+++ b/app/models/package.rb
@@ -65,7 +65,7 @@ install all packages located under auto_install/*.zpm
data.push entry
end
end
- data.each {|file|
+ data.each { |file|
install(file: "#{path}/#{file}")
}
data
@@ -370,7 +370,7 @@ execute all pending package migrations at once
=end
def self.migration_execute
- Package.all.each {|package|
+ Package.all.each { |package|
json_file = Package._get_bin(package.name, package.version)
package = JSON.parse(json_file)
Package::Migration.migrate(package['name'])
@@ -435,16 +435,16 @@ execute all pending package migrations at once
# 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|
+ (1..position).each { |count|
tmp_path = "#{tmp_path}/#{directories[count]}"
}
next if tmp_path == ''
next if File.exist?(tmp_path)
- Dir.mkdir(tmp_path, 0755)
+ Dir.mkdir(tmp_path, 0o755)
}
# install file
@@ -490,7 +490,7 @@ execute all pending package migrations at once
# get existing migrations
migrations_existing = []
- Dir.foreach(location) {|entry|
+ Dir.foreach(location) { |entry|
next if entry == '.'
next if entry == '..'
migrations_existing.push entry
@@ -504,7 +504,7 @@ execute all pending package migrations at once
migrations_existing = migrations_existing.reverse
end
- migrations_existing.each {|migration|
+ migrations_existing.each { |migration|
next if migration !~ /\.rb$/
version = nil
name = nil
diff --git a/app/models/report.rb b/app/models/report.rb
index 51a4b52a4..03e75bc41 100644
--- a/app/models/report.rb
+++ b/app/models/report.rb
@@ -302,8 +302,8 @@ class Report
]
config[:metric][:communication][:backend] = backend
- config[:metric].each {|metric_key, metric_value|
- metric_value[:backend].each {|metric_backend|
+ config[:metric].each { |metric_key, metric_value|
+ metric_value[:backend].each { |metric_backend|
metric_backend[:name] = "#{metric_key}::#{metric_backend[:name]}"
}
}
diff --git a/app/models/scheduler.rb b/app/models/scheduler.rb
index 8bfba5e50..1277842a6 100644
--- a/app/models/scheduler.rb
+++ b/app/models/scheduler.rb
@@ -27,7 +27,7 @@ class Scheduler < ApplicationModel
# read/load jobs and check if it is alredy started
jobs = Scheduler.where('active = ?', true).order('prio ASC')
- jobs.each {|job|
+ jobs.each { |job|
# ignore job is still running
next if @@jobs_started[ job.id ]
diff --git a/app/models/sla/assets.rb b/app/models/sla/assets.rb
index 18756e399..64fd2d7ba 100644
--- a/app/models/sla/assets.rb
+++ b/app/models/sla/assets.rb
@@ -39,7 +39,7 @@ returns
end
end
end
- %w(created_by_id updated_by_id).each {|local_user_id|
+ %w(created_by_id updated_by_id).each { |local_user_id|
next if !self[ local_user_id ]
next if data[ User.to_app_model ][ self[ local_user_id ] ]
user = User.lookup(id: self[ local_user_id ])
diff --git a/app/models/store/file.rb b/app/models/store/file.rb
index c5b1ac861..9f18d03bd 100644
--- a/app/models/store/file.rb
+++ b/app/models/store/file.rb
@@ -78,7 +78,7 @@ in case of fixing sha hash use:
def self.verify(fix_it = nil)
success = true
- Store::File.all.each {|item|
+ Store::File.all.each { |item|
content = item.content
sha = Digest::SHA256.hexdigest(content)
logger.info "CHECK: Store::File.find(#{item.id})"
@@ -112,7 +112,7 @@ move files from db backend to fs
adapter_source = load_adapter("Store::Provider::#{source}")
adapter_target = load_adapter("Store::Provider::#{target}")
- Store::File.all.each {|item|
+ Store::File.all.each { |item|
next if item.provider == target
content = item.content
diff --git a/app/models/store/provider/file.rb b/app/models/store/provider/file.rb
index cc0d936bf..5eddd3e34 100644
--- a/app/models/store/provider/file.rb
+++ b/app/models/store/provider/file.rb
@@ -53,7 +53,7 @@ class Store::Provider::File
# check if dir need to be removed
base = "#{Rails.root}/storage/fs"
locations = location.split('/')
- (0..locations.count).reverse_each {|count|
+ (0..locations.count).reverse_each { |count|
local_location = locations[0, count].join('/')
break if local_location =~ %r{storage/fs/{0,4}$}
break if !Dir["#{local_location}/*"].empty?
@@ -71,17 +71,17 @@ class Store::Provider::File
length2 = 5
length3 = 7
last_position = 0
- (0..1).each {|_count|
+ (0..1).each { |_count|
end_position = last_position + length1
parts.push sha[last_position, length1]
last_position = end_position
}
- (0..1).each {|_count|
+ (0..1).each { |_count|
end_position = last_position + length2
parts.push sha[last_position, length2]
last_position = end_position
}
- (0..1).each {|_count|
+ (0..1).each { |_count|
end_position = last_position + length3
parts.push sha[last_position, length3]
last_position = end_position
diff --git a/app/models/tag.rb b/app/models/tag.rb
index e398c1a90..c57af1e9f 100644
--- a/app/models/tag.rb
+++ b/app/models/tag.rb
@@ -116,7 +116,7 @@ returns
o_id: data[:o_id],
)
tags = []
- tag_search.each {|tag|
+ tag_search.each { |tag|
tag_item = Tag::Item.lookup(id: tag.tag_item_id)
next if !tag_item
tags.push tag_item.name
@@ -189,7 +189,7 @@ rename tag items
if already_existing_tag
# re-assign old tag to already existing tag
- Tag.where(tag_item_id: old_tag_item.id).each {|tag|
+ Tag.where(tag_item_id: old_tag_item.id).each { |tag|
# check if tag already exists on object
if Tag.find_by(tag_object_id: tag.tag_object_id, o_id: tag.o_id, tag_item_id: already_existing_tag.id)
@@ -223,7 +223,7 @@ rename tag items
old_tag_item.save
# touch reference objects
- Tag.where(tag_item_id: old_tag_item.id).each {|tag|
+ Tag.where(tag_item_id: old_tag_item.id).each { |tag|
tag_object = Tag::Object.lookup(id: tag.tag_object_id)
Tag.touch_reference_by_params(
object: tag_object.name,
@@ -246,7 +246,7 @@ remove tag item (destroy with reverences)
def self.remove(id)
# search for references, destroy and touch
- Tag.where(tag_item_id: id).each {|tag|
+ Tag.where(tag_item_id: id).each { |tag|
tag_object = Tag::Object.lookup(id: tag.tag_object_id)
tag.destroy
Tag.touch_reference_by_params(
diff --git a/app/models/ticket.rb b/app/models/ticket.rb
index 53303c454..bbcd6447d 100644
--- a/app/models/ticket.rb
+++ b/app/models/ticket.rb
@@ -221,7 +221,7 @@ returns
tickets = where('escalation_time <= ?', Time.zone.now + 15.minutes)
- tickets.each {|ticket|
+ tickets.each { |ticket|
# get sla
sla = ticket.escalation_calculation_get_sla
@@ -452,7 +452,7 @@ condition example
# get tables to join
tables = ''
- selectors.each {|attribute, selector|
+ selectors.each { |attribute, selector|
selector = attribute.split(/\./)
next if !selector[1]
next if selector[0] == 'ticket'
@@ -478,7 +478,7 @@ condition example
}
# add conditions
- selectors.each {|attribute, selector_raw|
+ selectors.each { |attribute, selector_raw|
# validation
raise "Invalid selector #{selector_raw.inspect}" if !selector_raw
@@ -673,7 +673,7 @@ perform changes on ticket
end
recipient_string = ''
recipient_already = {}
- recipients.each {|user|
+ recipients.each { |user|
# send notifications only to email adresses
next if !user.email
@@ -784,7 +784,7 @@ perform changes on ticket
next if value['value'].empty?
tags = value['value'].split(/,/)
if value['operator'] == 'add'
- tags.each {|tag|
+ tags.each { |tag|
Tag.tag_add(
object: 'Ticket',
o_id: id,
@@ -792,7 +792,7 @@ perform changes on ticket
)
}
elsif value['operator'] == 'remove'
- tags.each {|tag|
+ tags.each { |tag|
Tag.tag_remove(
object: 'Ticket',
o_id: id,
@@ -838,7 +838,7 @@ result
def get_references(ignore = [])
references = []
- Ticket::Article.select('in_reply_to, message_id').where(ticket_id: id).each {|article|
+ Ticket::Article.select('in_reply_to, message_id').where(ticket_id: id).each { |article|
if !article.in_reply_to.empty?
references.push article.in_reply_to
end
@@ -846,7 +846,7 @@ result
next if article.message_id.empty?
references.push article.message_id
}
- ignore.each {|item|
+ ignore.each { |item|
references.delete(item)
}
references
diff --git a/app/models/ticket/article.rb b/app/models/ticket/article.rb
index a4ca9bc9a..3cb3250da 100644
--- a/app/models/ticket/article.rb
+++ b/app/models/ticket/article.rb
@@ -48,7 +48,7 @@ class Ticket::Article < ApplicationModel
replace = item
# look for attachment
- attachments.each {|file|
+ attachments.each { |file|
next if !file.preferences['Content-ID'] || file.preferences['Content-ID'] != $3
replace = "#{$1}/api/v1/ticket_attachment/#{article['ticket_id']}/#{article['id']}/#{file.id}#{$4}"
inline_attachments[file.id] = true
@@ -57,7 +57,7 @@ class Ticket::Article < ApplicationModel
replace
}
new_attachments = []
- attachments.each {|file|
+ attachments.each { |file|
next if inline_attachments[file.id]
new_attachments.push file
}
diff --git a/app/models/ticket/article/assets.rb b/app/models/ticket/article/assets.rb
index 9039bd066..169de83a1 100644
--- a/app/models/ticket/article/assets.rb
+++ b/app/models/ticket/article/assets.rb
@@ -55,7 +55,7 @@ returns
end
end
- %w(created_by_id updated_by_id).each {|local_user_id|
+ %w(created_by_id updated_by_id).each { |local_user_id|
next if !self[ local_user_id ]
next if data[ User.to_app_model ] && data[ User.to_app_model ][ self[ local_user_id ] ]
user = User.lookup(id: self[ local_user_id ])
diff --git a/app/models/ticket/assets.rb b/app/models/ticket/assets.rb
index 906650574..a0de7e3c2 100644
--- a/app/models/ticket/assets.rb
+++ b/app/models/ticket/assets.rb
@@ -28,7 +28,7 @@ returns
if !data[ Ticket.to_app_model ][ id ]
data[ Ticket.to_app_model ][ id ] = attributes_with_associations
end
- %w(created_by_id updated_by_id owner_id customer_id).each {|local_user_id|
+ %w(created_by_id updated_by_id owner_id customer_id).each { |local_user_id|
next if !self[ local_user_id ]
next if data[ User.to_app_model ] && data[ User.to_app_model ][ self[ local_user_id ] ]
user = User.lookup(id: self[ local_user_id ])
diff --git a/app/models/ticket/escalation.rb b/app/models/ticket/escalation.rb
index 996d26a69..f0c073f49 100644
--- a/app/models/ticket/escalation.rb
+++ b/app/models/ticket/escalation.rb
@@ -72,11 +72,11 @@ returns
# get business hours
hours = {}
- calendar.business_hours.each {|day, meta|
+ calendar.business_hours.each { |day, meta|
next if !meta[:active]
next if !meta[:timeframes]
hours[day.to_sym] = {}
- meta[:timeframes].each {|frame|
+ meta[:timeframes].each { |frame|
next if !frame[0]
next if !frame[1]
hours[day.to_sym][frame[0]] = frame[1]
@@ -90,7 +90,7 @@ returns
# get holidays
holidays = []
if calendar.public_holidays
- calendar.public_holidays.each {|day, meta|
+ calendar.public_holidays.each { |day, meta|
next if !meta
next if !meta['active']
next if meta['removed']
@@ -212,7 +212,7 @@ returns
sla_list = Sla.all.order(:name, :created_at)
Cache.write('SLA::List::Active', sla_list, { expires_in: 1.hour })
end
- sla_list.each {|sla|
+ sla_list.each { |sla|
if !sla.condition || sla.condition.empty?
sla_selected = sla
elsif sla.condition
diff --git a/app/models/ticket/history_log.rb b/app/models/ticket/history_log.rb
index 35fb0c890..46b81afa8 100644
--- a/app/models/ticket/history_log.rb
+++ b/app/models/ticket/history_log.rb
@@ -64,7 +64,7 @@ returns
# get related objects
assets = {}
- list.each {|item|
+ list.each { |item|
record = Kernel.const_get(item['object']).find(item['o_id'])
assets = record.assets(assets)
diff --git a/app/models/ticket/number.rb b/app/models/ticket/number.rb
index 2936721c7..c558b26ca 100644
--- a/app/models/ticket/number.rb
+++ b/app/models/ticket/number.rb
@@ -18,7 +18,7 @@ returns
def self.generate
# generate number
- (1..50_000).each {
+ 49_999.times {
number = adapter.generate
ticket = Ticket.find_by( number: number )
return number if !ticket
diff --git a/app/models/ticket/number/increment.rb b/app/models/ticket/number/increment.rb
index d268b44d9..07db21ec6 100644
--- a/app/models/ticket/number/increment.rb
+++ b/app/models/ticket/number/increment.rb
@@ -31,7 +31,7 @@ module Ticket::Number::Increment
min_digs = min_digs.to_i - 1
end
fillup = Setting.get('system_id').to_s || '1'
- (1..100).each {
+ 99.times {
next if (fillup.length.to_i + counter_increment.to_s.length.to_i) >= min_digs.to_i
diff --git a/app/models/ticket/overviews.rb b/app/models/ticket/overviews.rb
index d7e206295..5c9048e27 100644
--- a/app/models/ticket/overviews.rb
+++ b/app/models/ticket/overviews.rb
@@ -26,7 +26,7 @@ returns
Overview.where(role_id: role.id, organization_shared: false, active: true).order(:prio)
end
overviews_list = []
- overviews.each {|overview|
+ overviews.each { |overview|
user_ids = overview.user_ids
next if !user_ids.empty? && !user_ids.include?(data[:current_user].id)
overviews_list.push overview
@@ -39,7 +39,7 @@ returns
role = Role.find_by(name: 'Agent')
overviews = Overview.where(role_id: role.id, active: true).order(:prio)
overviews_list = []
- overviews.each {|overview|
+ overviews.each { |overview|
user_ids = overview.user_ids
next if !user_ids.empty? && !user_ids.include?(data[:current_user].id)
overviews_list.push overview
@@ -91,7 +91,7 @@ returns
access_condition = Ticket.access_condition(user)
list = []
- overviews.each {|overview|
+ overviews.each { |overview|
query_condition, bind_condition = Ticket.selector2sql(overview.condition, user)
order_by = "#{overview.order[:by]} #{overview.order[:direction]}"
diff --git a/app/models/ticket/permission.rb b/app/models/ticket/permission.rb
index 4d4ba9b0e..f123f9144 100644
--- a/app/models/ticket/permission.rb
+++ b/app/models/ticket/permission.rb
@@ -37,7 +37,7 @@ returns
return true if owner_id == data[:current_user].id
# access if requestor is in group
- data[:current_user].groups.each {|group|
+ data[:current_user].groups.each { |group|
return true if self.group.id == group.id
}
false
diff --git a/app/models/ticket/screen_options.rb b/app/models/ticket/screen_options.rb
index e407c4913..1d85eeea8 100644
--- a/app/models/ticket/screen_options.rb
+++ b/app/models/ticket/screen_options.rb
@@ -45,10 +45,10 @@ returns
if state_type && !state_types.include?(state_type.name)
state_ids.push params[:ticket].state.id
end
- state_types.each {|type|
+ state_types.each { |type|
state_type = Ticket::StateType.find_by(name: type)
next if !state_type
- state_type.states.each {|state|
+ state_type.states.each { |state|
assets = state.assets(assets)
state_ids.push state.id
}
@@ -69,7 +69,7 @@ returns
if params[:ticket].group.email_address_id
types.push 'email'
end
- types.each {|type_name|
+ types.each { |type_name|
type = Ticket::Article::Type.lookup( name: type_name )
if type
type_ids.push type.id
@@ -88,7 +88,7 @@ returns
Group.where(active: true).each { |group|
assets = group.assets(assets)
dependencies[:group_id][group.id] = { owner_id: [] }
- group.users.each {|user|
+ group.users.each { |user|
next if !agents[ user.id ]
assets = user.assets(assets)
dependencies[:group_id][ group.id ][ :owner_id ].push user.id
@@ -136,7 +136,7 @@ returns
).limit( data[:limit] || 15 ).order('created_at DESC')
assets = {}
ticket_ids_open = []
- tickets_open.each {|ticket|
+ tickets_open.each { |ticket|
ticket_ids_open.push ticket.id
assets = ticket.assets(assets)
}
@@ -146,7 +146,7 @@ returns
state_id: state_list_closed
).limit( data[:limit] || 15 ).order('created_at DESC')
ticket_ids_closed = []
- tickets_closed.each {|ticket|
+ tickets_closed.each { |ticket|
ticket_ids_closed.push ticket.id
assets = ticket.assets(assets)
}
diff --git a/app/models/ticket/search.rb b/app/models/ticket/search.rb
index 5be9cc213..3a4d7631a 100644
--- a/app/models/ticket/search.rb
+++ b/app/models/ticket/search.rb
@@ -107,7 +107,7 @@ returns
.where('groups_users.user_id = ?', current_user.id)
.where('groups.active = ?', true)
group_condition = []
- groups.each {|group|
+ groups.each { |group|
group_condition.push group.name
}
access_condition = {
@@ -134,7 +134,7 @@ returns
items = SearchIndexBackend.search(query, limit, 'Ticket', query_extention)
if !full
ids = []
- items.each {|item|
+ items.each { |item|
ids.push item[:id]
}
return ids
diff --git a/app/models/ticket/search_index.rb b/app/models/ticket/search_index.rb
index a18049a87..b002c17cf 100644
--- a/app/models/ticket/search_index.rb
+++ b/app/models/ticket/search_index.rb
@@ -20,7 +20,7 @@ returns
# default ignored attributes
ignore_attributes = {}
if self.class.search_index_support_config[:ignore_attributes]
- self.class.search_index_support_config[:ignore_attributes].each {|key, value|
+ self.class.search_index_support_config[:ignore_attributes].each { |key, value|
ignore_attributes[key] = value
}
end
@@ -31,7 +31,7 @@ returns
# remove ignored attributes
attributes = ticket.attributes
- ignore_attributes.each {|key, value|
+ ignore_attributes.each { |key, value|
next if value != true
attributes.delete( key.to_s )
}
@@ -54,12 +54,12 @@ returns
# collect article data
articles = Ticket::Article.where( ticket_id: id )
attributes['articles'] = []
- articles.each {|article|
+ articles.each { |article|
article_attributes = article.attributes
# remove note needed attributes
ignore = %w(message_id_md5)
- ignore.each {|attribute|
+ ignore.each { |attribute|
article_attributes.delete( attribute )
}
@@ -72,7 +72,7 @@ returns
end
# lookup attachments
- article.attachments.each {|attachment|
+ article.attachments.each { |attachment|
if !article_attributes['attachments']
article_attributes['attachments'] = []
end
diff --git a/app/models/transaction/background_job.rb b/app/models/transaction/background_job.rb
index 488bd271e..838e9c839 100644
--- a/app/models/transaction/background_job.rb
+++ b/app/models/transaction/background_job.rb
@@ -22,7 +22,7 @@ class Transaction::BackgroundJob
end
def perform
- Setting.where(area: 'Transaction::Backend::Async').order(:name).each {|setting|
+ Setting.where(area: 'Transaction::Backend::Async').order(:name).each { |setting|
backend = Kernel.const_get(Setting.get(setting.name))
Observer::Transaction.execute_singel_backend(backend, @item, @params)
}
diff --git a/app/models/transaction/clearbit_enrichment.rb b/app/models/transaction/clearbit_enrichment.rb
index 857d4bd20..e3fcffae9 100644
--- a/app/models/transaction/clearbit_enrichment.rb
+++ b/app/models/transaction/clearbit_enrichment.rb
@@ -50,7 +50,7 @@ sync all users against clearbit
def self.sync
users = User.of_role('Customer')
- users.each {|user|
+ users.each { |user|
sync_user(user)
}
end
@@ -84,7 +84,7 @@ users = [...]
user_sync = config['user_sync']
user_sync_values = {}
if user_sync
- user_sync.each {|callback, destination|
+ user_sync.each { |callback, destination|
next if !user_sync_values[destination].empty?
value = _replace(callback, data)
next if !value
@@ -96,7 +96,7 @@ users = [...]
organization_sync = config['organization_sync']
organization_sync_values = {}
if organization_sync
- organization_sync.each {|callback, destination|
+ organization_sync.each { |callback, destination|
next if !organization_sync_values[destination].empty?
value = _replace(callback, data)
next if !value
@@ -115,7 +115,7 @@ users = [...]
o_id: user.id,
)
if external_syn_user && external_syn_user.last_payload
- user_sync.each {|callback, destination|
+ user_sync.each { |callback, destination|
next if !user_sync_values_last_time[destination].empty?
value = _replace(callback, external_syn_user.last_payload)
next if !value
@@ -126,7 +126,7 @@ users = [...]
# if person record exists
user_has_changed = false
- user_sync_values.each {|destination, value|
+ user_sync_values.each { |destination, value|
attribute = destination.sub(/^user\./, '')
next if user[attribute] == value
next if !user[attribute].empty? && user_sync_values_last_time[destination] != user[attribute]
@@ -196,7 +196,7 @@ users = [...]
organization = Organization.new(
shared: config['organization_shared'],
)
- organization_sync_values.each {|destination, value|
+ organization_sync_values.each { |destination, value|
attribute = destination.sub(/^organization\./, '')
next if !organization[attribute].empty?
begin
@@ -227,7 +227,7 @@ users = [...]
# get latest organization synced attributes
organization_sync_values_last_time = {}
if external_syn_organization && external_syn_organization.last_payload
- organization_sync.each {|callback, destination|
+ organization_sync.each { |callback, destination|
next if !organization_sync_values_last_time[destination].empty?
value = _replace(callback, external_syn_organization.last_payload)
next if !value
@@ -238,7 +238,7 @@ users = [...]
# update existing organization
organization = Organization.find(external_syn_organization[:o_id])
organization_has_changed = false
- organization_sync_values.each {|destination, value|
+ organization_sync_values.each { |destination, value|
attribute = destination.sub(/^organization\./, '')
next if organization[attribute] == value
next if !organization[attribute].empty? && organization_sync_values_last_time[destination] != organization[attribute]
@@ -292,7 +292,7 @@ users = [...]
object_refs = data[object_name]
object_methods = object_method.split('.')
object_methods_s = ''
- object_methods.each {|method|
+ object_methods.each { |method|
if object_methods_s != ''
object_methods_s += '.'
end
diff --git a/app/models/transaction/notification.rb b/app/models/transaction/notification.rb
index a6509ecf9..2f4805aa2 100644
--- a/app/models/transaction/notification.rb
+++ b/app/models/transaction/notification.rb
@@ -79,7 +79,7 @@ class Transaction::Notification
possible_recipients.push ticket.owner
end
already_checked_recipient_ids = {}
- possible_recipients.each {|user|
+ possible_recipients.each { |user|
result = NotificationFactory::Mailer.notification_settings(user, ticket, @item[:type])
next if !result
next if already_checked_recipient_ids[result[:user].id]
@@ -113,7 +113,7 @@ class Transaction::Notification
identifier = user.login
end
already_notified = false
- History.list('Ticket', ticket.id).each {|history|
+ History.list('Ticket', ticket.id).each { |history|
next if history['type'] != 'notification'
next if history['value_to'] !~ /\(#{Regexp.escape(@item[:type])}:/
next if history['value_to'] !~ /#{Regexp.escape(identifier)}\(/
@@ -234,7 +234,7 @@ class Transaction::Notification
attribute_list = ObjectManager::Attribute.by_object_as_hash('Ticket', user)
#puts "AL #{attribute_list.inspect}"
user_related_changes = {}
- @item[:changes].each {|key, value|
+ @item[:changes].each { |key, value|
# if no config exists, use all attributes
if !attribute_list || attribute_list.empty?
@@ -247,7 +247,7 @@ class Transaction::Notification
}
changes = {}
- user_related_changes.each {|key, value|
+ user_related_changes.each { |key, value|
# get attribute name
attribute_name = key.to_s
diff --git a/app/models/transaction/slack.rb b/app/models/transaction/slack.rb
index a9821928e..40e449b28 100644
--- a/app/models/transaction/slack.rb
+++ b/app/models/transaction/slack.rb
@@ -110,7 +110,7 @@ backend.perform
color = '#38ad69'
end
- config['items'].each {|local_config|
+ config['items'].each { |local_config|
next if local_config['webhook'].empty?
# check if reminder_reached/escalation/escalation_warning is already sent today
@@ -134,7 +134,7 @@ backend.perform
# check action
if local_config['types'].class == Array
hit = false
- local_config['types'].each {|type|
+ local_config['types'].each { |type|
next if type.to_s != @item[:type].to_s
hit = true
break
@@ -147,7 +147,7 @@ backend.perform
# check group
if local_config['group_ids'].class == Array
hit = false
- local_config['group_ids'].each {|group_id|
+ local_config['group_ids'].each { |group_id|
next if group_id.to_s != ticket.group_id.to_s
hit = true
break
@@ -206,7 +206,7 @@ backend.perform
attribute_list = ObjectManager::Attribute.by_object_as_hash('Ticket', user)
#puts "AL #{attribute_list.inspect}"
user_related_changes = {}
- @item[:changes].each {|key, value|
+ @item[:changes].each { |key, value|
# if no config exists, use all attributes
if !attribute_list || attribute_list.empty?
@@ -219,7 +219,7 @@ backend.perform
}
changes = {}
- user_related_changes.each {|key, value|
+ user_related_changes.each { |key, value|
# get attribute name
attribute_name = key.to_s
diff --git a/app/models/transaction/trigger.rb b/app/models/transaction/trigger.rb
index 01c22ca80..8dbee34f8 100644
--- a/app/models/transaction/trigger.rb
+++ b/app/models/transaction/trigger.rb
@@ -40,7 +40,7 @@ class Transaction::Trigger
original_user_id = UserInfo.current_user_id
UserInfo.current_user_id = 1
- triggers.each {|trigger|
+ triggers.each { |trigger|
condition = trigger.condition
# check action
@@ -49,7 +49,28 @@ class Transaction::Trigger
next if condition['ticket.action']['operator'] != 'is' && condition['ticket.action']['value'] == @item[:type]
condition.delete('ticket.action')
end
+=begin
+ # check "has changed" options
+ has_changed = true
+ trigger.condition.each do |key, value|
+ next if !value
+ next if !value['operator']
+ next if !value['operator']['has changed']
+ # next if has changed? && !@item[:changes][attribute]
+ (object_name, attribute) = key.split('.', 2)
+
+ # remove condition item, because it has changed
+ if @item[:changes][attribute]
+ #condition.delete(key)
+ next
+ end
+ has_changed = false
+ break
+ #{"ticket.state_id"=>{"operator"=>"has changed"
+ end
+ next if !has_changed
+=end
# check if selector is matching
condition['ticket.id'] = {
operator: 'is',
diff --git a/app/models/translation.rb b/app/models/translation.rb
index 0e513e51b..fd8d7c3eb 100644
--- a/app/models/translation.rb
+++ b/app/models/translation.rb
@@ -24,13 +24,13 @@ dedicated:
locales_list = []
if !dedicated_locale
locales = Locale.to_sync
- locales.each {|locale|
+ locales.each { |locale|
locales_list.push locale.locale
}
else
locales_list = [dedicated_locale]
end
- locales_list.each {|locale|
+ locales_list.each { |locale|
url = "https://i18n.zammad.com/api/v1/translations/#{locale}"
if !UserInfo.current_user_id
UserInfo.current_user_id = 1
@@ -48,11 +48,11 @@ dedicated:
translations = Translation.where(locale: locale).all
ActiveRecord::Base.transaction do
- result.data.each {|translation_raw|
+ result.data.each { |translation_raw|
# handle case insensitive sql
translation = nil
- translations.each {|item|
+ translations.each { |item|
next if item.format != translation_raw['format']
next if item.source != translation_raw['source']
translation = item
@@ -62,7 +62,7 @@ dedicated:
# verify if update is needed
update_needed = false
- translation_raw.each {|key, _value|
+ translation_raw.each { |key, _value|
if translation_raw[key] != translation[key]
update_needed = true
break
@@ -94,7 +94,7 @@ push translations to online
# only push changed translations
translations = Translation.where(locale: locale)
translations_to_push = []
- translations.each {|translation|
+ translations.each { |translation|
if translation.target != translation.target_initial
translations_to_push.push translation
end
@@ -142,7 +142,7 @@ reset translations to origin
# only push changed translations
translations = Translation.where(locale: locale)
- translations.each {|translation|
+ translations.each { |translation|
if !translation.target_initial || translation.target_initial.empty?
translation.destroy
elsif translation.target != translation.target_initial
@@ -203,8 +203,8 @@ get list of translations
# add presorted on top
presorted_list = []
- %w(yes no or Year Years Month Months Day Days Hour Hours Minute Minutes Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec January February March April May June July August September October November December Mon Tue Wed Thu Fri Sat Sun Monday Tuesday Wednesday Thursday Friday Saturday Sunday).each {|presort|
- list.each {|item|
+ %w(yes no or Year Years Month Months Day Days Hour Hours Minute Minutes Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec January February March April May June July August September October November December Mon Tue Wed Thu Fri Sat Sun Monday Tuesday Wednesday Thursday Friday Saturday Sunday).each { |presort|
+ list.each { |item|
next if item[1] != presort
presorted_list.push item
list.delete item
@@ -233,13 +233,13 @@ translate strings in ruby context, e. g. for notifications
# translate string
records = Translation.where(locale: locale, source: string)
- records.each {|record|
+ records.each { |record|
return record.target if record.source == string
}
# fallback lookup in en
records = Translation.where(locale: 'en', source: string)
- records.each {|record|
+ records.each { |record|
return record.target if record.source == string
}
diff --git a/app/models/user.rb b/app/models/user.rb
index acbb49f9f..f55c55e2a 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -290,7 +290,7 @@ returns
roles = Role.where(name: 'Customer')
url = ''
if hash['info']['urls']
- hash['info']['urls'].each {|_name, local_url|
+ hash['info']['urls'].each { |_name, local_url|
next if !local_url
next if local_url.empty?
url = local_url
@@ -539,7 +539,7 @@ returns
def self.update_default_preferences(role_name)
role = Role.lookup(name: role_name)
- User.of_role(role_name).each {|user|
+ User.of_role(role_name).each { |user|
user.check_notifications(role)
user.check_preferences_default
user.save
@@ -555,7 +555,7 @@ returns
if !@preferences_default
@preferences_default = {}
end
- default[o.name].each {|key, value|
+ default[o.name].each { |key, value|
next if @preferences_default[key]
@preferences_default[key] = value
}
diff --git a/app/models/user/assets.rb b/app/models/user/assets.rb
index 0f977c143..16bc14e9b 100644
--- a/app/models/user/assets.rb
+++ b/app/models/user/assets.rb
@@ -62,7 +62,7 @@ returns
end
local_attributes['role_ids'] = local_role_ids
if local_role_ids
- local_role_ids.each {|role_id|
+ local_role_ids.each { |role_id|
role = Role.lookup(id: role_id)
data = role.assets(data)
}
@@ -77,7 +77,7 @@ returns
end
local_attributes['group_ids'] = local_group_ids
if local_group_ids
- local_group_ids.each {|group_id|
+ local_group_ids.each { |group_id|
group = Group.lookup(id: group_id)
next if !group
data = group.assets(data)
@@ -93,7 +93,7 @@ returns
end
local_attributes['organization_ids'] = local_organization_ids
if local_organization_ids
- local_organization_ids.each {|organization_id|
+ local_organization_ids.each { |organization_id|
organization = Organization.lookup(id: organization_id)
next if !organization
data = organization.assets(data)
@@ -112,7 +112,7 @@ returns
end
end
end
- %w(created_by_id updated_by_id).each {|local_user_id|
+ %w(created_by_id updated_by_id).each { |local_user_id|
next if !self[ local_user_id ]
next if data[ User.to_app_model ][ self[ local_user_id ] ]
user = User.lookup(id: self[ local_user_id ])
diff --git a/app/models/user_device.rb b/app/models/user_device.rb
index c4a4ce13a..a7e9018f8 100644
--- a/app/models/user_device.rb
+++ b/app/models/user_device.rb
@@ -40,7 +40,7 @@ store new device for user if device not already known
user_id: user_id,
fingerprint: fingerprint,
)
- user_devices.each {|local_user_device|
+ user_devices.each { |local_user_device|
device_exists_by_fingerprint = true
next if local_user_device.location != location
return action(local_user_device.id, user_agent, ip, user_id, type) if local_user_device
@@ -54,7 +54,7 @@ store new device for user if device not already known
user_id: user_id,
user_agent: user_agent,
)
- user_devices.each {|local_user_device|
+ user_devices.each { |local_user_device|
device_exists_by_user_agent = true
next if local_user_device.location != location
return action(local_user_device.id, user_agent, ip, user_id, type) if local_user_device
diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb
index d1e858b68..09feafbf1 100644
--- a/config/initializers/assets.rb
+++ b/config/initializers/assets.rb
@@ -8,5 +8,5 @@ Rails.application.config.assets.version = '1.0'
# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
-Rails.application.config.assets.precompile += %w( application-print.css )
-Rails.application.config.assets.precompile += %w( print.css )
+Rails.application.config.assets.precompile += %w(application-print.css)
+Rails.application.config.assets.precompile += %w(print.css)
diff --git a/config/initializers/core_ext.rb b/config/initializers/core_ext.rb
index 4b6e4df3e..ee21f0f77 100644
--- a/config/initializers/core_ext.rb
+++ b/config/initializers/core_ext.rb
@@ -1,5 +1,5 @@
# load all core_ext extentions
-Dir.glob("#{Rails.root}/lib/core_ext/**/*").each {|file|
+Dir.glob("#{Rails.root}/lib/core_ext/**/*").each { |file|
if File.file?(file)
require file
end
diff --git a/config/initializers/vendor_lib.rb b/config/initializers/vendor_lib.rb
index 2aba3cccb..6a3780365 100644
--- a/config/initializers/vendor_lib.rb
+++ b/config/initializers/vendor_lib.rb
@@ -1,5 +1,5 @@
# load all vendor/lib extentions
-Dir["#{Rails.root}/vendor/lib/*"].each {|file|
+Dir["#{Rails.root}/vendor/lib/*"].each { |file|
if File.file?(file)
require file
end
diff --git a/db/migrate/20150979000001_update_timestamps.rb b/db/migrate/20150979000001_update_timestamps.rb
index 0fe949b56..c4f52869b 100644
--- a/db/migrate/20150979000001_update_timestamps.rb
+++ b/db/migrate/20150979000001_update_timestamps.rb
@@ -1,7 +1,7 @@
class UpdateTimestamps < ActiveRecord::Migration
def up
# get all models
- Models.all.each {|_model, value|
+ Models.all.each { |_model, value|
next if !value
next if !value[:attributes]
if value[:attributes].include?('changed_at')
diff --git a/db/migrate/20160307000001_only_one_group.rb b/db/migrate/20160307000001_only_one_group.rb
index 7c06d7612..dc0b7d1fe 100644
--- a/db/migrate/20160307000001_only_one_group.rb
+++ b/db/migrate/20160307000001_only_one_group.rb
@@ -188,7 +188,7 @@ class OnlyOneGroup < ActiveRecord::Migration
)
list = []
- User.all {|user|
+ User.all { |user|
next if !user.zip.empty? && !user.city.empty? && !user.street.empty?
#next if !user.address.empty?
list.push user
diff --git a/db/migrate/20160506000001_update_setting_placeholder.rb b/db/migrate/20160506000001_update_setting_placeholder.rb
index 8ce5fe938..24e6a9591 100644
--- a/db/migrate/20160506000001_update_setting_placeholder.rb
+++ b/db/migrate/20160506000001_update_setting_placeholder.rb
@@ -11,7 +11,7 @@ class UpdateSettingPlaceholder < ActiveRecord::Migration
http_type
ticket_hook
)
- names.each {|name|
+ names.each { |name|
setting = Setting.find_by(name: name)
next if !setting
setting.preferences[:placeholder] = true
diff --git a/db/seeds.rb b/db/seeds.rb
index 3972ee687..251275e53 100644
--- a/db/seeds.rb
+++ b/db/seeds.rb
@@ -134,7 +134,7 @@ Setting.create_if_not_exists(
frontend: true
)
options = {}
-(10..99).each {|item|
+(10..99).each { |item|
options[item] = item
}
system_id = rand(10..99)
diff --git a/lib/auth.rb b/lib/auth.rb
index 70d2cca5a..b02f087f0 100644
--- a/lib/auth.rb
+++ b/lib/auth.rb
@@ -28,7 +28,7 @@ returns
]
# added configured backends
- Setting.where(area: 'Security::Authentication').each {|setting|
+ Setting.where(area: 'Security::Authentication').each { |setting|
if setting.state_current[:value]
config.push setting.state_current[:value]
end
@@ -36,7 +36,7 @@ returns
# try to login against configure auth backends
user_auth = nil
- config.each {|config_item|
+ config.each { |config_item|
next if !config_item[:adapter]
# load backend
diff --git a/lib/auth/ldap.rb b/lib/auth/ldap.rb
index b048a81d2..aa91fb21c 100644
--- a/lib/auth/ldap.rb
+++ b/lib/auth/ldap.rb
@@ -64,7 +64,7 @@ module Auth::Ldap
source: 'ldap',
updated_by_id: 1,
}
- config[:sync_params].each {|local_data, ldap_data|
+ config[:sync_params].each { |local_data, ldap_data|
if user_data[ ldap_data.downcase.to_sym ]
user_attributes[ local_data.downcase.to_sym] = user_data[ ldap_data.downcase.to_sym ]
end
@@ -91,7 +91,7 @@ module Auth::Ldap
# set always roles
if config[:always_roles]
role_ids = user.role_ids
- config[:always_roles].each {|role_name|
+ config[:always_roles].each { |role_name|
role = Role.where( name: role_name ).first
next if !role
if !role_ids.include?( role.id )
@@ -105,7 +105,7 @@ module Auth::Ldap
# set always groups
if config[:always_groups]
group_ids = user.group_ids
- config[:always_groups].each {|group_name|
+ config[:always_groups].each { |group_name|
group = Group.where( name: group_name ).first
next if !group
if !group_ids.include?( group.id )
diff --git a/lib/auto_wizard.rb b/lib/auto_wizard.rb
index 0590fb54c..9801cc9cf 100644
--- a/lib/auto_wizard.rb
+++ b/lib/auto_wizard.rb
@@ -81,9 +81,9 @@ returns
model_map = {
'Organizations' => 'Organization',
}
- model_map.each {|map_name, model|
+ model_map.each { |map_name, model|
next if !auto_wizard_hash[map_name]
- auto_wizard_hash[map_name].each {|data|
+ auto_wizard_hash[map_name].each { |data|
generic_object = Kernel.const_get(model)
data.symbolize_keys!
generic_object.create_or_update_with_ref(data)
@@ -126,9 +126,9 @@ returns
'Signatures' => 'Signature',
'Groups' => 'Group',
}
- model_map.each {|map_name, model|
+ model_map.each { |map_name, model|
next if !auto_wizard_hash[map_name]
- auto_wizard_hash[map_name].each {|data|
+ auto_wizard_hash[map_name].each { |data|
generic_object = Kernel.const_get(model)
data.symbolize_keys!
generic_object.create_or_update_with_ref(data)
diff --git a/lib/core_ext/active_record/connection_adapters/postgresql/schema_statements.rb b/lib/core_ext/active_record/connection_adapters/postgresql/schema_statements.rb
index ff17790aa..da62e838c 100644
--- a/lib/core_ext/active_record/connection_adapters/postgresql/schema_statements.rb
+++ b/lib/core_ext/active_record/connection_adapters/postgresql/schema_statements.rb
@@ -12,7 +12,7 @@ module ActiveRecord
column_names = index_columns.split ', '
if column_names.class == Array
index_columns_new = []
- column_names.each {|i|
+ column_names.each { |i|
if i =~ /^"(name|login|locale|alias)"$/ || i =~ /name"$/
index_columns_new.push "LOWER(#{i})"
else
diff --git a/lib/core_ext/string.rb b/lib/core_ext/string.rb
index f2e5f4505..103597de6 100644
--- a/lib/core_ext/string.rb
+++ b/lib/core_ext/string.rb
@@ -58,7 +58,7 @@ class String
# More details: http://pjambet.github.io/blog/emojis-and-mysql/
def utf8_to_3bytesutf8
return self if Rails.application.config.db_4bytes_utf8
- each_char.select {|c|
+ each_char.select { |c|
if c.bytes.count > 3
Rails.logger.warn "strip out 4 bytes utf8 chars '#{c}' of '#{self}'"
next
@@ -102,7 +102,7 @@ class String
"[#{counter}] "
}
else
- string.gsub!(%r{]*)>(.+?)<[[:space:]]*/a[[:space:]]*>}mxi) {|_placeholder|
+ string.gsub!(%r{]*)>(.+?)<[[:space:]]*/a[[:space:]]*>}mxi) { |_placeholder|
link = $3
text = $6
text.gsub!(/\<.+?\>/, '')
@@ -192,7 +192,7 @@ class String
# add hyperlinks
if strict
- string.gsub!(%r{([[:space:]])((http|https|ftp|tel)://.+?|(www..+?))([[:space:]]|\.[[:space:]]|,[[:space:]])}mxi) {|_placeholder|
+ string.gsub!(%r{([[:space:]])((http|https|ftp|tel)://.+?|(www..+?))([[:space:]]|\.[[:space:]]|,[[:space:]])}mxi) { |_placeholder|
pre = $1
content = $2
post = $5
@@ -368,7 +368,7 @@ class String
# edv hotline schrieb:
#map['word-en-de'] = "[^#{marker}].{1,250}\s(wrote|schrieb):"
- map.each {|_key, regexp|
+ map.each { |_key, regexp|
string.sub!(/#{regexp}/) { |placeholder|
placeholder = "#{marker}#{placeholder}"
}
diff --git a/lib/email_helper.rb b/lib/email_helper.rb
index c1b0dd5f4..d7dac17aa 100644
--- a/lib/email_helper.rb
+++ b/lib/email_helper.rb
@@ -213,7 +213,7 @@ returns
def self.provider_inbound_mx(user, email, password, mx_domains)
inbounds = []
- mx_domains.each {|domain|
+ mx_domains.each { |domain|
inbound = [
{
adapter: 'imap',
@@ -412,7 +412,7 @@ returns
def self.provider_outbound_mx(user, email, password, mx_domains)
outbounds = []
- mx_domains.each {|domain|
+ mx_domains.each { |domain|
outbound = [
{
adapter: 'smtp',
diff --git a/lib/email_helper/probe.rb b/lib/email_helper/probe.rb
index 92d27b668..7faa5373b 100644
--- a/lib/email_helper/probe.rb
+++ b/lib/email_helper/probe.rb
@@ -68,8 +68,8 @@ returns on fail
# get mx records, try to find provider based on mx records
mx_records = EmailHelper.mx_records(domain)
domains = domains.concat(mx_records)
- provider_map.each {|_provider, settings|
- domains.each {|domain_to_check|
+ provider_map.each { |_provider, settings|
+ domains.each { |domain_to_check|
next if domain_to_check !~ /#{settings[:domain]}/i
@@ -109,7 +109,7 @@ returns on fail
setting: {}
}
success = false
- inbound_map.each {|config|
+ inbound_map.each { |config|
# add folder to config if needed
if !params[:folder].empty? && config[:options]
@@ -143,7 +143,7 @@ returns on fail
outbound_map = outbound_mx + outbound_guess
success = false
- outbound_map.each {|config|
+ outbound_map.each { |config|
Rails.logger.debug "OUTBOUND PROBE GUESS: #{config.inspect}"
result_outbound = EmailHelper::Probe.outbound(config, params[:email])
Rails.logger.debug "OUTBOUND RESULT GUESS: #{result_outbound.inspect}"
@@ -337,7 +337,7 @@ returns on fail
white_map = {
'Recipient address rejected' => true,
}
- white_map.each {|key, _message|
+ white_map.each { |key, _message|
next if e.message !~ /#{Regexp.escape(key)}/i
@@ -362,7 +362,7 @@ returns on fail
end
def self.invalid_field(message_backend)
- invalid_fields.each {|key, fields|
+ invalid_fields.each { |key, fields|
return fields if message_backend =~ /#{Regexp.escape(key)}/i
}
{}
@@ -387,7 +387,7 @@ returns on fail
end
def self.translation(message_backend)
- translations.each {|key, message_human|
+ translations.each { |key, message_human|
return message_human if message_backend =~ /#{Regexp.escape(key)}/i
}
nil
diff --git a/lib/email_helper/verify.rb b/lib/email_helper/verify.rb
index cd97609bc..c872cce61 100644
--- a/lib/email_helper/verify.rb
+++ b/lib/email_helper/verify.rb
@@ -77,7 +77,7 @@ or
end
# looking for verify email
- (1..10).each {
+ 9.times {
sleep 5
# fetch mailbox
diff --git a/lib/external_credential/facebook.rb b/lib/external_credential/facebook.rb
index 926eb6eb0..750881b31 100644
--- a/lib/external_credential/facebook.rb
+++ b/lib/external_credential/facebook.rb
@@ -53,7 +53,7 @@ class ExternalCredential::Facebook
}
# check if account already exists
- Channel.where(area: 'Facebook::Account').each {|channel|
+ Channel.where(area: 'Facebook::Account').each { |channel|
next if !channel.options
next if !channel.options['user']
next if !channel.options['user']['id']
diff --git a/lib/external_credential/twitter.rb b/lib/external_credential/twitter.rb
index d2659413b..940b66cd8 100644
--- a/lib/external_credential/twitter.rb
+++ b/lib/external_credential/twitter.rb
@@ -39,7 +39,7 @@ class ExternalCredential::Twitter
user = client.user
# check if account already exists
- Channel.where(area: 'Twitter::Account').each {|channel|
+ Channel.where(area: 'Twitter::Account').each { |channel|
next if !channel.options
next if !channel.options['user']
next if !channel.options['user']['id']
diff --git a/lib/facebook.rb b/lib/facebook.rb
index f334d0e00..ff77cdd14 100644
--- a/lib/facebook.rb
+++ b/lib/facebook.rb
@@ -141,7 +141,7 @@ result
}
# ignore if value is already set
- map.each {|target, source|
+ map.each { |target, source|
next if user[target] && !user[target].empty?
new_value = tweet_user.send(source).to_s
next if !new_value || new_value.empty?
@@ -240,7 +240,7 @@ result
to = nil
if post['to'] && post['to']['data']
- post['to']['data'].each {|to_entry|
+ post['to']['data'].each { |to_entry|
if !to
to = ''
else
diff --git a/lib/fill_db.rb b/lib/fill_db.rb
index d7f21120d..32e8c593f 100644
--- a/lib/fill_db.rb
+++ b/lib/fill_db.rb
@@ -113,7 +113,7 @@ e. g.
(1..groups).each {
group = Group.create( name: 'FillGroup::' + rand(999_999).to_s, active: true )
group_pool.push group
- Role.where(name: 'Agent').first.users.where(active: true).each {|user|
+ Role.where(name: 'Agent').first.users.where(active: true).each { |user|
user_groups = user.groups
user_groups.push group
user.groups = user_groups
diff --git a/lib/import/otrs.rb b/lib/import/otrs.rb
index b0e60417f..ba9c1157a 100644
--- a/lib/import/otrs.rb
+++ b/lib/import/otrs.rb
@@ -409,7 +409,7 @@ module Import::OTRS
ActiveRecord::Base.connection.close
}
}
- (1..thread_count).each {|thread|
+ (1..thread_count).each { |thread|
threads[thread].join
}
@@ -591,7 +591,7 @@ module Import::OTRS
},
}
- result.each {|record|
+ result.each { |record|
# cleanup values
_cleanup(record)
@@ -901,7 +901,7 @@ module Import::OTRS
}
# rename states to handle not uniq issues
- Ticket::State.all.each {|state|
+ Ticket::State.all.each { |state|
state.name = state.name + '_tmp'
state.save
}
@@ -1100,8 +1100,8 @@ module Import::OTRS
queue_ids = []
# lookup by groups
- user['GroupIDs'].each {|group_id, permissions|
- queues.each {|queue_lookup|
+ user['GroupIDs'].each { |group_id, permissions|
+ queues.each { |queue_lookup|
next if queue_lookup['GroupID'] != group_id
next if !permissions
@@ -1125,8 +1125,8 @@ module Import::OTRS
local_role_ids = []
# apply group permissions
- user['GroupIDs'].each {|group_id, permissions|
- groups.each {|group_lookup|
+ user['GroupIDs'].each { |group_id, permissions|
+ groups.each { |group_lookup|
next if group_id != group_lookup['ID']
next if !permissions
@@ -1143,15 +1143,15 @@ module Import::OTRS
}
# apply role permissions
- user['RoleIDs'].each {|role_id|
+ user['RoleIDs'].each { |role_id|
# get groups of role
- roles.each {|role|
+ roles.each { |role|
next if role['ID'] != role_id
# verify group names
- role['GroupIDs'].each {|group_id, permissions|
- groups.each {|group_lookup|
+ role['GroupIDs'].each { |group_id, permissions|
+ groups.each { |group_lookup|
next if group_id != group_lookup['ID']
next if !permissions
@@ -1169,7 +1169,7 @@ module Import::OTRS
}
}
- local_roles.each {|role|
+ local_roles.each { |role|
role_lookup = Role.lookup(name: role)
next if !role_lookup
local_role_ids.push role_lookup.id
@@ -1248,7 +1248,7 @@ module Import::OTRS
def self.get_organization_id(user, organizations)
organization_id = nil
if user['UserCustomerID']
- organizations.each {|organization|
+ organizations.each { |organization|
next if user['UserCustomerID'] != organization['CustomerID']
organization = Organization.lookup(name: organization['CustomerCompanyName'])
organization_id = organization.id
@@ -1372,7 +1372,7 @@ module Import::OTRS
# cleanup invalid values
def self._cleanup(record)
- record.each {|key, value|
+ record.each { |key, value|
if value == '0000-00-00 00:00:00'
record[key] = nil
end
diff --git a/lib/import/zendesk.rb b/lib/import/zendesk.rb
index f2933ef79..264000faf 100644
--- a/lib/import/zendesk.rb
+++ b/lib/import/zendesk.rb
@@ -1064,7 +1064,7 @@ module Import::Zendesk
def get_fields(user_fields)
return {} if !user_fields
fields = {}
- user_fields.each {|key, value|
+ user_fields.each { |key, value|
fields[key] = value
}
fields
diff --git a/lib/models.rb b/lib/models.rb
index d9c218949..9e7051ea7 100644
--- a/lib/models.rb
+++ b/lib/models.rb
@@ -67,7 +67,7 @@ returns
def self.searchable
models = []
- all.each {|model_class, _options|
+ all.each { |model_class, _options|
next if !model_class
next if !model_class.respond_to? :search_preferences
models.push model_class
@@ -115,13 +115,13 @@ returns
ref_attributes.push 'created_by_id'
ref_attributes.push 'updated_by_id'
end
- list.each {|model_class, model_attributes|
+ list.each { |model_class, model_attributes|
if !references[model_class.to_s]
references[model_class.to_s] = {}
end
next if !model_attributes[:attributes]
- ref_attributes.each {|item|
+ ref_attributes.each { |item|
next if !model_attributes[:attributes].include?(item)
count = model_class.where("#{item} = ?", object_id).count
@@ -135,9 +135,9 @@ returns
}
# find relations via reflections
- list.each {|model_class, model_attributes|
+ list.each { |model_class, model_attributes|
next if !model_attributes[:reflections]
- model_attributes[:reflections].each {|_reflection_key, reflection_value|
+ model_attributes[:reflections].each { |_reflection_key, reflection_value|
next if reflection_value.macro != :belongs_to
col_name = "#{reflection_value.name}_id"
@@ -167,7 +167,7 @@ returns
}
# cleanup, remove models with empty references
- references.each {|k, v|
+ references.each { |k, v|
next if !v.empty?
references.delete(k)
}
@@ -190,8 +190,8 @@ returns
def self.references_total(object_name, object_id)
references = references(object_name, object_id)
total = 0
- references.each {|_model, model_references|
- model_references.each {|_col, count|
+ references.each { |_model, model_references|
+ model_references.each { |_col, count|
total += count
}
}
@@ -222,14 +222,14 @@ returns
# update references
references = references(object_name, object_id_to_merge)
- references.each {|model, attributes|
+ references.each { |model, attributes|
model_object = Object.const_get(model)
# collect items and attributes to update
items_to_update = {}
- attributes.each {|attribute, _count|
+ attributes.each { |attribute, _count|
Rails.logger.debug "#{object_name}: #{model}.#{attribute}->#{object_id_to_merge}->#{object_id_primary}"
- model_object.where("#{attribute} = ?", object_id_to_merge).each {|item|
+ model_object.where("#{attribute} = ?", object_id_to_merge).each { |item|
if !items_to_update[item.id]
items_to_update[item.id] = item
end
@@ -239,7 +239,7 @@ returns
# update items
ActiveRecord::Base.transaction do
- items_to_update.each {|_id, item|
+ items_to_update.each { |_id, item|
item.save
}
end
diff --git a/lib/notification_factory/mailer.rb b/lib/notification_factory/mailer.rb
index d4106b226..e4763d238 100644
--- a/lib/notification_factory/mailer.rb
+++ b/lib/notification_factory/mailer.rb
@@ -38,7 +38,7 @@ returns
hit = true
else
hit = false
- selected_group_ids.each {|selected_group_id|
+ selected_group_ids.each { |selected_group_id|
if selected_group_id.to_s == ticket.group_id.to_s
hit = true
break
@@ -165,7 +165,7 @@ retunes
def self.already_sent?(ticket, recipient, type)
result = ticket.history_get()
count = 0
- result.each {|item|
+ result.each { |item|
next if item['type'] != 'notification'
next if item['object'] != 'Ticket'
next if item['value_to'] !~ /#{recipient.email}/i
diff --git a/lib/notification_factory/template.rb b/lib/notification_factory/template.rb
index a0244a6ce..13e740186 100644
--- a/lib/notification_factory/template.rb
+++ b/lib/notification_factory/template.rb
@@ -25,7 +25,7 @@ class NotificationFactory::Template
object_name = object_methods.shift.to_sym
object_refs = @objects[object_name]
object_methods_s = ''
- object_methods.each {|method|
+ object_methods.each { |method|
if object_methods_s != ''
object_methods_s += '.'
end
diff --git a/lib/report/article_by_type_sender.rb b/lib/report/article_by_type_sender.rb
index c79a8457d..575146769 100644
--- a/lib/report/article_by_type_sender.rb
+++ b/lib/report/article_by_type_sender.rb
@@ -43,7 +43,7 @@ returns
start = Time.zone.parse(params[:range_start])
stop_interval = 60
end
- (1..stop_interval).each {|_counter|
+ (1..stop_interval).each { |_counter|
if params[:interval] == 'month'
stop = start.next_month
elsif params[:interval] == 'week'
diff --git a/lib/report/base.rb b/lib/report/base.rb
index 21283bee0..b5654a2a1 100644
--- a/lib/report/base.rb
+++ b/lib/report/base.rb
@@ -128,7 +128,7 @@ class Report::Base
'histories.created_at >= ? AND histories.created_at <= ? AND histories.history_object_id = ? AND histories.history_type_id = ?', data[:start], data[:end], history_object.id, history_type.id
)
.where(query, *bind_params).joins(tables)
- histories.each {|history|
+ histories.each { |history|
count += 1
ticket_ids.push history.o_id
}
@@ -209,7 +209,7 @@ class Report::Base
data[:id_to],
)
end
- histories.each {|history|
+ histories.each { |history|
count += 1
ticket_ids.push history.o_id
}
@@ -232,7 +232,7 @@ class Report::Base
.where(query, *bind_params).joins(tables)
tickets = 0
time_total = 0
- ticket_list.each {|ticket|
+ ticket_list.each { |ticket|
timestamp = ticket[ data[:type].to_sym ]
next if !timestamp
# puts 'FR:' + first_response.to_s
@@ -264,7 +264,7 @@ class Report::Base
tickets = 0
time_min = 0
ticket_ids = []
- ticket_list.each {|ticket|
+ ticket_list.each { |ticket|
timestamp = ticket[ data[:type].to_sym ]
next if !timestamp
ticket_ids.push ticket.id
@@ -301,7 +301,7 @@ class Report::Base
tickets = 0
time_max = 0
ticket_ids = []
- ticket_list.each {|ticket|
+ ticket_list.each { |ticket|
timestamp = ticket[ data[:type].to_sym ]
next if !timestamp
ticket_ids.push ticket.id
@@ -331,7 +331,7 @@ class Report::Base
def self.ticket_condition(ticket_id, condition)
ticket = Ticket.lookup( id: ticket_id )
match = true
- condition.each {|key, value|
+ condition.each { |key, value|
if ticket[key.to_sym] != value
return false
end
diff --git a/lib/report/ticket_backlog.rb b/lib/report/ticket_backlog.rb
index eb70ee939..345119364 100644
--- a/lib/report/ticket_backlog.rb
+++ b/lib/report/ticket_backlog.rb
@@ -27,7 +27,7 @@ returns
closed = Report::TicketGenericTime.aggs(local_params)
result = []
- (0..created.length - 1).each {|position|
+ (0..created.length - 1).each { |position|
count = created[position] - closed[position]
result.push count
}
diff --git a/lib/report/ticket_first_solution.rb b/lib/report/ticket_first_solution.rb
index e9f92818f..ee8b1924a 100644
--- a/lib/report/ticket_first_solution.rb
+++ b/lib/report/ticket_first_solution.rb
@@ -38,7 +38,7 @@ returns
start = Time.zone.parse(params[:range_start])
stop_interval = 60
end
- (1..stop_interval).each {|_counter|
+ (1..stop_interval).each { |_counter|
if params[:interval] == 'month'
stop = start.next_month
elsif params[:interval] == 'week'
@@ -57,7 +57,7 @@ returns
stop,
).where(query, *bind_params).joins(tables)
count = 0
- ticket_list.each {|ticket|
+ ticket_list.each { |ticket|
closed_at = ticket.close_time
created_at = ticket.created_at
if (closed_at - (60 * 15) ) < created_at
@@ -98,7 +98,7 @@ returns
count = 0
assets = {}
ticket_ids = []
- ticket_list.each {|ticket|
+ ticket_list.each { |ticket|
closed_at = ticket.close_time
created_at = ticket.created_at
if (closed_at - (60 * 15) ) < created_at
diff --git a/lib/report/ticket_generic_time.rb b/lib/report/ticket_generic_time.rb
index b557a3a53..71cb6a992 100644
--- a/lib/report/ticket_generic_time.rb
+++ b/lib/report/ticket_generic_time.rb
@@ -53,7 +53,7 @@ returns
stop_interval = 60
end
result = []
- (1..stop_interval).each {|_counter|
+ (1..stop_interval).each { |_counter|
match = false
if !result_es
raise "Invalid es result #{result_es.inspect}"
@@ -67,7 +67,7 @@ returns
if !result_es['aggregations']['time_buckets']['buckets']
raise "Invalid es result, no buckets #{result_es.inspect}"
end
- result_es['aggregations']['time_buckets']['buckets'].each {|item|
+ result_es['aggregations']['time_buckets']['buckets'].each { |item|
if params[:interval] == 'minute'
item['key_as_string'] = item['key_as_string'].sub(/:\d\d.\d\d\dZ$/, '')
start_string = start.iso8601.sub(/:\d\dZ$/, '')
@@ -147,7 +147,7 @@ returns
result = SearchIndexBackend.selectors(['Ticket'], selector, limit, nil, aggs_interval)
assets = {}
- result[:ticket_ids].each {|ticket_id|
+ result[:ticket_ids].each { |ticket_id|
ticket_full = Ticket.find(ticket_id)
assets = ticket_full.assets(assets)
}
diff --git a/lib/report/ticket_moved.rb b/lib/report/ticket_moved.rb
index b9302231e..b105f78c1 100644
--- a/lib/report/ticket_moved.rb
+++ b/lib/report/ticket_moved.rb
@@ -46,7 +46,7 @@ returns
start = Time.zone.parse(params[:range_start])
stop_interval = 60
end
- (1..stop_interval).each {|_counter|
+ (1..stop_interval).each { |_counter|
if params[:interval] == 'month'
stop = start.next_month
elsif params[:interval] == 'week'
@@ -124,7 +124,7 @@ returns
local_params = defaults.merge(local_params)
result = history(local_params)
assets = {}
- result[:ticket_ids].each {|ticket_id|
+ result[:ticket_ids].each { |ticket_id|
ticket_full = Ticket.find(ticket_id)
assets = ticket_full.assets(assets)
}
diff --git a/lib/report/ticket_reopened.rb b/lib/report/ticket_reopened.rb
index 0313f7b47..3a9ddda81 100644
--- a/lib/report/ticket_reopened.rb
+++ b/lib/report/ticket_reopened.rb
@@ -40,7 +40,7 @@ returns
start = Time.zone.parse(params[:range_start])
stop_interval = 60
end
- (1..stop_interval).each {|_counter|
+ (1..stop_interval).each { |_counter|
if params[:interval] == 'month'
stop = start.next_month
elsif params[:interval] == 'week'
@@ -99,7 +99,7 @@ returns
selector: params[:selector]
)
assets = {}
- result[:ticket_ids].each {|ticket_id|
+ result[:ticket_ids].each { |ticket_id|
ticket_full = Ticket.find(ticket_id)
assets = ticket_full.assets(assets)
}
@@ -113,8 +113,8 @@ returns
return ticket_state_ids if ticket_state_ids
ticket_state_types = Ticket::StateType.where( name: %w(closed merged removed) )
ticket_state_ids = []
- ticket_state_types.each {|ticket_state_type|
- ticket_state_type.states.each {|ticket_state|
+ ticket_state_types.each { |ticket_state_type|
+ ticket_state_type.states.each { |ticket_state|
ticket_state_ids.push ticket_state.id
}
}
diff --git a/lib/search_index_backend.rb b/lib/search_index_backend.rb
index 2e2106755..93f72535c 100644
--- a/lib/search_index_backend.rb
+++ b/lib/search_index_backend.rb
@@ -314,7 +314,7 @@ get count of tickets and tickets which match on selector
if !aggs_interval || !aggs_interval[:interval]
ticket_ids = []
- response.data['hits']['hits'].each {|item|
+ response.data['hits']['hits'].each { |item|
ticket_ids.push item['_id']
}
return {
@@ -331,7 +331,7 @@ get count of tickets and tickets which match on selector
query_must = []
query_must_not = []
if selector && !selector.empty?
- selector.each {|key, data|
+ selector.each { |key, data|
key_tmp = key.sub(/^.+?\./, '')
t = {}
if data['value'].class == Array
diff --git a/lib/session_helper.rb b/lib/session_helper.rb
index c38f0e248..fbb4c0bcc 100644
--- a/lib/session_helper.rb
+++ b/lib/session_helper.rb
@@ -18,7 +18,7 @@ module SessionHelper
def self.models(user = nil)
models = {}
objects = ObjectManager.list_objects
- objects.each {|object|
+ objects.each { |object|
attributes = ObjectManager::Attribute.by_object(object, user)
models[object] = attributes
}
diff --git a/lib/sessions.rb b/lib/sessions.rb
index 35b4f3e53..2542f64a0 100644
--- a/lib/sessions.rb
+++ b/lib/sessions.rb
@@ -332,7 +332,7 @@ returns
# list all current clients
client_list = sessions
- client_list.each {|client_id|
+ client_list.each { |client_id|
session = Sessions.get(client_id)
next if !session
next if !session[:user]
@@ -368,7 +368,7 @@ broadcase also not to sender
# list all current clients
recipients = []
client_list = sessions
- client_list.each {|client_id|
+ client_list.each { |client_id|
session = Sessions.get(client_id)
next if !session
@@ -411,12 +411,12 @@ returns
path = "#{@path}/#{client_id}/"
data = []
files = []
- Dir.foreach(path) {|entry|
+ Dir.foreach(path) { |entry|
next if entry == '.'
next if entry == '..'
files.push entry
}
- files.sort.each {|entry|
+ files.sort.each { |entry|
filename = "#{path}/#{entry}"
if /^send/ =~ entry
data.push Sessions.queue_file_read(path, entry)
@@ -464,12 +464,12 @@ returns
data = []
to_delete = []
files = []
- Dir.foreach(path) {|entry|
+ Dir.foreach(path) { |entry|
next if entry == '.'
next if entry == '..'
files.push entry
}
- files.sort.each {|entry|
+ files.sort.each { |entry|
filename = "#{path}/#{entry}"
next if !File.exist?(filename)
File.open(filename, 'rb') { |file|
@@ -528,7 +528,7 @@ returns
end
}
}
- to_delete.each {|file|
+ to_delete.each { |file|
File.delete(file)
}
data
@@ -637,7 +637,7 @@ returns
end
def self.symbolize_keys(hash)
- hash.each_with_object({}) {|(key, value), result|
+ hash.each_with_object({}) { |(key, value), result|
new_key = case key
when String then key.to_sym
else key
diff --git a/lib/sessions/backend/collections.rb b/lib/sessions/backend/collections.rb
index 25668b8b9..ea8c22ff2 100644
--- a/lib/sessions/backend/collections.rb
+++ b/lib/sessions/backend/collections.rb
@@ -11,7 +11,7 @@ class Sessions::Backend::Collections < Sessions::Backend::Base
def push
results = []
- @backends.each {|backend|
+ @backends.each { |backend|
#puts "B: #{backend.inspect}"
result = backend.push
#puts "R: #{result.inspect}"
diff --git a/lib/sessions/backend/collections/base.rb b/lib/sessions/backend/collections/base.rb
index 24010785a..c11ca0f58 100644
--- a/lib/sessions/backend/collections/base.rb
+++ b/lib/sessions/backend/collections/base.rb
@@ -25,7 +25,7 @@ class Sessions::Backend::Collections::Base < Sessions::Backend::Base
# check role based access
if self.class.roles
access = false
- self.class.roles.each {|role|
+ self.class.roles.each { |role|
next if !@user.role?(role)
access = true
break
@@ -34,7 +34,7 @@ class Sessions::Backend::Collections::Base < Sessions::Backend::Base
end
if self.class.not_roles
access = false
- self.class.not_roles.each {|role|
+ self.class.not_roles.each { |role|
next if @user.role?(role)
access = true
break
@@ -61,13 +61,13 @@ class Sessions::Backend::Collections::Base < Sessions::Backend::Base
# get relations of data
all = []
- items.each {|item|
+ items.each { |item|
all.push item.attributes_with_associations
}
# collect assets
assets = {}
- items.each {|item|
+ items.each { |item|
next if !asset_needed?(item)
assets = item.assets(assets)
}
diff --git a/lib/sessions/backend/ticket_overview_list.rb b/lib/sessions/backend/ticket_overview_list.rb
index fc47b9ccd..bf80cbda4 100644
--- a/lib/sessions/backend/ticket_overview_list.rb
+++ b/lib/sessions/backend/ticket_overview_list.rb
@@ -100,7 +100,7 @@ class Sessions::Backend::TicketOverviewList < Sessions::Backend::Base
if asset_needed?(overview)
assets = overview.assets(assets)
end
- index[:tickets].each {|ticket_meta|
+ index[:tickets].each { |ticket_meta|
ticket = Ticket.lookup(id: ticket_meta[:id])
next if !asset_needed?(ticket)
assets = ticket.assets(assets)
diff --git a/lib/sessions/client.rb b/lib/sessions/client.rb
index 067b6bd6d..35daf84a6 100644
--- a/lib/sessions/client.rb
+++ b/lib/sessions/client.rb
@@ -43,7 +43,7 @@ class Sessions::Client
# create new pool
backend_pool = []
- backends.each {|backend|
+ backends.each { |backend|
item = backend.constantize.new(user, asset_lookup, self, @client_id)
backend_pool.push item
}
diff --git a/lib/sessions/event/broadcast.rb b/lib/sessions/event/broadcast.rb
index ef874d76e..255d43d60 100644
--- a/lib/sessions/event/broadcast.rb
+++ b/lib/sessions/event/broadcast.rb
@@ -4,7 +4,7 @@ class Sessions::Event::Broadcast < Sessions::Event::Base
# list all current clients
client_list = Sessions.list
- client_list.each {|local_client_id, local_client|
+ client_list.each { |local_client_id, local_client|
if local_client_id == @client_id
log 'notice', 'do not send broadcast to it self'
next
diff --git a/lib/sessions/event/chat_status_agent.rb b/lib/sessions/event/chat_status_agent.rb
index b9f5e71aa..3266af4e2 100644
--- a/lib/sessions/event/chat_status_agent.rb
+++ b/lib/sessions/event/chat_status_agent.rb
@@ -11,7 +11,7 @@ class Sessions::Event::ChatStatusAgent < Sessions::Event::ChatBase
Chat::Agent.state(@session['id'], state)
# update recipients of existing sessions
- Chat::Session.where(state: 'running', user_id: @session['id']).order('created_at ASC').each {|chat_session|
+ Chat::Session.where(state: 'running', user_id: @session['id']).order('created_at ASC').each { |chat_session|
chat_session.add_recipient(@client_id, true)
}
{
diff --git a/lib/signature_detection.rb b/lib/signature_detection.rb
index f0275bbe2..28942adf8 100644
--- a/lib/signature_detection.rb
+++ b/lib/signature_detection.rb
@@ -22,7 +22,7 @@ returns
def self.find_signature(messages)
string_list = []
- messages.each {|message|
+ messages.each { |message|
if message[:content_type] =~ %r{text/html}i
string_list.push message[:content].html2text(true)
next
@@ -38,7 +38,7 @@ returns
break if main_string_index + 1 > string_list.length - 1
# loop all all strings in array except of the previous index
- ( main_string_index + 1..string_list.length - 1 ).each {|second_string_index|
+ ( main_string_index + 1..string_list.length - 1 ).each { |second_string_index|
# get content of string 1
string1_content = string_list[main_string_index]
@@ -56,7 +56,7 @@ returns
match_block = nil
# loop of lines of the diff result
- ( 0..diff_result_array.length - 1 ).each {|diff_string_index|
+ ( 0..diff_result_array.length - 1 ).each { |diff_string_index|
# if no block with difference is defined then we try to find a string block without a difference
if !match_block
@@ -83,7 +83,7 @@ returns
# get string of possible signature, use only the first 10 lines
match_max_content = 0
match_content = ''
- ( match_block..match_block_total ).each {|match_block_index|
+ ( match_block..match_block_total ).each { |match_block_index|
break if match_max_content == 10
match_max_content += 1
match_content += "#{diff_result_array[match_block_index][1..-1]}\n"
@@ -187,7 +187,7 @@ returns
create_article_sender_id: sender.id
).limit(5).order(id: :desc)
article_bodies = []
- tickets.each {|ticket|
+ tickets.each { |ticket|
article = ticket.articles.first
next if !article
data = {
@@ -213,7 +213,7 @@ returns
=end
def self.rebuild_all_user
- User.select('id').where(active: true).order(id: :desc).each {|local_user|
+ User.select('id').where(active: true).order(id: :desc).each { |local_user|
rebuild_user(local_user.id)
}
true
@@ -259,7 +259,7 @@ returns
def self.rebuild_all_articles
article_type = Ticket::Article::Type.lookup(name: 'email')
- Ticket::Article.select('id').where(type_id: article_type.id).order(id: :desc).each {|local_article|
+ Ticket::Article.select('id').where(type_id: article_type.id).order(id: :desc).each { |local_article|
article = Ticket::Article.find(local_article.id)
user = User.find(article.created_by_id)
next if !user.preferences[:signature_detection]
diff --git a/lib/sso.rb b/lib/sso.rb
index 5301788b6..ea18e21d1 100644
--- a/lib/sso.rb
+++ b/lib/sso.rb
@@ -25,7 +25,7 @@ returns
]
# added configured backends
- Setting.where( area: 'Security::SSO' ).each {|setting|
+ Setting.where( area: 'Security::SSO' ).each { |setting|
if setting.state_current[:value]
config.push setting.state_current[:value]
end
@@ -33,7 +33,7 @@ returns
# try to login against configure auth backends
user_auth = nil
- config.each {|config_item|
+ config.each { |config_item|
next if !config_item[:adapter]
# load backend
diff --git a/lib/stats.rb b/lib/stats.rb
index 986e23bce..eb019cf29 100644
--- a/lib/stats.rb
+++ b/lib/stats.rb
@@ -30,12 +30,12 @@ returns
users = User.of_role('Agent')
agent_count = 0
user_result = {}
- users.each {|user|
+ users.each { |user|
next if user.id == 1
next if !user.active
agent_count += 1
data = {}
- backends.each {|backend|
+ backends.each { |backend|
data[backend] = backend.generate(user)
}
user_result[user.id] = data
@@ -43,8 +43,8 @@ returns
# calculate average
backend_average_sum = {}
- user_result.each {|_user_id, data|
- data.each {|backend_model, backend_result|
+ user_result.each { |_user_id, data|
+ data.each { |backend_model, backend_result|
next if !backend_result.key?(:used_for_average)
if !backend_average_sum[backend_model]
backend_average_sum[backend_model] = 0
@@ -54,9 +54,9 @@ returns
}
# generate average param and icon state
- backend_average_sum.each {|backend_model_average, result|
+ backend_average_sum.each { |backend_model_average, result|
average = ( result.to_f / agent_count.to_f ).round(1)
- user_result.each {|user_id, data|
+ user_result.each { |user_id, data|
next if !data[backend_model_average]
next if !data[backend_model_average].key?(:used_for_average)
data[backend_model_average][:average_per_agent] = average
@@ -66,9 +66,9 @@ returns
}
}
- user_result.each {|user_id, data|
+ user_result.each { |user_id, data|
data_for_user = {}
- data.each {|backend, result|
+ data.each { |backend, result|
data_for_user[backend.to_app_model] = result
}
state_store = StatsStore.sync(
diff --git a/lib/stats/ticket_channel_distribution.rb b/lib/stats/ticket_channel_distribution.rb
index fdebba8ee..6a73f4e31 100644
--- a/lib/stats/ticket_channel_distribution.rb
+++ b/lib/stats/ticket_channel_distribution.rb
@@ -34,12 +34,12 @@ class Stats::TicketChannelDistribution
result = {}
total_in = 0
total_out = 0
- channels.each {|channel|
+ channels.each { |channel|
result[channel[:sender].to_sym] = {
icon: channel[:icon]
}
type_ids = []
- Ticket::Article::Type.all.each {|type|
+ Ticket::Article::Type.all.each { |type|
next if type.name !~ /^#{channel[:sender]}/i
type_ids.push type.id
}
@@ -64,7 +64,7 @@ class Stats::TicketChannelDistribution
}
# append in percent
- channels.each {|channel|
+ channels.each { |channel|
count = result[channel[:sender].to_sym][:inbound]
#puts "#{channel.inspect}:in/#{result.inspect}:#{count}"
in_process_precent = if count.zero?
diff --git a/lib/stats/ticket_response_time.rb b/lib/stats/ticket_response_time.rb
index 1952722e7..7d44022ca 100644
--- a/lib/stats/ticket_response_time.rb
+++ b/lib/stats/ticket_response_time.rb
@@ -27,7 +27,7 @@ class Stats::TicketResponseTime
total = 0
count_own = 0
own = 0
- items.each {|_item|
+ items.each { |_item|
ticket = Ticket.lookup(id: data[:ticket_id])
if ticket.owner_id == user.id
count_own += 1
diff --git a/lib/tasks/search_index_es.rake b/lib/tasks/search_index_es.rake
index 6278cbba5..705c61be5 100644
--- a/lib/tasks/search_index_es.rake
+++ b/lib/tasks/search_index_es.rake
@@ -42,7 +42,7 @@ namespace :searchindex do
task :reload, [:opts] => :environment do |_t, _args|
puts 'reload data...'
- Models.searchable.each {|model_class|
+ Models.searchable.each { |model_class|
puts " reload #{model_class}"
started_at = Time.zone.now
puts " - started at #{started_at}"
diff --git a/lib/tweet_base.rb b/lib/tweet_base.rb
index 7fd44dc23..10f4157f0 100644
--- a/lib/tweet_base.rb
+++ b/lib/tweet_base.rb
@@ -46,7 +46,7 @@ class TweetBase
}
# ignore if value is already set
- map.each {|target, source|
+ map.each { |target, source|
next if user[target] && !user[target].empty?
new_value = tweet_user.send(source).to_s
next if !new_value || new_value.empty?
@@ -159,7 +159,7 @@ class TweetBase
article_type = 'twitter status'
from = "@#{tweet.user.screen_name}"
if tweet.user_mentions
- tweet.user_mentions.each {|local_user|
+ tweet.user_mentions.each { |local_user|
if !to
to = ''
else
@@ -206,7 +206,7 @@ class TweetBase
# if sender is a system account, wait until twitter message id is stored
# on article to prevent two (own created & twitter created) articles
tweet_user = user(tweet)
- Channel.where(area: 'Twitter::Account').each {|local_channel|
+ Channel.where(area: 'Twitter::Account').each { |local_channel|
next if !local_channel.options
next if !local_channel.options[:user]
next if !local_channel.options[:user][:id]
diff --git a/lib/user_agent.rb b/lib/user_agent.rb
index 8fb48b3bd..16459a691 100644
--- a/lib/user_agent.rb
+++ b/lib/user_agent.rb
@@ -307,7 +307,7 @@ returns
content_encoding: request['Content-Encoding'],
source: request['User-Agent'] || request['Server'],
}
- request.each_header {|key, value|
+ request.each_header { |key, value|
request_data[:content] += "#{key}: #{value}\n"
}
body = request.body
@@ -329,7 +329,7 @@ returns
response_data[:content_type] = response['Content-Type']
response_data[:content_encoding] = response['Content-Encoding']
response_data[:source] = response['User-Agent'] || response['Server']
- response.each_header {|key, value|
+ response.each_header { |key, value|
response_data[:content] += "#{key}: #{value}\n"
}
body = response.body
diff --git a/script/websocket-server.rb b/script/websocket-server.rb
index b6fa8bd68..87b4c5a7b 100755
--- a/script/websocket-server.rb
+++ b/script/websocket-server.rb
@@ -99,7 +99,7 @@ EventMachine.run {
EventMachine::WebSocket.start( host: @options[:b], port: @options[:p], secure: @options[:s], tls_options: tls_options ) do |ws|
# register client connection
- ws.onopen {|handshake|
+ ws.onopen { |handshake|
headers = handshake.headers
remote_ip = get_remote_ip(headers)
client_id = ws.object_id.to_s
@@ -194,12 +194,12 @@ EventMachine.run {
# ajax
client_list = Sessions.list
clients = 0
- client_list.each {|_client_id, client|
+ client_list.each { |_client_id, client|
next if client[:meta][:type] == 'websocket'
clients = clients + 1
}
log 'notice', "Status: ajax clients: #{clients}"
- client_list.each {|client_id, client|
+ client_list.each { |client_id, client|
next if client[:meta][:type] == 'websocket'
log 'notice', 'working...', client_id
}
diff --git a/test/browser/aaa_getting_started_test.rb b/test/browser/aaa_getting_started_test.rb
index 529d8f9f9..045e6cb59 100644
--- a/test/browser/aaa_getting_started_test.rb
+++ b/test/browser/aaa_getting_started_test.rb
@@ -200,7 +200,7 @@ class AaaGettingStartedTest < TestCase
def test_b_accounts_auto
#return # TODO: temp disable
accounts = []
- (1..10).each {|count|
+ (1..10).each { |count|
next if !ENV["MAILBOX_AUTO#{count}"]
mailbox_user = ENV["MAILBOX_AUTO#{count}"].split(':')[0]
mailbox_password = ENV["MAILBOX_AUTO#{count}"].split(':')[1]
@@ -222,7 +222,7 @@ class AaaGettingStartedTest < TestCase
password: 'test',
url: browser_url,
)
- accounts.each {|account|
+ accounts.each { |account|
# getting started - auto mail
location(url: browser_url + '/#getting_started/channel')
@@ -263,7 +263,7 @@ class AaaGettingStartedTest < TestCase
def test_b_accounts_manual
#return # TODO: temp disable
accounts = []
- (1..10).each {|count|
+ (1..10).each { |count|
next if !ENV["MAILBOX_MANUAL#{count}"]
mailbox_user = ENV["MAILBOX_MANUAL#{count}"].split(':')[0]
mailbox_password = ENV["MAILBOX_MANUAL#{count}"].split(':')[1]
@@ -294,7 +294,7 @@ class AaaGettingStartedTest < TestCase
password: 'test',
url: browser_url,
)
- accounts.each {|account|
+ accounts.each { |account|
# getting started - manual mail
location(url: browser_url + '/#getting_started/channel')
diff --git a/test/browser/first_steps_test.rb b/test/browser/first_steps_test.rb
index b7bc3262d..6854cabaf 100644
--- a/test/browser/first_steps_test.rb
+++ b/test/browser/first_steps_test.rb
@@ -117,7 +117,7 @@ class FirstStepsTest < TestCase
)
click(css: '#navigation a[href="#dashboard"]')
hit = false
- (1..38).each {
+ 37.times {
next if !@browser.find_elements(css: '.active.content a[href="#channels/form"].todo.is-done')[0]
hit = true
break
diff --git a/test/browser/keyboard_shortcuts_test.rb b/test/browser/keyboard_shortcuts_test.rb
index 00227381d..b4385be23 100644
--- a/test/browser/keyboard_shortcuts_test.rb
+++ b/test/browser/keyboard_shortcuts_test.rb
@@ -18,7 +18,7 @@ class KeyboardShortcutsTest < TestCase
# ff issue, sometimes shortcut is not fired in browser test env
if ENV['BROWSER'] && ENV['BROWSER'] =~ /firefox/i
exists = false
- (1..4).each {|_count|
+ (1..4).each { |_count|
sleep 1
next if !@browser.find_elements(css: '.modal')[0]
exists = true
@@ -27,7 +27,7 @@ class KeyboardShortcutsTest < TestCase
reload
sleep 4
shortcut(key: 'h')
- (1..4).each {|_count|
+ (1..4).each { |_count|
sleep 1
next if !@browser.find_elements(css: '.modal')[0]
exists = true
diff --git a/test/browser_test_helper.rb b/test/browser_test_helper.rb
index 55f12e848..f8d99d748 100644
--- a/test/browser_test_helper.rb
+++ b/test/browser_test_helper.rb
@@ -55,7 +55,7 @@ class TestCase < Test::Unit::TestCase
end
# avoid "Cannot read property 'get_Current' of undefined" issues
- (1..5).each {|count|
+ (1..5).each { |count|
begin
local_browser = browser_instance_remote
break
@@ -258,7 +258,7 @@ class TestCase < Test::Unit::TestCase
mute_log: true,
)
- (1..6).each {
+ 5.times {
sleep 1
login = instance.find_elements(css: '#login')[0]
@@ -611,7 +611,7 @@ class TestCase < Test::Unit::TestCase
else
element.send_keys('')
keys = params[:value].to_s.split('')
- keys.each {|key|
+ keys.each { |key|
instance.action.send_keys(key).perform
}
end
@@ -766,7 +766,7 @@ class TestCase < Test::Unit::TestCase
instance = params[:browser] || @browser
if params[:value].class == Array
- params[:value].each {|key|
+ params[:value].each { |key|
instance.action.send_keys(key).perform
}
return
@@ -803,7 +803,7 @@ class TestCase < Test::Unit::TestCase
dropdown = Selenium::WebDriver::Support::Select.new(element)
success = false
if dropdown.selected_options
- dropdown.selected_options.each {|option|
+ dropdown.selected_options.each { |option|
if option.text == params[:value]
success = true
end
@@ -939,7 +939,7 @@ class TestCase < Test::Unit::TestCase
end
cookies = instance.manage.all_cookies
- cookies.each {|cookie|
+ cookies.each { |cookie|
#puts "CCC #{cookie.inspect}"
# :name=>"_zammad_session_c25832f4de2", :value=>"adc31cd21615cb0a7ab269184ec8b76f", :path=>"/", :domain=>"localhost", :expires=>nil, :secure=>false}
next if cookie[:name] !~ /#{params[:name]}/i
@@ -1142,7 +1142,7 @@ class TestCase < Test::Unit::TestCase
instance = params[:browser] || @browser
- params[:files].each {|file|
+ params[:files].each { |file|
instance.find_elements(css: params[:css])[0].send_keys "#{Rails.root}/#{file}"
}
sleep 2 * params[:files].count
@@ -1309,7 +1309,7 @@ wait untill text in selector disabppears
instance = params[:browser] || @browser
- (1..100).each do
+ 99.times do
#sleep 0.5
begin
if instance.find_elements(css: '.navigation .tasks .task:first-child')[0]
@@ -1394,7 +1394,7 @@ wait untill text in selector disabppears
instance = params[:browser] || @browser
- (1..100).each do
+ 99.times do
sleep 0.5
begin
if instance.find_elements(css: '.js-notificationsContainer .js-item:first-child')[0]
@@ -1533,7 +1533,7 @@ wait untill text in selector disabppears
end
if data[:selector]
- data[:selector].each {|key, value|
+ data[:selector].each { |key, value|
select(
browser: instance,
css: '.modal .ticket_selector .js-attributeSelector select',
@@ -1562,7 +1562,7 @@ wait untill text in selector disabppears
instance.find_elements(css: '.modal button.js-submit')[0].click
modal_disappear(browser: instance)
- (1..12).each {
+ 11.times {
element = instance.find_elements(css: 'body')[0]
text = element.text
if text =~ /#{Regexp.quote(data[:name])}/
@@ -1634,7 +1634,7 @@ wait untill text in selector disabppears
end
if data[:selector]
- data[:selector].each {|key, value|
+ data[:selector].each { |key, value|
select(
browser: instance,
css: '.modal .ticket_selector .js-attributeSelector select',
@@ -1663,7 +1663,7 @@ wait untill text in selector disabppears
instance.find_elements(css: '.modal button.js-submit')[0].click
modal_disappear(browser: instance)
- (1..12).each {
+ 11.times {
element = instance.find_elements(css: 'body')[0]
text = element.text
if text =~ /#{Regexp.quote(data[:name])}/
@@ -1742,7 +1742,7 @@ wait untill text in selector disabppears
)
found = false
- (1..8).each {
+ 7.times {
element = instance.find_elements(css: '.active .newTicket')[0]
if element
found = true
@@ -1849,7 +1849,7 @@ wait untill text in selector disabppears
end
if params[:custom_data_select]
- params[:custom_data_select].each {|local_key, local_value|
+ params[:custom_data_select].each { |local_key, local_value|
select(
browser: instance,
css: ".active .newTicket select[name=\"#{local_key}\"]",
@@ -1858,7 +1858,7 @@ wait untill text in selector disabppears
}
end
if params[:custom_data_input]
- params[:custom_data_input].each {|local_key, local_value|
+ params[:custom_data_input].each { |local_key, local_value|
set(
browser: instance,
css: ".active .newTicket input[name=\"#{local_key}\"]",
@@ -1889,7 +1889,7 @@ wait untill text in selector disabppears
)
sleep 1
- (1..10).each {
+ 9.times {
if instance.current_url =~ /#{Regexp.quote('#ticket/zoom/')}/
assert(true, 'ticket created')
sleep 2.5
@@ -2082,7 +2082,7 @@ wait untill text in selector disabppears
end
if params[:custom_data_select]
- params[:custom_data_select].each {|local_key, local_value|
+ params[:custom_data_select].each { |local_key, local_value|
select(
browser: instance,
css: ".active .sidebar select[name=\"#{local_key}\"]",
@@ -2091,7 +2091,7 @@ wait untill text in selector disabppears
}
end
if params[:custom_data_input]
- params[:custom_data_input].each {|local_key, local_value|
+ params[:custom_data_input].each { |local_key, local_value|
set(
browser: instance,
css: ".active .sidebar input[name=\"#{local_key}\"]",
@@ -2103,7 +2103,7 @@ wait untill text in selector disabppears
if data[:state] || data[:group] || data[:body] || !params[:custom_data_select].empty? || !params[:custom_data_input].empty?
found = nil
- (1..10).each {
+ 9.times {
break if found
@@ -2136,7 +2136,7 @@ wait untill text in selector disabppears
instance.find_elements(css: '.content.active .js-submit')[0].click
- (1..10).each {
+ 9.times {
begin
text = instance.find_elements(css: '.content.active .js-reset')[0].text
if !text || text.empty?
@@ -2199,7 +2199,7 @@ wait untill text in selector disabppears
end
if params[:custom_data_select]
- params[:custom_data_select].each {|local_key, local_value|
+ params[:custom_data_select].each { |local_key, local_value|
element = instance.find_elements(css: ".active .sidebar select[name=\"#{local_key}\"] option[selected]").first
value = element.text.strip
if value =~ /#{local_value}/i
@@ -2210,7 +2210,7 @@ wait untill text in selector disabppears
}
end
if params[:custom_data_input]
- params[:custom_data_input].each {|local_key, local_value|
+ params[:custom_data_input].each { |local_key, local_value|
element = instance.find_elements(css: ".active .sidebar input[name=\"#{local_key}\"]").first
value = element.text.strip
if value =~ /#{local_value}/i
@@ -2375,14 +2375,14 @@ wait untill text in selector disabppears
#)
overviews = {}
- instance.find_elements(css: '.content.active .sidebar a[href]').each {|element|
+ instance.find_elements(css: '.content.active .sidebar a[href]').each { |element|
url = element.attribute('href')
url.gsub!(%r{(http|https)://.+?/(.+?)$}, '\\2')
overviews[url] = 0
#puts url.inspect
#puts element.inspect
}
- overviews.each {|url, _value|
+ overviews.each { |url, _value|
count = instance.find_elements(css: ".content.active .sidebar a[href=\"#{url}\"] .badge")[0].text
overviews[url] = count.to_i
}
@@ -2581,7 +2581,7 @@ wait untill text in selector disabppears
element.send_keys(data[:first_response_time_in_text])
instance.find_elements(css: '.modal button.js-submit')[0].click
modal_disappear(browser: instance)
- (1..8).each {
+ 7.times {
element = instance.find_elements(css: 'body')[0]
text = element.text
if text =~ /#{Regexp.quote(data[:name])}/
@@ -2642,7 +2642,7 @@ wait untill text in selector disabppears
element.send_keys(data[:content])
instance.find_elements(css: '.modal button.js-submit')[0].click
modal_disappear(browser: instance)
- (1..8).each {
+ 7.times {
element = instance.find_elements(css: 'body')[0]
text = element.text
if text =~ /#{Regexp.quote(data[:name])}/
@@ -2705,7 +2705,7 @@ wait untill text in selector disabppears
element.send_keys(data[:body])
instance.find_elements(css: '.modal button.js-submit')[0].click
modal_disappear(browser: instance)
- (1..12).each {
+ 11.times {
element = instance.find_elements(css: 'body')[0]
text = element.text
if text =~ /#{Regexp.quote(data[:name])}/
@@ -2771,7 +2771,7 @@ wait untill text in selector disabppears
end
instance.find_elements(css: '.modal button.js-submit')[0].click
modal_disappear(browser: instance)
- (1..12).each {
+ 11.times {
element = instance.find_elements(css: 'body')[0]
text = element.text
if text =~ /#{Regexp.quote(data[:name])}/
@@ -2780,7 +2780,7 @@ wait untill text in selector disabppears
# add member
if data[:member]
- data[:member].each {|login|
+ data[:member].each { |login|
instance.find_elements(css: 'a[href="#manage"]')[0].click
sleep 1
instance.find_elements(css: 'a[href="#manage/users"]')[0].click
@@ -2949,7 +2949,7 @@ wait untill text in selector disabppears
element.clear
element.send_keys(data[:data_option][:options][:false])
else
- data[:data_option][:options].each {|key, value|
+ data[:data_option][:options].each { |key, value|
element = instance.find_elements(css: '.modal .js-Table .js-key').last
element.clear
element.send_keys(key)
@@ -2962,14 +2962,14 @@ wait untill text in selector disabppears
end
end
- [:default, :min, :max, :diff].each {|key|
+ [:default, :min, :max, :diff].each { |key|
next if !data[:data_option].key?(key)
element = instance.find_elements(css: ".modal [name=\"data_option::#{key}\"]").first
element.clear
element.send_keys(data[:data_option][key])
}
- [:future, :past].each {|key|
+ [:future, :past].each { |key|
next if !data[:data_option].key?(key)
select(
browser: instance,
@@ -2995,7 +2995,7 @@ wait untill text in selector disabppears
return
end
- (1..12).each {
+ 11.times {
element = instance.find_elements(css: 'body')[0]
text = element.text
if text =~ /#{Regexp.quote(data[:name])}/
@@ -3105,11 +3105,11 @@ wait untill text in selector disabppears
assert(tags[0])
tags_found = {}
- params[:tags].each {|key, _value|
+ params[:tags].each { |key, _value|
tags_found[key] = false
}
- tags.each {|element|
+ tags.each { |element|
text = element.text
if tags_found.key?(text)
tags_found[text] = true
@@ -3117,7 +3117,7 @@ wait untill text in selector disabppears
assert(false, "tag exists but is not in check to verify '#{text}'")
end
}
- params[:tags].each {|key, value|
+ params[:tags].each { |key, value|
assert_equal(value, tags_found[key], "tag '#{key}'")
}
end
@@ -3144,7 +3144,7 @@ wait untill text in selector disabppears
instance = params[:browser] || @browser
if instance
logs = instance.manage.logs.get(:browser)
- logs.each {|log|
+ logs.each { |log|
next if log.level == 'WARNING' && log.message =~ /Declaration\sdropped./ # ignore ff css warnings
time = Time.zone.parse(Time.zone.at(log.timestamp / 1000).to_datetime.to_s)
puts "#{time}/#{log.level}: #{log.message}"
diff --git a/test/fixtures/seeds.rb b/test/fixtures/seeds.rb
index c58a66cab..158350737 100644
--- a/test/fixtures/seeds.rb
+++ b/test/fixtures/seeds.rb
@@ -18,7 +18,7 @@ email_address = EmailAddress.create_or_update(
updated_by_id: 1,
created_by_id: 1
)
-Group.all.each {|group|
+Group.all.each { |group|
group.email_address_id = email_address.id
group.save
}
diff --git a/test/integration/facebook_test.rb b/test/integration/facebook_test.rb
index 23d27fe94..648feedcf 100644
--- a/test/integration/facebook_test.rb
+++ b/test/integration/facebook_test.rb
@@ -82,7 +82,7 @@ class FacebookTest < ActiveSupport::TestCase
test 'b - available pages' do
client = Facebook.new(user_access_token)
page_found = false
- client.pages.each {|page|
+ client.pages.each { |page|
next if page[:name] != page_name
page_found = true
assert_equal(page_id, page[:id])
@@ -94,7 +94,7 @@ class FacebookTest < ActiveSupport::TestCase
# check access to pages
test 'c - page access' do
page_found = false
- provider_options[:pages].each {|page|
+ provider_options[:pages].each { |page|
client = Facebook.new(page['access_token'])
current_user = client.current_user
next if page['name'] != page_name
diff --git a/test/integration/slack_test.rb b/test/integration/slack_test.rb
index a70a91844..6a99642fc 100644
--- a/test/integration/slack_test.rb
+++ b/test/integration/slack_test.rb
@@ -282,7 +282,7 @@ class SlackTest < ActiveSupport::TestCase
client = Slack::Client.new
channels = client.channels_list['channels']
channel_id = nil
- channels.each {|channel|
+ channels.each { |channel|
next if channel['name'] != channel_name
channel_id = channel['id']
}
@@ -298,7 +298,7 @@ class SlackTest < ActiveSupport::TestCase
raise "ERROR: No history messages for channel #{channel_name}/#{channel_id}"
end
message_count = 0
- channel_history['messages'].each {|message|
+ channel_history['messages'].each { |message|
next if !message['text']
if message['text'] =~ /#{search_for}/i
message_count += 1
diff --git a/test/integration/twitter_test.rb b/test/integration/twitter_test.rb
index f8206bba5..4679cdd04 100644
--- a/test/integration/twitter_test.rb
+++ b/test/integration/twitter_test.rb
@@ -161,7 +161,7 @@ class TwitterTest < ActiveSupport::TestCase
# fetch check system account
sleep 10
article = nil
- (1..2).each {
+ 1.times {
Channel.fetch
# check if follow up article has been created
@@ -203,7 +203,7 @@ class TwitterTest < ActiveSupport::TestCase
# fetch check system account
sleep 20
article = nil
- (1..3).each {
+ 2.times {
Channel.fetch
# check if ticket and article has been created
@@ -261,7 +261,7 @@ class TwitterTest < ActiveSupport::TestCase
config.access_token_secret = system_token_secret
end
dms = client.direct_messages(count: 100)
- dms.each {|dm|
+ dms.each { |dm|
client.destroy_direct_message(dm.id)
}
client = Twitter::REST::Client.new(
@@ -271,7 +271,7 @@ class TwitterTest < ActiveSupport::TestCase
access_token_secret: customer_token_secret
)
dms = client.direct_messages(count: 100)
- dms.each {|dm|
+ dms.each { |dm|
client.destroy_direct_message(dm.id)
}
hash = "#citheo44 #{hash_gen}"
@@ -285,7 +285,7 @@ class TwitterTest < ActiveSupport::TestCase
# fetch check system account
sleep 15
article = nil
- (1..2).each {
+ 1.times {
Channel.fetch
# check if ticket and article has been created
@@ -335,7 +335,7 @@ class TwitterTest < ActiveSupport::TestCase
# fetch check system account
sleep 15
article = nil
- (1..2).each {
+ 1.times {
Channel.fetch
# check if ticket and article has been created
@@ -368,7 +368,7 @@ class TwitterTest < ActiveSupport::TestCase
# fetch check system account
sleep 15
article = nil
- (1..2).each {
+ 1.times {
Channel.fetch
# check if ticket and article has been created
@@ -413,7 +413,7 @@ class TwitterTest < ActiveSupport::TestCase
)
sleep 10
article = nil
- (1..2).each {
+ 1.times {
article = Ticket::Article.find_by(message_id: tweet.id)
break if article
sleep 15
@@ -437,7 +437,7 @@ class TwitterTest < ActiveSupport::TestCase
ActiveRecord::Base.connection.reconnect!
sleep 10
article = nil
- (1..2).each {
+ 1.times {
article = Ticket::Article.find_by(message_id: tweet.id)
break if article
sleep 15
@@ -503,7 +503,7 @@ class TwitterTest < ActiveSupport::TestCase
#ActiveRecord::Base.connection.reconnect!
sleep 10
article = nil
- (1..2).each {
+ 1.times {
article = Ticket::Article.find_by(message_id: dm.id)
break if article
sleep 10
diff --git a/test/integration/zendesk_import_test.rb b/test/integration/zendesk_import_test.rb
index 0f549187e..33656bf91 100644
--- a/test/integration/zendesk_import_test.rb
+++ b/test/integration/zendesk_import_test.rb
@@ -134,7 +134,7 @@ class ZendeskImportTest < ActiveSupport::TestCase
checks.each { |check|
user = User.find(check[:id])
- check[:data].each {|key, value|
+ check[:data].each { |key, value|
assert_equal(value, user[key], "user.#{key} for user_id #{check[:id]}")
}
assert_equal(check[:roles], user.roles.to_a, "#{user.login} roles")
@@ -213,7 +213,7 @@ class ZendeskImportTest < ActiveSupport::TestCase
checks.each { |check|
group = Group.find(check[:id])
- check[:data].each {|key, value|
+ check[:data].each { |key, value|
assert_equal(value, group[key], "group.#{key} for group_id #{check[:id]}")
}
}
@@ -245,7 +245,7 @@ class ZendeskImportTest < ActiveSupport::TestCase
checks.each { |check|
organization = Organization.find(check[:id])
- check[:data].each {|key, value|
+ check[:data].each { |key, value|
assert_equal(value, organization[key], "organization.#{key} for organization_id #{check[:id]}")
}
}
@@ -372,7 +372,7 @@ If you\'re reading this message in your email, click the ticket number link that
checks.each { |check|
ticket = Ticket.find(check[:id])
- check[:data].each {|key, value|
+ check[:data].each { |key, value|
assert_equal(value, ticket[key], "ticket.#{key} for ticket_id #{check[:id]}")
}
}
diff --git a/test/test_helper.rb b/test/test_helper.rb
index ac3f690e6..57e468cab 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -5,9 +5,10 @@ require 'cache'
require 'simplecov'
require 'simplecov-rcov'
-ActiveSupport::TestCase.test_order = :sorted
+#ActiveSupport::TestCase.test_order = :sorted
class ActiveSupport::TestCase
+ self.test_order = :sorted
# Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
#
@@ -54,7 +55,7 @@ class ActiveSupport::TestCase
lines.push line
end
count = 0
- lines.reverse.each {|line|
+ lines.reverse.each { |line|
break if line =~ /\+\+\+\+NEW\+\+\+\+TEST\+\+\+\+/
next if line !~ /Send notification \(#{type}\)/
next if line !~ /to:\s#{recipient}/
diff --git a/test/unit/assets_test.rb b/test/unit/assets_test.rb
index 134e9c416..79bd832e6 100644
--- a/test/unit/assets_test.rb
+++ b/test/unit/assets_test.rb
@@ -266,7 +266,7 @@ class AssetsTest < ActiveSupport::TestCase
def diff(o1, o2)
return true if o1 == o2
- %w(updated_at created_at).each {|item|
+ %w(updated_at created_at).each { |item|
if o1[item]
o1[item] = o1[item].to_s
end
diff --git a/test/unit/auth_test.rb b/test/unit/auth_test.rb
index 0216f87de..ceb607f21 100644
--- a/test/unit/auth_test.rb
+++ b/test/unit/auth_test.rb
@@ -68,7 +68,7 @@ class AuthTest < ActiveSupport::TestCase
if !user
assert(false, 'auth faild')
else
- test[:verify].each {|key, value|
+ test[:verify].each { |key, value|
assert_equal(user[key], value, 'verify')
}
end
diff --git a/test/unit/auto_wizard_test.rb b/test/unit/auto_wizard_test.rb
index 4de69621f..8f8f5c003 100644
--- a/test/unit/auto_wizard_test.rb
+++ b/test/unit/auto_wizard_test.rb
@@ -48,7 +48,7 @@ class AutoWizardTest < ActiveSupport::TestCase
# check first user roles
auto_wizard_data[:Users][0][:roles] = %w(Agent Admin Chat)
- auto_wizard_data[:Users].each {|local_user|
+ auto_wizard_data[:Users].each { |local_user|
user = User.find_by(login: local_user[:login])
assert_equal(local_user[:login], user.login)
assert_equal(local_user[:firstname], user.firstname)
@@ -56,21 +56,21 @@ class AutoWizardTest < ActiveSupport::TestCase
assert_equal(local_user[:email], user.email)
assert_equal(local_user[:roles].count, user.role_ids.count)
next unless local_user[:roles]
- local_user[:roles].each {|local_role_name|
+ local_user[:roles].each { |local_role_name|
local_role = Role.find_by(name: local_role_name)
assert(user.role_ids.include?(local_role.id))
}
}
- auto_wizard_data[:Groups].each {|local_group|
+ auto_wizard_data[:Groups].each { |local_group|
group = Group.find_by(name: local_group[:name])
assert_equal(local_group[:name], group.name)
next unless local_group[:users]
- local_group[:users].each {|local_user_login|
+ local_group[:users].each { |local_user_login|
local_user = User.find_by(login: local_user_login)
assert(group.user_ids.include?(local_user.id))
}
}
- auto_wizard_data[:Settings].each {|local_setting|
+ auto_wizard_data[:Settings].each { |local_setting|
setting_value = Setting.get(local_setting[:name])
assert_equal(local_setting[:value], setting_value)
}
@@ -166,7 +166,7 @@ class AutoWizardTest < ActiveSupport::TestCase
AutoWizard.setup
assert_equal(false, AutoWizard.enabled?)
- auto_wizard_data[:Users].each {|local_user|
+ auto_wizard_data[:Users].each { |local_user|
user = User.find_by(login: local_user[:login])
assert_equal(local_user[:login], user.login)
assert_equal(local_user[:firstname], user.firstname)
@@ -174,16 +174,16 @@ class AutoWizardTest < ActiveSupport::TestCase
assert_equal(local_user[:email], user.email)
next unless local_user[:roles]
assert_equal(local_user[:roles].count, user.role_ids.count)
- local_user[:roles].each {|local_role_name|
+ local_user[:roles].each { |local_role_name|
local_role = Role.find_by(name: local_role_name)
assert(user.role_ids.include?(local_role.id))
}
}
- auto_wizard_data[:Groups].each {|local_group|
+ auto_wizard_data[:Groups].each { |local_group|
group = Group.find_by(name: local_group[:name])
assert_equal(local_group[:name], group.name)
if local_group[:users]
- local_group[:users].each {|local_user_login|
+ local_group[:users].each { |local_user_login|
local_user = User.find_by(login: local_user_login)
assert(group.user_ids.include?(local_user.id))
}
@@ -193,20 +193,20 @@ class AutoWizardTest < ActiveSupport::TestCase
assert_equal('default', signature.name)
end
}
- auto_wizard_data[:EmailAddresses].each {|local_email_address|
+ auto_wizard_data[:EmailAddresses].each { |local_email_address|
email_address = EmailAddress.find_by(email: local_email_address[:email])
assert_equal(local_email_address[:email], email_address.email)
assert_equal(local_email_address[:realname], email_address.realname)
channel = email_address.channel
assert_equal(local_email_address[:channel_id], email_address.channel.id)
}
- auto_wizard_data[:Channels].each {|local_channel|
+ auto_wizard_data[:Channels].each { |local_channel|
channel = Channel.find_by(id: local_channel[:id])
assert_equal(local_channel[:area], channel.area)
group = channel.group
assert_equal(local_channel[:group], group.name)
}
- auto_wizard_data[:Settings].each {|local_setting|
+ auto_wizard_data[:Settings].each { |local_setting|
setting_value = Setting.get(local_setting[:name])
assert_equal(local_setting[:value], setting_value)
}
diff --git a/test/unit/package_test.rb b/test/unit/package_test.rb
index 8a2542ddf..036f8a285 100644
--- a/test/unit/package_test.rb
+++ b/test/unit/package_test.rb
@@ -350,7 +350,7 @@ class PackageTest < ActiveSupport::TestCase
elsif test[:action] == 'auto_install'
if test[:zpm]
if !File.exist?( Rails.root.to_s + '/auto_install/' )
- Dir.mkdir( Rails.root.to_s + '/auto_install/', 0755)
+ Dir.mkdir( Rails.root.to_s + '/auto_install/', 0o755)
end
location = Rails.root.to_s + '/auto_install/unittest.zpm'
file = File.new( location, 'wb' )
@@ -373,7 +373,7 @@ class PackageTest < ActiveSupport::TestCase
next if !test[:verify]
next if !test[:verify][:check_files]
- test[:verify][:check_files].each {|item|
+ test[:verify][:check_files].each { |item|
exists = File.exist?( item[:location] )
if item[:result]
assert( exists, "'#{item[:location]}' exists" )
diff --git a/test/unit/session_collections_test.rb b/test/unit/session_collections_test.rb
index 44aa9d659..f67855422 100644
--- a/test/unit/session_collections_test.rb
+++ b/test/unit/session_collections_test.rb
@@ -133,7 +133,7 @@ class SessionCollectionsTest < ActiveSupport::TestCase
end
def check_if_collection_exists(results, collection, attributes = nil)
- results.each {|result|
+ results.each { |result|
next if !result
next if !result[:collection]
next if !result[:collection][collection]
@@ -142,9 +142,9 @@ class SessionCollectionsTest < ActiveSupport::TestCase
return true if !attributes
# check if objetc with attributes in collection exists
- result[:collection][collection].each {|item|
+ result[:collection][collection].each { |item|
match_all = true
- attributes.each {|key, value|
+ attributes.each { |key, value|
# sort array, database result maybe unsorted
item_attributes = item[ key.to_s ]
diff --git a/test/unit/session_enhanced_test.rb b/test/unit/session_enhanced_test.rb
index 33b6976c1..02e7598b3 100644
--- a/test/unit/session_enhanced_test.rb
+++ b/test/unit/session_enhanced_test.rb
@@ -295,20 +295,20 @@ class SessionEnhancedTest < ActiveSupport::TestCase
#puts "cid: #{client_id}"
#puts "m: #{messages.inspect}"
collections_result = {}
- messages.each {|message|
+ messages.each { |message|
#puts ""
#puts "message: #{message.inspect}"
next if message['event'] != 'resetCollection'
#puts "rc: "
next if !message['data']
- message['data'].each {|key, _value|
+ message['data'].each { |key, _value|
#puts "rc: #{key}"
collections_result[key] = true
}
}
#puts "c: #{collections_result.inspect}"
- collections_orig.each {|key, _value|
+ collections_orig.each { |key, _value|
assert_equal( collections_orig[key], collections_result[key], "collection message for #{key} #{type}-check (client_id #{client_id})" )
}
end
diff --git a/test/unit/tag_test.rb b/test/unit/tag_test.rb
index 07e72197d..041719301 100644
--- a/test/unit/tag_test.rb
+++ b/test/unit/tag_test.rb
@@ -140,7 +140,7 @@ class TagTest < ActiveSupport::TestCase
assert(success, 'Tag.tag_remove successful')
end
list = Tag.tag_list(tags)
- test[:verify][:items].each {|key, value|
+ test[:verify][:items].each { |key, value|
if value == true
assert(list.include?(key), "Tag verify - should exists but exists #{key}")
else
diff --git a/test/unit/ticket_test.rb b/test/unit/ticket_test.rb
index e87d66aa1..938856ed9 100644
--- a/test/unit/ticket_test.rb
+++ b/test/unit/ticket_test.rb
@@ -239,7 +239,7 @@ class TicketTest < ActiveSupport::TestCase
test 'ticket process_pending' do
# close all other pending close tickets first
- Ticket.where('pending_time IS NOT NULL').each {|ticket|
+ Ticket.where('pending_time IS NOT NULL').each { |ticket|
ticket.state = Ticket::State.lookup(name: 'closed')
ticket.save!
}
diff --git a/test/unit/token_test.rb b/test/unit/token_test.rb
index 9b483c019..2133bd1e0 100644
--- a/test/unit/token_test.rb
+++ b/test/unit/token_test.rb
@@ -88,7 +88,7 @@ class TokenTest < ActiveSupport::TestCase
if !user
assert( false, test[:test_name] + ': token verification failed' )
else
- test[:verify].each {|key, value|
+ test[:verify].each { |key, value|
assert_equal( user[key], value, 'verify' )
}
end