Updated rubocop(-* gems) to latest version (0.88.0).

This commit is contained in:
Thorsten Eckel 2020-07-13 14:46:08 +02:00
parent 829fc6e5c5
commit 73f6a98e29
37 changed files with 385 additions and 340 deletions

View file

@ -451,7 +451,7 @@ GEM
rspec-support (~> 3.8.0)
rspec-support (3.8.0)
rszr (0.5.2)
rubocop (0.87.0)
rubocop (0.88.0)
parallel (~> 1.10)
parser (>= 2.7.1.1)
rainbow (>= 2.2.2, < 4.0)
@ -468,8 +468,8 @@ GEM
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 0.82.0)
rubocop-rspec (1.41.0)
rubocop (>= 0.68.1)
rubocop-rspec (1.42.0)
rubocop (>= 0.87.0)
ruby-progressbar (1.10.1)
ruby-saml (1.10.2)
nokogiri (>= 1.5.10)

View file

@ -306,13 +306,14 @@ curl http://localhost/api/v1/monitoring/amount_check?token=XXX&periode=1h
periode = params[:periode][0, params[:periode].length - 1]
raise Exceptions::UnprocessableEntity, 'periode need to be an integer!' if periode.to_i.zero?
if scale == 's'
case scale
when 's'
created_at = Time.zone.now - periode.to_i.seconds
elsif scale == 'm'
when 'm'
created_at = Time.zone.now - periode.to_i.minutes
elsif scale == 'h'
when 'h'
created_at = Time.zone.now - periode.to_i.hours
elsif scale == 'd'
when 'd'
created_at = Time.zone.now - periode.to_i.days
end

View file

@ -85,9 +85,10 @@ class ObjectManagerAttributesController < ApplicationController
if permitted[:data_option][:options][:true]
permitted[:data_option][:options][true] = permitted[:data_option][:options].delete(:true)
end
if permitted[:data_option][:default] == 'true'
case permitted[:data_option][:default]
when 'true'
permitted[:data_option][:default] = true
elsif permitted[:data_option][:default] == 'false'
when 'false'
permitted[:data_option][:default] = false
end
# rubocop:enable Lint/BooleanSymbol

View file

@ -138,22 +138,23 @@ class ReportsController < ApplicationController
metric = local_config[:metric][params[:metric].to_sym]
if params[:timeRange] == 'realtime'
case params[:timeRange]
when 'realtime'
start_at = (Time.zone.now - 60.minutes)
stop_at = Time.zone.now
range = 'minute'
elsif params[:timeRange] == 'day'
when 'day'
date = Date.parse("#{params[:year]}-#{params[:month]}-#{params[:day]}").to_s
start_at = Time.zone.parse("#{date}T00:00:00Z")
stop_at = Time.zone.parse("#{date}T23:59:59Z")
range = 'hour'
elsif params[:timeRange] == 'week'
when 'week'
start_week_at = Date.commercial(params[:year].to_i, params[:week].to_i)
stop_week_at = start_week_at.end_of_week
start_at = Time.zone.parse("#{start_week_at.year}-#{start_week_at.month}-#{start_week_at.day}T00:00:00Z")
stop_at = Time.zone.parse("#{stop_week_at.year}-#{stop_week_at.month}-#{stop_week_at.day}T23:59:59Z")
range = 'week'
elsif params[:timeRange] == 'month'
when 'month'
start_at = Time.zone.parse("#{params[:year]}-#{params[:month]}-01T00:00:00Z")
stop_at = Time.zone.parse("#{params[:year]}-#{params[:month]}-#{start_at.end_of_month.day}T23:59:59Z")
range = 'day'

View file

@ -12,16 +12,13 @@ module KnowledgeBaseTopBarHelper
end
def kb_answer_top_bar_color(answer)
case answer.can_be_published_aasm.current_state
when :draft
'yellow'
when :internal
'blue'
when :published
'green'
when :archived
'grey'
end
state_color_map = {
draft: 'yellow',
internal: 'blue',
published: 'green',
archived: 'grey',
}
state_color_map[answer.can_be_published_aasm.current_state]
end
def kb_top_bar_tag(object)

View file

@ -13,14 +13,12 @@ module KnowledgeBaseVisibilityClassHelper
end
def visiblity_class_suffix_can_be_published(object)
case object.can_be_published_aasm.current_state
when :internal
'internal'
when :archived
'archived'
when :draft
'not-published'
end
state_suffix_map = {
internal: 'internal',
archived: 'archived',
draft: 'not-published',
}
state_suffix_map[object.can_be_published_aasm.current_state]
end
def visiblity_class_suffix_category(object)

View file

@ -19,14 +19,12 @@ module KnowledgeBaseVisibilityNoteHelper
end
def visiblity_text_can_be_published(object)
case object.can_be_published_aasm.current_state
when :internal
'internal'
when :archived
'archived'
when :draft
'not published'
end
state_text_map = {
internal: 'internal',
archived: 'archived',
draft: 'not published',
}
state_text_map[object.can_be_published_aasm.current_state]
end
def visiblity_text_category(object)

View file

@ -87,7 +87,7 @@ class Channel::EmailParser
headers,
body,
self.class.sender_attributes(headers),
raw: msg,
{ raw: msg },
]
message_attributes.reduce({}.with_indifferent_access, &:merge)
end

View file

@ -18,12 +18,13 @@ module Channel::Filter::Database
value = mail[ key.downcase.to_sym ]
match_rule = meta['value']
min_one_rule_exists = true
if meta[:operator] == 'contains not'
case meta[:operator]
when 'contains not'
if value.present? && Channel::Filter::Match::EmailRegex.match(value: value, match_rule: match_rule)
all_matches_ok = false
Rails.logger.info " matching #{key.downcase}:'#{value}' on #{match_rule}, but shoud not"
end
elsif meta[:operator] == 'contains'
when 'contains'
if value.blank? || !Channel::Filter::Match::EmailRegex.match(value: value, match_rule: match_rule)
all_matches_ok = false
Rails.logger.info " not matching #{key.downcase}:'#{value}' on #{match_rule}, but should"

View file

@ -71,9 +71,10 @@ class Channel::Filter::MonitoringBase
# possible event types https://mmonit.com/monit/documentation/#Setting-an-event-filter
if result['state'].blank?
result['state'] = if mail[:body].match?(/\s(done|recovery|succeeded|bytes\sok|packets\sok)\s/)
result['state'] = case mail[:body]
when /\s(done|recovery|succeeded|bytes\sok|packets\sok)\s/
'OK'
elsif mail[:body].match?(/(instance\schanged\snot|Link\sup|Exists|Saturation\sok|Speed\sok)/)
when /(instance\schanged\snot|Link\sup|Exists|Saturation\sok|Speed\sok)/
'OK'
else
'CRITICAL'

View file

