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)
rspec-support (3.8.0) rspec-support (3.8.0)
rszr (0.5.2) rszr (0.5.2)
rubocop (0.87.0) rubocop (0.88.0)
parallel (~> 1.10) parallel (~> 1.10)
parser (>= 2.7.1.1) parser (>= 2.7.1.1)
rainbow (>= 2.2.2, < 4.0) rainbow (>= 2.2.2, < 4.0)
@ -468,8 +468,8 @@ GEM
activesupport (>= 4.2.0) activesupport (>= 4.2.0)
rack (>= 1.1) rack (>= 1.1)
rubocop (>= 0.82.0) rubocop (>= 0.82.0)
rubocop-rspec (1.41.0) rubocop-rspec (1.42.0)
rubocop (>= 0.68.1) rubocop (>= 0.87.0)
ruby-progressbar (1.10.1) ruby-progressbar (1.10.1)
ruby-saml (1.10.2) ruby-saml (1.10.2)
nokogiri (>= 1.5.10) 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] periode = params[:periode][0, params[:periode].length - 1]
raise Exceptions::UnprocessableEntity, 'periode need to be an integer!' if periode.to_i.zero? 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 created_at = Time.zone.now - periode.to_i.seconds
elsif scale == 'm' when 'm'
created_at = Time.zone.now - periode.to_i.minutes created_at = Time.zone.now - periode.to_i.minutes
elsif scale == 'h' when 'h'
created_at = Time.zone.now - periode.to_i.hours created_at = Time.zone.now - periode.to_i.hours
elsif scale == 'd' when 'd'
created_at = Time.zone.now - periode.to_i.days created_at = Time.zone.now - periode.to_i.days
end end

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -18,12 +18,13 @@ module Channel::Filter::Database
value = mail[ key.downcase.to_sym ] value = mail[ key.downcase.to_sym ]
match_rule = meta['value'] match_rule = meta['value']
min_one_rule_exists = true 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) if value.present? && Channel::Filter::Match::EmailRegex.match(value: value, match_rule: match_rule)
all_matches_ok = false all_matches_ok = false
Rails.logger.info " matching #{key.downcase}:'#{value}' on #{match_rule}, but shoud not" Rails.logger.info " matching #{key.downcase}:'#{value}' on #{match_rule}, but shoud not"
end end
elsif meta[:operator] == 'contains' when 'contains'
if value.blank? || !Channel::Filter::Match::EmailRegex.match(value: value, match_rule: match_rule) if value.blank? || !Channel::Filter::Match::EmailRegex.match(value: value, match_rule: match_rule)
all_matches_ok = false all_matches_ok = false
Rails.logger.info " not matching #{key.downcase}:'#{value}' on #{match_rule}, but should" 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 # possible event types https://mmonit.com/monit/documentation/#Setting-an-event-filter
if result['state'].blank? 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' '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' 'OK'
else else
'CRITICAL' '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]) chat_session = Chat::Session.find_by(session_id: session_id, state: %w[waiting running])
if chat_session if chat_session
if chat_session.state == 'running' case chat_session.state
when 'running'
user = chat_session.agent_user user = chat_session.agent_user
if user if user
@ -80,7 +81,7 @@ reconnect - chat session already exists, serve agent and session chat messages (
} }
end end
end end
elsif chat_session.state == 'waiting' when 'waiting'
return { return {
state: 'reconnect', state: 'reconnect',
position: chat_session.position, position: chat_session.position,

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -480,7 +480,8 @@ create a tweet or direct message from an article
def from_article(article) def from_article(article)
tweet = nil 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]}'..." } 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 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...' } Rails.logger.debug { 'Create tweet from article...' }

View file

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

View file

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

View file

@ -84,9 +84,9 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
body: 'some body', body: 'some body',
type: 'note', type: 'note',
attachments: [ attachments: [
'filename' => 'some_file.txt', { 'filename' => 'some_file.txt',
'data' => 'dGVzdCAxMjM=', 'data' => 'dGVzdCAxMjM=',
'mime-type' => 'text/plain', 'mime-type' => 'text/plain' },
], ],
} }
post '/api/v1/ticket_articles', params: params, as: :json 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', subject: 'some test 123',
body: 'some test 123', body: 'some test 123',
attachments: [ attachments: [
'filename' => 'some_file.txt', { 'filename' => 'some_file.txt',
'data' => 'dGVzdCAxMjM=', 'data' => 'dGVzdCAxMjM=',
'mime-type' => 'text/plain', 'mime-type' => 'text/plain' },
], ],
}, },
} }
@ -506,9 +506,9 @@ RSpec.describe 'Ticket', type: :request do
subject: 'some test 123', subject: 'some test 123',
body: 'some test 123', body: 'some test 123',
attachments: [ attachments: [
'filename' => 'some_file.txt', { 'filename' => 'some_file.txt',
'data' => 'ABC_INVALID_BASE64', 'data' => 'ABC_INVALID_BASE64',
'mime-type' => 'text/plain', 'mime-type' => 'text/plain' },
], ],
}, },
} }
@ -528,9 +528,9 @@ RSpec.describe 'Ticket', type: :request do
subject: 'some test 123', subject: 'some test 123',
body: 'some test 123', body: 'some test 123',
attachments: [ attachments: [
'filename' => 'some_file.txt', { 'filename' => 'some_file.txt',
'data' => "LARGE_INVALID_BASE64_#{'#' * 20_000_000}", 'data' => "LARGE_INVALID_BASE64_#{'#' * 20_000_000}",
'mime-type' => 'text/plain', 'mime-type' => 'text/plain' },
], ],
}, },
} }
@ -550,9 +550,9 @@ RSpec.describe 'Ticket', type: :request do
subject: 'some test 123', subject: 'some test 123',
body: 'some test 123', body: 'some test 123',
attachments: [ attachments: [
'filename' => 'some_file.txt', { 'filename' => 'some_file.txt',
'data' => Base64.encode64('a' * 1_000), 'data' => Base64.encode64('a' * 1_000),
'mime-type' => 'text/plain', 'mime-type' => 'text/plain' },
], ],
}, },
} }
@ -576,9 +576,9 @@ RSpec.describe 'Ticket', type: :request do
subject: 'some test 123', subject: 'some test 123',
body: 'some test 123', body: 'some test 123',
attachments: [ attachments: [
'filename' => 'some_file.txt', { 'filename' => 'some_file.txt',
'data' => Base64.strict_encode64('a' * 1_000), 'data' => Base64.strict_encode64('a' * 1_000),
'mime-type' => 'text/plain', 'mime-type' => 'text/plain' },
], ],
}, },
} }
@ -602,8 +602,8 @@ RSpec.describe 'Ticket', type: :request do
subject: 'some test 123', subject: 'some test 123',
body: 'some test 123', body: 'some test 123',
attachments: [ attachments: [
'filename' => 'some_file.txt', { 'filename' => 'some_file.txt',
'data' => 'dGVzdCAxMjM=', '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" 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: [ attachments: [
'filename' => 'some_file.txt', { 'filename' => 'some_file.txt',
'data' => 'dGVzdCAxMjM=', 'data' => 'dGVzdCAxMjM=',
'mime-type' => 'text/plain', 'mime-type' => 'text/plain' },
], ],
}, },
} }

View file

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

View file

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

View file

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