@ -66,7 +66,8 @@ reconnect - chat session already exists, serve agent and session chat messages (
chat_session = Chat::Session.find_by(session_id: session_id, state: %w[waiting running])
if chat_session
if chat_session.state == 'running'
case chat_session.state
when 'running'
user = chat_session.agent_user
if user
@ -80,7 +81,7 @@ reconnect - chat session already exists, serve agent and session chat messages (
}
end
end
elsif chat_session.state == 'waiting'
when 'waiting'
return {
state: 'reconnect',
position: chat_session.position,

View file

@ -7,15 +7,16 @@ class Cti::Driver::Placetel < Cti::Driver::Base
def mapping(params)
# do event mapping
if params['event'] == 'IncomingCall'
case params['event']
when 'IncomingCall'
params['direction'] = 'in'
params['event'] = 'newCall'
elsif params['event'] == 'HungUp'
when 'HungUp'
params['event'] = 'hangup'
elsif params['event'] == 'OutgoingCall'
when 'OutgoingCall'
params['direction'] = 'out'
params['event'] = 'newCall'
elsif params['event'] == 'CallAccepted'
when 'CallAccepted'
params['event'] = 'answer'
end
@ -41,13 +42,14 @@ class Cti::Driver::Placetel < Cti::Driver::Base
end
# do case mapping
if params['type'] == 'missed'
case params['type']
when 'missed'
params['cause'] = 'cancel'
elsif params['type'] == 'voicemail'
when 'voicemail'
params['cause'] = 'voicemail'
elsif params['type'] == 'blocked'
when 'blocked'
params['cause'] = 'blocked'
elsif params['type'] == 'accepted'
when 'accepted'
params['cause'] = 'normalClearing'
end

View file

@ -677,21 +677,23 @@ to send no browser reload event, pass false
end
data_type = nil
if attribute.data_type.match?(/^input|select|tree_select|richtext|textarea|checkbox$/)
case attribute.data_type
when /^input|select|tree_select|richtext|textarea|checkbox$/
data_type = :string
elsif attribute.data_type.match?(/^integer|user_autocompletion$/)
when /^integer|user_autocompletion$/
data_type = :integer
elsif attribute.data_type.match?(/^boolean|active$/)
when /^boolean|active$/
data_type = :boolean
elsif attribute.data_type.match?(/^datetime$/)
when /^datetime$/
data_type = :datetime
elsif attribute.data_type.match?(/^date$/)
when /^date$/
data_type = :date
end
# change field
if model.column_names.include?(attribute.name)
if attribute.data_type.match?(/^input|select|tree_select|richtext|textarea|checkbox$/)
case attribute.data_type
when /^input|select|tree_select|richtext|textarea|checkbox$/
ActiveRecord::Migration.change_column(
model.table_name,
attribute.name,
@ -699,7 +701,7 @@ to send no browser reload event, pass false
limit: attribute.data_option[:maxlength],
null: true
)
elsif attribute.data_type.match?(/^integer|user_autocompletion|datetime|date$/)
when /^integer|user_autocompletion|datetime|date$/
ActiveRecord::Migration.change_column(
model.table_name,
attribute.name,
@ -707,7 +709,7 @@ to send no browser reload event, pass false
default: attribute.data_option[:default],
null: true
)
elsif attribute.data_type.match?(/^boolean|active$/)
when /^boolean|active$/
ActiveRecord::Migration.change_column(
model.table_name,
attribute.name,
@ -730,7 +732,8 @@ to send no browser reload event, pass false
end
# create field
if attribute.data_type.match?(/^input|select|tree_select|richtext|textarea|checkbox$/)
case attribute.data_type
when /^input|select|tree_select|richtext|textarea|checkbox$/
ActiveRecord::Migration.add_column(
model.table_name,
attribute.name,
@ -738,7 +741,7 @@ to send no browser reload event, pass false
limit: attribute.data_option[:maxlength],
null: true
)
elsif attribute.data_type.match?(/^integer|user_autocompletion$/)
when /^integer|user_autocompletion$/
ActiveRecord::Migration.add_column(
model.table_name,
attribute.name,
@ -746,7 +749,7 @@ to send no browser reload event, pass false
default: attribute.data_option[:default],
null: true
)
elsif attribute.data_type.match?(/^boolean|active$/)
when /^boolean|active$/
ActiveRecord::Migration.add_column(
model.table_name,
attribute.name,
@ -754,7 +757,7 @@ to send no browser reload event, pass false
default: attribute.data_option[:default],
null: true
)
elsif attribute.data_type.match?(/^datetime|date$/)
when /^datetime|date$/
ActiveRecord::Migration.add_column(
model.table_name,
attribute.name,

View file

@ -408,9 +408,10 @@ execute all pending package migrations at once
end
def self._read_file(file, fullpath = false)
location = if fullpath == false
location = case fullpath
when false
@@root + '/' + file
elsif fullpath == true
when true
file
else
fullpath + '/' + file

View file

@ -547,19 +547,20 @@ condition example
if query != ''
query += ' AND '
end
if selector[0] == 'customer'
case selector[0]
when 'customer'
tables += ', users customers'
query += 'tickets.customer_id = customers.id'
elsif selector[0] == 'organization'
when 'organization'
tables += ', organizations'
query += 'tickets.organization_id = organizations.id'
elsif selector[0] == 'owner'
when 'owner'
tables += ', users owners'
query += 'tickets.owner_id = owners.id'
elsif selector[0] == 'article'
when 'article'
tables += ', ticket_articles articles'
query += 'tickets.id = articles.ticket_id'
elsif selector[0] == 'ticket_state'
when 'ticket_state'
tables += ', ticket_states'
query += 'tickets.state_id = ticket_states.id'
else
@ -786,15 +787,16 @@ condition example
elsif selector['operator'] == 'within last (relative)'
query += "#{attribute} >= ?"
time = nil
if selector['range'] == 'minute'
case selector['range']
when 'minute'
time = Time.zone.now - selector['value'].to_i.minutes
elsif selector['range'] == 'hour'
when 'hour'
time = Time.zone.now - selector['value'].to_i.hours
elsif selector['range'] == 'day'
when 'day'
time = Time.zone.now - selector['value'].to_i.days
elsif selector['range'] == 'month'
when 'month'
time = Time.zone.now - selector['value'].to_i.months
elsif selector['range'] == 'year'
when 'year'
time = Time.zone.now - selector['value'].to_i.years
else
raise "Unknown selector attributes '#{selector.inspect}'"
@ -803,15 +805,16 @@ condition example
elsif selector['operator'] == 'within next (relative)'
query += "#{attribute} <= ?"
time = nil
if selector['range'] == 'minute'
case selector['range']
when 'minute'
time = Time.zone.now + selector['value'].to_i.minutes
elsif selector['range'] == 'hour'
when 'hour'
time = Time.zone.now + selector['value'].to_i.hours
elsif selector['range'] == 'day'
when 'day'
time = Time.zone.now + selector['value'].to_i.days
elsif selector['range'] == 'month'
when 'month'
time = Time.zone.now + selector['value'].to_i.months
elsif selector['range'] == 'year'
when 'year'
time = Time.zone.now + selector['value'].to_i.years
else
raise "Unknown selector attributes '#{selector.inspect}'"
@ -820,15 +823,16 @@ condition example
elsif selector['operator'] == 'before (relative)'
query += "#{attribute} <= ?"
time = nil
if selector['range'] == 'minute'
case selector['range']
when 'minute'
time = Time.zone.now - selector['value'].to_i.minutes
elsif selector['range'] == 'hour'
when 'hour'
time = Time.zone.now - selector['value'].to_i.hours
elsif selector['range'] == 'day'
when 'day'
time = Time.zone.now - selector['value'].to_i.days
elsif selector['range'] == 'month'
when 'month'
time = Time.zone.now - selector['value'].to_i.months
elsif selector['range'] == 'year'
when 'year'
time = Time.zone.now - selector['value'].to_i.years
else
raise "Unknown selector attributes '#{selector.inspect}'"
@ -837,15 +841,16 @@ condition example
elsif selector['operator'] == 'after (relative)'
query += "#{attribute} >= ?"
time = nil
if selector['range'] == 'minute'
case selector['range']
when 'minute'
time = Time.zone.now + selector['value'].to_i.minutes
elsif selector['range'] == 'hour'
when 'hour'
time = Time.zone.now + selector['value'].to_i.hours
elsif selector['range'] == 'day'
when 'day'
time = Time.zone.now + selector['value'].to_i.days
elsif selector['range'] == 'month'
when 'month'
time = Time.zone.now + selector['value'].to_i.months
elsif selector['range'] == 'year'
when 'year'
time = Time.zone.now + selector['value'].to_i.years
else
raise "Unknown selector attributes '#{selector.inspect}'"
@ -944,11 +949,12 @@ perform changes on ticket
next if value['value'].blank?
tags = value['value'].split(/,/)
if value['operator'] == 'add'
case value['operator']
when 'add'
tags.each do |tag|
tag_add(tag, current_user_id || 1)
end
elsif value['operator'] == 'remove'
when 'remove'
tags.each do |tag|
tag_remove(tag, current_user_id || 1)
end
@ -1365,7 +1371,8 @@ result
recipients_raw = []
value_recipient.each do |recipient|
if recipient == 'article_last_sender'
case recipient
when 'article_last_sender'
if article.present?
if article.reply_to.present?
recipients_raw.push(article.reply_to)
@ -1379,17 +1386,17 @@ result
recipients_raw.push(email)
end
end
elsif recipient == 'ticket_customer'
when 'ticket_customer'
email = User.find_by(id: customer_id).email
recipients_raw.push(email)
elsif recipient == 'ticket_owner'
when 'ticket_owner'
email = User.find_by(id: owner_id).email
recipients_raw.push(email)
elsif recipient == 'ticket_agents'
when 'ticket_agents'
User.group_access(group_id, 'full').sort_by(&:login).each do |user|
recipients_raw.push(user.email)
end
elsif recipient =~ /\Auserid_(\d+)\z/
when /\Auserid_(\d+)\z/
user = User.lookup(id: $1)
if !user
logger.warn "Can't find configured Trigger Email recipient User with ID '#{$1}'"

View file

@ -170,15 +170,16 @@ class Transaction::Notification
# get user based notification template
# if create, send create message / block update messages
template = nil
if @item[:type] == 'create'
case @item[:type]
when 'create'
template = 'ticket_create'
elsif @item[:type] == 'update'
when 'update'
template = 'ticket_update'
elsif @item[:type] == 'reminder_reached'
when 'reminder_reached'
template = 'ticket_reminder_reached'
elsif @item[:type] == 'escalation'
when 'escalation'
template = 'ticket_escalation'
elsif @item[:type] == 'escalation_warning'
when 'escalation_warning'
template = 'ticket_escalation_warning'
else
raise "unknown type for notification #{@item[:type]}"

View file

@ -60,17 +60,18 @@ class Transaction::Slack
# if create, send create message / block update messages
template = nil
sent_value = nil
if @item[:type] == 'create'
case @item[:type]
when 'create'
template = 'ticket_create'
elsif @item[:type] == 'update'
when 'update'
template = 'ticket_update'
elsif @item[:type] == 'reminder_reached'
when 'reminder_reached'
template = 'ticket_reminder_reached'
sent_value = ticket.pending_time
elsif @item[:type] == 'escalation'
when 'escalation'
template = 'ticket_escalation'
sent_value = ticket.escalation_at
elsif @item[:type] == 'escalation_warning'
when 'escalation_warning'
template = 'ticket_escalation_warning'
sent_value = ticket.escalation_at
else

View file

@ -1058,9 +1058,10 @@ try to find correct name
return true if !preferences[:notification_sound]
return true if !preferences[:notification_sound][:enabled]
if preferences[:notification_sound][:enabled] == 'true'
case preferences[:notification_sound][:enabled]
when 'true'
preferences[:notification_sound][:enabled] = true
elsif preferences[:notification_sound][:enabled] == 'false'
when 'false'
preferences[:notification_sound][:enabled] = false
end
class_name = preferences[:notification_sound][:enabled].class.to_s

View file

@ -14,25 +14,25 @@ class ForeignKeys < ActiveRecord::Migration[4.2]
foreign_keys = [
# Base
%i[users organizations],
[:users, :users, column: :created_by_id],
[:users, :users, column: :updated_by_id],
[:users, :users, { column: :created_by_id }],
[:users, :users, { column: :updated_by_id }],
[:signatures, :users, column: :created_by_id],
[:signatures, :users, column: :updated_by_id],
[:signatures, :users, { column: :created_by_id }],
[:signatures, :users, { column: :updated_by_id }],
[:email_addresses, :users, column: :created_by_id],
[:email_addresses, :users, column: :updated_by_id],
[:email_addresses, :users, { column: :created_by_id }],
[:email_addresses, :users, { column: :updated_by_id }],
%i[groups signatures],
%i[groups email_addresses],
[:groups, :users, column: :created_by_id],
[:groups, :users, column: :updated_by_id],
[:groups, :users, { column: :created_by_id }],
[:groups, :users, { column: :updated_by_id }],
[:roles, :users, column: :created_by_id],
[:roles, :users, column: :updated_by_id],
[:roles, :users, { column: :created_by_id }],
[:roles, :users, { column: :updated_by_id }],
[:organizations, :users, column: :created_by_id],
[:organizations, :users, column: :updated_by_id],
[:organizations, :users, { column: :created_by_id }],
[:organizations, :users, { column: :updated_by_id }],
%i[roles_users users],
%i[roles_users roles],
@ -45,108 +45,108 @@ class ForeignKeys < ActiveRecord::Migration[4.2]
%i[authorizations users],
[:translations, :users, column: :created_by_id],
[:translations, :users, column: :updated_by_id],
[:translations, :users, { column: :created_by_id }],
[:translations, :users, { column: :updated_by_id }],
%i[tokens users],
[:packages, :users, column: :created_by_id],
[:packages, :users, column: :updated_by_id],
[:packages, :users, { column: :created_by_id }],
[:packages, :users, { column: :updated_by_id }],
%i[taskbars users],
%i[tags tag_items],
%i[tags tag_objects],
[:tags, :users, column: :created_by_id],
[:tags, :users, { column: :created_by_id }],
[:recent_views, :object_lookups, column: :recent_view_object_id],
[:recent_views, :users, column: :created_by_id],
[:recent_views, :object_lookups, { column: :recent_view_object_id }],
[:recent_views, :users, { column: :created_by_id }],
[:activity_streams, :type_lookups, column: :activity_stream_type_id],
[:activity_streams, :object_lookups, column: :activity_stream_object_id],
[:activity_streams, :type_lookups, { column: :activity_stream_type_id }],
[:activity_streams, :object_lookups, { column: :activity_stream_object_id }],
%i[activity_streams permissions],
%i[activity_streams groups],
[:activity_streams, :users, column: :created_by_id],
[:activity_streams, :users, { column: :created_by_id }],
%i[histories history_types],
%i[histories history_objects],
%i[histories history_attributes],
[:histories, :users, column: :created_by_id],
[:histories, :users, { column: :created_by_id }],
%i[stores store_objects],
%i[stores store_files],
[:stores, :users, column: :created_by_id],
[:stores, :users, { column: :created_by_id }],
[:avatars, :users, column: :created_by_id],
[:avatars, :users, column: :updated_by_id],
[:avatars, :users, { column: :created_by_id }],
[:avatars, :users, { column: :updated_by_id }],
[:online_notifications, :users, column: :created_by_id],
[:online_notifications, :users, column: :updated_by_id],
[:online_notifications, :users, { column: :created_by_id }],
[:online_notifications, :users, { column: :updated_by_id }],
[:schedulers, :users, column: :created_by_id],
[:schedulers, :users, column: :updated_by_id],
[:schedulers, :users, { column: :created_by_id }],
[:schedulers, :users, { column: :updated_by_id }],
[:calendars, :users, column: :created_by_id],
[:calendars, :users, column: :updated_by_id],
[:calendars, :users, { column: :created_by_id }],
[:calendars, :users, { column: :updated_by_id }],
%i[user_devices users],
%i[object_manager_attributes object_lookups],
[:object_manager_attributes, :users, column: :created_by_id],
[:object_manager_attributes, :users, column: :updated_by_id],
[:object_manager_attributes, :users, { column: :created_by_id }],
[:object_manager_attributes, :users, { column: :updated_by_id }],
%i[cti_caller_ids users],
[:stats_stores, :users, column: :created_by_id],
[:stats_stores, :users, { column: :created_by_id }],
[:http_logs, :users, column: :created_by_id],
[:http_logs, :users, column: :updated_by_id],
[:http_logs, :users, { column: :created_by_id }],
[:http_logs, :users, { column: :updated_by_id }],
# Ticket
[:ticket_state_types, :users, column: :created_by_id],
[:ticket_state_types, :users, column: :updated_by_id],
[:ticket_state_types, :users, { column: :created_by_id }],
[:ticket_state_types, :users, { column: :updated_by_id }],
[:ticket_states, :ticket_state_types, column: :state_type_id],
[:ticket_states, :users, column: :created_by_id],
[:ticket_states, :users, column: :updated_by_id],
[:ticket_states, :ticket_state_types, { column: :state_type_id }],
[:ticket_states, :users, { column: :created_by_id }],
[:ticket_states, :users, { column: :updated_by_id }],
[:ticket_priorities, :users, column: :created_by_id],
[:ticket_priorities, :users, column: :updated_by_id],
[:ticket_priorities, :users, { column: :created_by_id }],
[:ticket_priorities, :users, { column: :updated_by_id }],
%i[tickets groups],
[:tickets, :users, column: :owner_id],
[:tickets, :users, column: :customer_id],
[:tickets, :ticket_priorities, column: :priority_id],
[:tickets, :ticket_states, column: :state_id],
[:tickets, :users, { column: :owner_id }],
[:tickets, :users, { column: :customer_id }],
[:tickets, :ticket_priorities, { column: :priority_id }],
[:tickets, :ticket_states, { column: :state_id }],
%i[tickets organizations],
[:tickets, :users, column: :created_by_id],
[:tickets, :users, column: :updated_by_id],
[:tickets, :users, { column: :created_by_id }],
[:tickets, :users, { column: :updated_by_id }],
[:ticket_flags, :tickets, column: :ticket_id],
[:ticket_flags, :users, column: :created_by_id],
[:ticket_flags, :tickets, { column: :ticket_id }],
[:ticket_flags, :users, { column: :created_by_id }],
[:ticket_article_types, :users, column: :created_by_id],
[:ticket_article_types, :users, column: :updated_by_id],
[:ticket_article_types, :users, { column: :created_by_id }],
[:ticket_article_types, :users, { column: :updated_by_id }],
[:ticket_article_senders, :users, column: :created_by_id],
[:ticket_article_senders, :users, column: :updated_by_id],
[:ticket_article_senders, :users, { column: :created_by_id }],
[:ticket_article_senders, :users, { column: :updated_by_id }],
%i[ticket_articles tickets],
[:ticket_articles, :ticket_article_types, column: :type_id],
[:ticket_articles, :ticket_article_senders, column: :sender_id],
[:ticket_articles, :users, column: :created_by_id],
[:ticket_articles, :users, column: :updated_by_id],
[:ticket_articles, :users, column: :origin_by_id],
[:ticket_articles, :ticket_article_types, { column: :type_id }],
[:ticket_articles, :ticket_article_senders, { column: :sender_id }],
[:ticket_articles, :users, { column: :created_by_id }],
[:ticket_articles, :users, { column: :updated_by_id }],
[:ticket_articles, :users, { column: :origin_by_id }],
[:ticket_article_flags, :ticket_articles, column: :ticket_article_id],
[:ticket_article_flags, :users, column: :created_by_id],
[:ticket_article_flags, :ticket_articles, { column: :ticket_article_id }],
[:ticket_article_flags, :users, { column: :created_by_id }],
%i[ticket_time_accountings tickets],
%i[ticket_time_accountings ticket_articles],
[:ticket_time_accountings, :users, column: :created_by_id],
[:ticket_time_accountings, :users, { column: :created_by_id }],
[:overviews, :users, column: :created_by_id],
[:overviews, :users, column: :updated_by_id],
[:overviews, :users, { column: :created_by_id }],
[:overviews, :users, { column: :updated_by_id }],
%i[overviews_roles overviews],
%i[overviews_roles roles],
@ -157,65 +157,65 @@ class ForeignKeys < ActiveRecord::Migration[4.2]
%i[overviews_groups overviews],
%i[overviews_groups groups],
[:triggers, :users, column: :created_by_id],
[:triggers, :users, column: :updated_by_id],
[:triggers, :users, { column: :created_by_id }],
[:triggers, :users, { column: :updated_by_id }],
[:jobs, :users, column: :created_by_id],
[:jobs, :users, column: :updated_by_id],
[:jobs, :users, { column: :created_by_id }],
[:jobs, :users, { column: :updated_by_id }],
%i[links link_types],
[:postmaster_filters, :users, column: :created_by_id],
[:postmaster_filters, :users, column: :updated_by_id],
[:postmaster_filters, :users, { column: :created_by_id }],
[:postmaster_filters, :users, { column: :updated_by_id }],
%i[text_modules users],
[:text_modules, :users, column: :created_by_id],
[:text_modules, :users, column: :updated_by_id],
[:text_modules, :users, { column: :created_by_id }],
[:text_modules, :users, { column: :updated_by_id }],
%i[text_modules_groups text_modules],
%i[text_modules_groups groups],
%i[templates users],
[:templates, :users, column: :created_by_id],
[:templates, :users, column: :updated_by_id],
[:templates, :users, { column: :created_by_id }],
[:templates, :users, { column: :updated_by_id }],
%i[templates_groups templates],
%i[templates_groups groups],
%i[channels groups],
[:channels, :users, column: :created_by_id],
[:channels, :users, column: :updated_by_id],
[:channels, :users, { column: :created_by_id }],
[:channels, :users, { column: :updated_by_id }],
[:slas, :users, column: :created_by_id],
[:slas, :users, column: :updated_by_id],
[:slas, :users, { column: :created_by_id }],
[:slas, :users, { column: :updated_by_id }],
[:macros, :users, column: :created_by_id],
[:macros, :users, column: :updated_by_id],
[:macros, :users, { column: :created_by_id }],
[:macros, :users, { column: :updated_by_id }],
[:chats, :users, column: :created_by_id],
[:chats, :users, column: :updated_by_id],
[:chats, :users, { column: :created_by_id }],
[:chats, :users, { column: :updated_by_id }],
[:chat_topics, :users, column: :created_by_id],
[:chat_topics, :users, column: :updated_by_id],
[:chat_topics, :users, { column: :created_by_id }],
[:chat_topics, :users, { column: :updated_by_id }],
%i[chat_sessions chats],
%i[chat_sessions users],
[:chat_sessions, :users, column: :created_by_id],
[:chat_sessions, :users, column: :updated_by_id],
[:chat_sessions, :users, { column: :created_by_id }],
[:chat_sessions, :users, { column: :updated_by_id }],
%i[chat_messages chat_sessions],
[:chat_messages, :users, column: :created_by_id],
[:chat_messages, :users, { column: :created_by_id }],
[:chat_agents, :users, column: :created_by_id],
[:chat_agents, :users, column: :updated_by_id],
[:chat_agents, :users, { column: :created_by_id }],
[:chat_agents, :users, { column: :updated_by_id }],
[:report_profiles, :users, column: :created_by_id],
[:report_profiles, :users, column: :updated_by_id],
[:report_profiles, :users, { column: :created_by_id }],
[:report_profiles, :users, { column: :updated_by_id }],
%i[karma_users users],
%i[karma_activity_logs users],
[:karma_activity_logs, :karma_activities, column: :activity_id],
[:karma_activity_logs, :karma_activities, { column: :activity_id }],
]
foreign_keys.each do |foreign_key|

View file

@ -23,11 +23,12 @@ module Import
def booleanize_values(properties)
properties.each do |key, value|
if value.is_a?(String)
case value
when String
next if !%w[true false].include?(value)
properties[key] = value == 'true'
elsif value.is_a?(Hash)
when Hash
properties[key] = booleanize_values(value)
end
end

View file

@ -48,9 +48,10 @@ returns
owned_by_nobody = false
owned_by_me = false
if ticket.owner_id == 1
case ticket.owner_id
when 1
owned_by_nobody = true
elsif ticket.owner_id == user.id
when user.id
owned_by_me = true
else
# check the replacement chain of max 10

View file

@ -23,32 +23,36 @@ returns
params = params_origin.dup
result = []
if params[:interval] == 'month'
case params[:interval]
when 'month'
stop_interval = 12
elsif params[:interval] == 'week'
when 'week'
stop_interval = 7
elsif params[:interval] == 'day'
when 'day'
stop_interval = 31
elsif params[:interval] == 'hour'
when 'hour'
stop_interval = 24
elsif params[:interval] == 'minute'
when 'minute'
stop_interval = 60
end
query, bind_params, tables = Ticket.selector2sql(params[:selector])
sender = Ticket::Article::Sender.lookup(name: params[:params][:sender])
type = Ticket::Article::Type.lookup(name: params[:params][:type])
(1..stop_interval).each do |_counter|
if params[:interval] == 'month'
case params[:interval]
when 'month'
params[:range_end] = params[:range_start].next_month
elsif params[:interval] == 'week'
when 'week'
params[:range_end] = params[:range_start].next_day
elsif params[:interval] == 'day'
when 'day'
params[:range_end] = params[:range_start].next_day
elsif params[:interval] == 'hour'
when 'hour'
params[:range_end] = params[:range_start] + 1.hour
elsif params[:interval] == 'minute'
when 'minute'
params[:range_end] = params[:range_start] + 1.minute
end
query, bind_params, tables = Ticket.selector2sql(params[:selector])
sender = Ticket::Article::Sender.lookup(name: params[:params][:sender])
type = Ticket::Article::Type.lookup(name: params[:params][:type])
count = Ticket::Article.joins('INNER JOIN tickets ON tickets.id = ticket_articles.ticket_id')
.where(query, *bind_params).joins(tables)
.where(

View file

@ -19,27 +19,29 @@ returns
params = params_origin.dup
result = []
if params[:interval] == 'month'
case params[:interval]
when 'month'
stop_interval = 12
elsif params[:interval] == 'week'
when 'week'
stop_interval = 7
elsif params[:interval] == 'day'
when 'day'
stop_interval = 31
elsif params[:interval] == 'hour'
when 'hour'
stop_interval = 24
elsif params[:interval] == 'minute'
when 'minute'
stop_interval = 60
end
(1..stop_interval).each do |_counter|
if params[:interval] == 'month'
case params[:interval]
when 'month'
params[:range_end] = params[:range_start].next_month
elsif params[:interval] == 'week'
when 'week'
params[:range_end] = params[:range_start].next_day
elsif params[:interval] == 'day'
when 'day'
params[:range_end] = params[:range_start].next_day
elsif params[:interval] == 'hour'
when 'hour'
params[:range_end] = params[:range_start] + 1.hour
elsif params[:interval] == 'minute'
when 'minute'
params[:range_end] = params[:range_start] + 1.minute
end

View file

@ -46,15 +46,16 @@ returns
selector.merge!(without_merged_tickets) # do not show merged tickets in reports
result_es = SearchIndexBackend.selectors('Ticket', selector, {}, aggs_interval)
if params[:interval] == 'month'
case params[:interval]
when 'month'
stop_interval = 12
elsif params[:interval] == 'week'
when 'week'
stop_interval = 7
elsif params[:interval] == 'day'
when 'day'
stop_interval = ((params[:range_end] - params[:range_start]) / 86_400).to_i + 1
elsif params[:interval] == 'hour'
when 'hour'
stop_interval = 24
elsif params[:interval] == 'minute'
when 'minute'
stop_interval = 60
end
result = []
@ -80,9 +81,10 @@ returns
# only compare date - in certain cases elasticsearch timezone offset will not match
replace = ':\d\dZ$'
if params[:interval] == 'month'
case params[:interval]
when 'month'
replace = '\d\dT\d\d:\d\d:\d\dZ$'
elsif params[:interval] == 'day' || params[:interval] == 'week'
when 'day', 'week'
replace = '\d\d:\d\d:\d\dZ$'
end
@ -91,30 +93,32 @@ returns
match = true
result.push item['doc_count']
if params[:interval] == 'month'
case params[:interval]
when 'month'
params[:range_start] = params[:range_start].next_month
elsif params[:interval] == 'week'
when 'week'
params[:range_start] = params[:range_start].next_day
elsif params[:interval] == 'day'
when 'day'
params[:range_start] = params[:range_start].next_day
elsif params[:interval] == 'hour'
when 'hour'
params[:range_start] = params[:range_start] + 1.hour
elsif params[:interval] == 'minute'
when 'minute'
params[:range_start] = params[:range_start] + 1.minute
end
end
next if match
result.push 0
if params[:interval] == 'month'
case params[:interval]
when 'month'
params[:range_start] = params[:range_start].next_month
elsif params[:interval] == 'week'
when 'week'
params[:range_start] = params[:range_start].next_day
elsif params[:interval] == 'day'
when 'day'
params[:range_start] = params[:range_start] + 1.day
elsif params[:interval] == 'hour'
when 'hour'
params[:range_start] = params[:range_start] + 1.hour
elsif params[:interval] == 'minute'
when 'minute'
params[:range_start] = params[:range_start] + 1.minute
end
end

View file

@ -27,27 +27,29 @@ returns
end
result = []
if params[:interval] == 'month'
case params[:interval]
when 'month'
stop_interval = 12
elsif params[:interval] == 'week'
when 'week'
stop_interval = 7
elsif params[:interval] == 'day'
when 'day'
stop_interval = 31
elsif params[:interval] == 'hour'
when 'hour'
stop_interval = 24
elsif params[:interval] == 'minute'
when 'minute'
stop_interval = 60
end
(1..stop_interval).each do |_counter|
if params[:interval] == 'month'
case params[:interval]
when 'month'
params[:range_end] = params[:range_start].next_month
elsif params[:interval] == 'week'
when 'week'
params[:range_end] = params[:range_start].next_day
elsif params[:interval] == 'day'
when 'day'
params[:range_end] = params[:range_start].next_day
elsif params[:interval] == 'hour'
when 'hour'
params[:range_end] = params[:range_start] + 1.hour
elsif params[:interval] == 'minute'
when 'minute'
params[:range_end] = params[:range_start] + 1.minute
end
local_params = group_attributes(selector, params)
@ -141,7 +143,8 @@ returns
def self.group_attributes(selector, params)
group_id = selector['value']
if selector['operator'] == 'is'
case selector['operator']
when 'is'
if params[:params][:type] == 'in'
return {
id_not_from: group_id,
@ -153,7 +156,7 @@ returns
id_not_to: group_id,
}
end
elsif selector['operator'] == 'is not'
when 'is not'
if params[:params][:type] == 'in'
return {
id_from: group_id,

View file

@ -21,27 +21,29 @@ returns
ticket_state_ids = ticket_ids
result = []
if params[:interval] == 'month'
case params[:interval]
when 'month'
stop_interval = 12
elsif params[:interval] == 'week'
when 'week'
stop_interval = 7
elsif params[:interval] == 'day'
when 'day'
stop_interval = 31
elsif params[:interval] == 'hour'
when 'hour'
stop_interval = 24
elsif params[:interval] == 'minute'
when 'minute'
stop_interval = 60
end
(1..stop_interval).each do |_counter|
if params[:interval] == 'month'
case params[:interval]
when 'month'
params[:range_end] = params[:range_start].next_month
elsif params[:interval] == 'week'
when 'week'
params[:range_end] = params[:range_start].next_day
elsif params[:interval] == 'day'
when 'day'
params[:range_end] = params[:range_start].next_day
elsif params[:interval] == 'hour'
when 'hour'
params[:range_end] = params[:range_start] + 1.hour
elsif params[:interval] == 'minute'
when 'minute'
params[:range_end] = params[:range_start] + 1.minute
end

View file

@ -524,33 +524,36 @@ example for aggregations within one year
end
# is/is not/contains/contains not
if data['operator'] == 'is' || data['operator'] == 'is not' || data['operator'] == 'contains' || data['operator'] == 'contains not'
case data['operator']
when 'is', 'is not', 'contains', 'contains not'
t[wildcard_or_term] = {}
t[wildcard_or_term][key_tmp] = data['value']
if data['operator'] == 'is' || data['operator'] == 'contains'
case data['operator']
when 'is', 'contains'
query_must.push t
elsif data['operator'] == 'is not' || data['operator'] == 'contains not'
when 'is not', 'contains not'
query_must_not.push t
end
elsif data['operator'] == 'contains all' || data['operator'] == 'contains one' || data['operator'] == 'contains all not' || data['operator'] == 'contains one not'
when 'contains all', 'contains one', 'contains all not', 'contains one not'
values = data['value'].split(',').map(&:strip)
t[:query_string] = {}
if data['operator'] == 'contains all'
case data['operator']
when 'contains all'
t[:query_string][:query] = "#{key_tmp}:\"#{values.join('" AND "')}\""
query_must.push t
elsif data['operator'] == 'contains one not'
when 'contains one not'
t[:query_string][:query] = "#{key_tmp}:\"#{values.join('" OR "')}\""
query_must_not.push t
elsif data['operator'] == 'contains one'
when 'contains one'
t[:query_string][:query] = "#{key_tmp}:\"#{values.join('" OR "')}\""
query_must.push t
elsif data['operator'] == 'contains all not'
when 'contains all not'
t[:query_string][:query] = "#{key_tmp}:\"#{values.join('" AND "')}\""
query_must_not.push t
end
# within last/within next (relative)
elsif data['operator'] == 'within last (relative)' || data['operator'] == 'within next (relative)'
when 'within last (relative)', 'within next (relative)'
range = relative_map[data['range'].to_sym]
if range.blank?
raise "Invalid relative_map for range '#{data['range']}'."
@ -566,7 +569,7 @@ example for aggregations within one year
query_must.push t
# before/after (relative)
elsif data['operator'] == 'before (relative)' || data['operator'] == 'after (relative)'
when 'before (relative)', 'after (relative)'
range = relative_map[data['range'].to_sym]
if range.blank?
raise "Invalid relative_map for range '#{data['range']}'."
@ -582,7 +585,7 @@ example for aggregations within one year
query_must.push t
# before/after (absolute)
elsif data['operator'] == 'before (absolute)' || data['operator'] == 'after (absolute)'
when 'before (absolute)', 'after (absolute)'
t[:range] = {}
t[:range][key_tmp] = {}
if data['operator'] == 'before (absolute)'

View file

@ -794,9 +794,10 @@ returns
# we use it in rails and non rails context
def self.log(level, message)
if defined?(Rails)
if level == 'debug'
case level
when 'debug'
Rails.logger.debug { message }
elsif level == 'notice'
when 'notice'
Rails.logger.notice message
else
Rails.logger.error message

View file

@ -145,13 +145,14 @@ generate filename based on Store model
def self.filename(file)
hash = Digest::MD5.hexdigest(file.content)
extention = ''
if file.preferences['Content-Type'].match?(/jpg|jpeg/i)
case file.preferences['Content-Type']
when /jpg|jpeg/i
extention = '.jpg'
elsif file.preferences['Content-Type'].match?(/png/i)
when /png/i
extention = '.png'
elsif file.preferences['Content-Type'].match?(/gif/i)
when /gif/i
extention = '.gif'
elsif file.preferences['Content-Type'].match?(/svg/i)
when /svg/i
extention = '.svg'
end
"#{hash}#{extention}"

View file

@ -480,7 +480,8 @@ create a tweet or direct message from an article
def from_article(article)
tweet = nil
if article[:type] == 'twitter direct-message'
case article[:type]
when 'twitter direct-message'
Rails.logger.debug { "Create twitter direct message from article to '#{article[:to]}'..." }
@ -509,7 +510,7 @@ create a tweet or direct message from an article
tweet = Twitter::REST::Request.new(@client, :json_post, '/1.1/direct_messages/events/new.json', data).perform
elsif article[:type] == 'twitter status'
when 'twitter status'
Rails.logger.debug { 'Create tweet from article...' }

View file

@ -77,10 +77,10 @@ RSpec.describe Sessions::Event::ChatSessionStart do
messages = Sessions.queue(client_id)
expect(messages.count).to eq(1)
expect(messages).to eq([
'event' => 'chat_error',
'data' => {
'state' => 'no_permission'
}
{ 'event' => 'chat_error',
'data' => {
'state' => 'no_permission'
} }
])
end
end

View file

@ -53,10 +53,10 @@ RSpec.describe Sessions::Event::ChatTransfer do
messages = Sessions.queue(client_id)
expect(messages.count).to eq(1)
expect(messages).to eq([
'event' => 'chat_error',
'data' => {
'state' => 'no_permission'
}
{ 'event' => 'chat_error',
'data' => {
'state' => 'no_permission'
} }
])
end
end

View file

@ -84,9 +84,9 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
body: 'some body',
type: 'note',
attachments: [
'filename' => 'some_file.txt',
'data' => 'dGVzdCAxMjM=',
'mime-type' => 'text/plain',
{ 'filename' => 'some_file.txt',
'data' => 'dGVzdCAxMjM=',
'mime-type' => 'text/plain' },
],
}
post '/api/v1/ticket_articles', params: params, as: :json

View file

@ -429,9 +429,9 @@ RSpec.describe 'Ticket', type: :request do
subject: 'some test 123',
body: 'some test 123',
attachments: [
'filename' => 'some_file.txt',
'data' => 'dGVzdCAxMjM=',
'mime-type' => 'text/plain',
{ 'filename' => 'some_file.txt',
'data' => 'dGVzdCAxMjM=',
'mime-type' => 'text/plain' },
],
},
}
@ -506,9 +506,9 @@ RSpec.describe 'Ticket', type: :request do
subject: 'some test 123',
body: 'some test 123',
attachments: [
'filename' => 'some_file.txt',
'data' => 'ABC_INVALID_BASE64',
'mime-type' => 'text/plain',
{ 'filename' => 'some_file.txt',
'data' => 'ABC_INVALID_BASE64',
'mime-type' => 'text/plain' },
],
},
}
@ -528,9 +528,9 @@ RSpec.describe 'Ticket', type: :request do
subject: 'some test 123',
body: 'some test 123',
attachments: [
'filename' => 'some_file.txt',
'data' => "LARGE_INVALID_BASE64_#{'#' * 20_000_000}",
'mime-type' => 'text/plain',
{ 'filename' => 'some_file.txt',
'data' => "LARGE_INVALID_BASE64_#{'#' * 20_000_000}",
'mime-type' => 'text/plain' },
],
},
}
@ -550,9 +550,9 @@ RSpec.describe 'Ticket', type: :request do
subject: 'some test 123',
body: 'some test 123',
attachments: [
'filename' => 'some_file.txt',
'data' => Base64.encode64('a' * 1_000),
'mime-type' => 'text/plain',
{ 'filename' => 'some_file.txt',
'data' => Base64.encode64('a' * 1_000),
'mime-type' => 'text/plain' },
],
},
}
@ -576,9 +576,9 @@ RSpec.describe 'Ticket', type: :request do
subject: 'some test 123',
body: 'some test 123',
attachments: [
'filename' => 'some_file.txt',
'data' => Base64.strict_encode64('a' * 1_000),
'mime-type' => 'text/plain',
{ 'filename' => 'some_file.txt',
'data' => Base64.strict_encode64('a' * 1_000),
'mime-type' => 'text/plain' },
],
},
}
@ -602,8 +602,8 @@ RSpec.describe 'Ticket', type: :request do
subject: 'some test 123',
body: 'some test 123',
attachments: [
'filename' => 'some_file.txt',
'data' => 'dGVzdCAxMjM=',
{ 'filename' => 'some_file.txt',
'data' => 'dGVzdCAxMjM=' },
],
},
}
@ -665,9 +665,9 @@ RSpec.describe 'Ticket', type: :request do
body: 'some test 123 <img src="data:image/jpeg;base64,/9j/4QAYRXhpZgAASUkqAAgAAAAAAAAAAAAAAP/sABFEdWNreQABAAQAAAAJAAD/4QMtaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wLwA8P3hwYWNrZXQgYmVnaW49Iu+7vyIgaWQ9Ilc1TTBNcENlaGlIenJlU3pOVGN6a2M5ZCI/PiA8eDp4bXBtZXRhIHhtbG5zOng9ImFkb2JlOm5zOm1ldGEvIiB4OnhtcHRrPSJBZG9iZSBYTVAgQ29yZSA1LjMtYzAxMSA2Ni4xNDU2NjEsIDIwMTIvMDIvMDYtMTQ6NTY6MjcgICAgICAgICI+IDxyZGY6UkRGIHhtbG5zOnJkZj0iaHR0cDovL3d3dy53My5vcmcvMTk5OS8wMi8yMi1yZGYtc3ludGF4LW5zIyI+IDxyZGY6RGVzY3JpcHRpb24gcmRmOmFib3V0PSIiIHhtbG5zOnhtcD0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wLyIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bXA6Q3JlYXRvclRvb2w9IkFkb2JlIFBob3Rvc2hvcCBDUzYgKE1hY2ludG9zaCkiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6QzJCOTE2NzlGQUEwMTFFNjg0M0NGQjU0OUU4MTFEOEIiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6QzJCOTE2N0FGQUEwMTFFNjg0M0NGQjU0OUU4MTFEOEIiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDpDMkI5MTY3N0ZBQTAxMUU2ODQzQ0ZCNTQ5RTgxMUQ4QiIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDpDMkI5MTY3OEZBQTAxMUU2ODQzQ0ZCNTQ5RTgxMUQ4QiIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/Pv/uAA5BZG9iZQBkwAAAAAH/2wCEABQRERoTGioZGSo1KCEoNTEpKCgpMUE4ODg4OEFEREREREREREREREREREREREREREREREREREREREREREREREQBFhoaIh0iKRoaKTkpIik5RDktLTlEREREOERERERERERERERERERERERERERERERERERERERERERERERERERERP/AABEIABAADAMBIgACEQEDEQH/xABbAAEBAAAAAAAAAAAAAAAAAAAEBQEBAQAAAAAAAAAAAAAAAAAABAUQAAEEAgMAAAAAAAAAAAAAAAABAhIDESIxBAURAAICAwAAAAAAAAAAAAAAAAESABNRoQP/2gAMAwEAAhEDEQA/AJDq1rfF3Imeg/1+lFy2oR564DKWWWbweV+Buf/Z"
>',
attachments: [
'filename' => 'some_file.txt',
'data' => 'dGVzdCAxMjM=',
'mime-type' => 'text/plain',
{ 'filename' => 'some_file.txt',
'data' => 'dGVzdCAxMjM=',
'mime-type' => 'text/plain' },
],
},
}

View file

@ -41,7 +41,8 @@ class TestCase < ActiveSupport::TestCase
def profile
browser_profile = nil
if browser == 'firefox'
case browser
when 'firefox'
browser_profile = Selenium::WebDriver::Firefox::Profile.new
browser_profile['intl.locale.matchOS'] = false
@ -50,7 +51,7 @@ class TestCase < ActiveSupport::TestCase
# currently console log not working for firefox
# https://github.com/SeleniumHQ/selenium/issues/1161
#browser_profile['loggingPref'] = { browser: :all }
elsif browser == 'chrome'
when 'chrome'
# profile are only working on remote selenium
if ENV['REMOTE_URL']
@ -89,10 +90,11 @@ class TestCase < ActiveSupport::TestCase
profile: profile,
}
if ENV['BROWSER_HEADLESS'].present?
if browser == 'firefox'
case browser
when 'firefox'
params[:options] = Selenium::WebDriver::Firefox::Options.new
params[:options].add_argument('-headless')
elsif browser == 'chrome'
when 'chrome'
params[:options] = Selenium::WebDriver::Chrome::Options.new
params[:options].add_argument('-headless')
end
@ -3084,17 +3086,18 @@ wait untill text in selector disabppears
end
if data[:role]
if data[:role] == 'Admin'
case data[:role]
when 'Admin'
check(
browser: instance,
css: '.modal input[name=role_ids][value=1]',
)
elsif data[:role] == 'Customer'
when 'Customer'
check(
browser: instance,
css: '.modal input[name=role_ids][value=3]',
)
elsif data[:role] == 'Agent'
when 'Agent'
check(
browser: instance,
css: '.modal input[name=role_ids][value=2]',
@ -3251,17 +3254,18 @@ wait untill text in selector disabppears
end
if data[:role]
if data[:role] == 'Admin'
case data[:role]
when 'Admin'
check(
browser: instance,
css: '.modal input[name=role_ids][value=1]',
)
elsif data[:role] == 'Customer'
when 'Customer'
check(
browser: instance,
css: '.modal input[name=role_ids][value=3]',
)
elsif data[:role] == 'Agent'
when 'Agent'
check(
browser: instance,
css: '.modal input[name=role_ids][value=2]',
@ -4718,7 +4722,8 @@ wait untill text in selector disabppears
if data[:data_option]
if data[:data_option][:options]
if data[:data_type] == 'Boolean'
case data[:data_type]
when 'Boolean'
# rubocop:disable Lint/BooleanSymbol
element = instance.find_elements(css: '.modal .js-valueTrue').first
element.clear
@ -4727,7 +4732,7 @@ wait untill text in selector disabppears
element.clear
element.send_keys(data[:data_option][:options][:false])
# rubocop:enable Lint/BooleanSymbol
elsif data[:data_type] == 'Tree Select'
when 'Tree Select'
add_tree_options(
instance: instance,
options: data[:data_option][:options],

View file

@ -302,7 +302,8 @@ class PackageTest < ActiveSupport::TestCase
]
tests.each do |test|
if test[:action] == 'install'
case test[:action]
when 'install'
begin
package = Package.install(string: test[:zpm])
rescue => e
@ -315,7 +316,7 @@ class PackageTest < ActiveSupport::TestCase
else
assert_not(package, 'install package successful but should not')
end
elsif test[:action] == 'reinstall'
when 'reinstall'
begin
package = Package.reinstall(test[:name])
rescue
@ -328,7 +329,7 @@ class PackageTest < ActiveSupport::TestCase
else
assert_not(package, 'reinstall package successful but should not')
end
elsif test[:action] == 'uninstall'
when 'uninstall'
if test[:zpm]
begin
package = Package.uninstall(string: test[:zpm])
@ -347,7 +348,7 @@ class PackageTest < ActiveSupport::TestCase
else
assert_not(package, 'uninstall package successful but should not')
end
elsif test[:action] == 'auto_install'
when 'auto_install'
if test[:zpm]
if !File.exist?(Rails.root.to_s + '/auto_install/')
Dir.mkdir(Rails.root.to_s + '/auto_install/', 0o755)

View file

@ -89,12 +89,13 @@ class EmailBuildTest < ActiveSupport::TestCase
# check attachments
data[:attachments]&.each do |attachment|
if attachment[:filename] == 'message.html'
case attachment[:filename]
when 'message.html'
assert_nil(attachment[:preferences]['Content-ID'])
assert_equal(true, attachment[:preferences]['content-alternative'])
assert_equal('text/html', attachment[:preferences]['Mime-Type'])
assert_equal('UTF-8', attachment[:preferences]['Charset'])
elsif attachment[:filename] == 'somename.png'
when 'somename.png'
assert_nil(attachment[:preferences]['Content-ID'])
assert_nil(attachment[:preferences]['content-alternative'])
assert_equal('image/png', attachment[:preferences]['Mime-Type'])