Enable Lint/UselessAssignment cop.

This commit is contained in:
Ryan Lue 2019-06-28 13:38:49 +02:00 committed by Thorsten Eckel
parent 7930ffdf03
commit a1da3a27f9
142 changed files with 547 additions and 663 deletions

View file

@ -6,10 +6,6 @@
# Note that changes in the inspected code, or installation of new # Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again. # versions of RuboCop, may require this file to be generated again.
# Offense count: 43
Lint/UselessAssignment:
Enabled: false
# # Offense count: 17 (Competes with same override in .rubocop_todo.yml) # # Offense count: 17 (Competes with same override in .rubocop_todo.yml)
# Metrics/AbcSize: # Metrics/AbcSize:
# Max: 24 # Max: 24

View file

@ -41,7 +41,7 @@ class ApplicationChannelController < ApplicationController
end end
def channel_params def channel_params
params = params.permit!.to_s params.permit!.to_s
end end
end end

View file

@ -101,22 +101,11 @@ module ApplicationController::RendersModels
end end
def model_index_render(object, params) def model_index_render(object, params)
offset = 0 page = (params[:page] || 1).to_i
per_page = 500 per_page = (params[:per_page] || 500).to_i
if params[:page] && params[:per_page] offset = (page - 1) * per_page
offset = (params[:page].to_i - 1) * params[:per_page].to_i
limit = params[:per_page].to_i
end
if per_page > 500 generic_objects = object.order(id: :asc).offset(offset).limit(per_page)
per_page = 500
end
generic_objects = if offset.positive?
object.limit(params[:per_page]).order(id: :asc).offset(offset).limit(limit)
else
object.all.order(id: :asc).offset(offset).limit(limit)
end
if response_expand? if response_expand?
list = [] list = []

View file

@ -171,7 +171,7 @@ class ChannelsEmailController < ApplicationController
channel_id: channel.id, channel_id: channel.id,
) )
else else
address = EmailAddress.create( EmailAddress.create(
realname: params[:meta][:realname], realname: params[:meta][:realname],
email: email, email: email,
active: true, active: true,

View file

@ -96,7 +96,7 @@ module CreatesTicketArticles
begin begin
base64_data = attachment[:data].gsub(/[\r\n]/, '') base64_data = attachment[:data].gsub(/[\r\n]/, '')
attachment_data = Base64.strict_decode64(base64_data) attachment_data = Base64.strict_decode64(base64_data)
rescue ArgumentError => e rescue ArgumentError
raise Exceptions::UnprocessableEntity, "Invalid base64 for attachment with index '#{index}'" raise Exceptions::UnprocessableEntity, "Invalid base64 for attachment with index '#{index}'"
end end

View file

@ -123,7 +123,7 @@ class ImportOtrsController < ApplicationController
end end
def import_check def import_check
statistic = Import::OTRS::Requester.list Import::OTRS::Requester.list
issues = [] issues = []
# check count of dynamic fields # check count of dynamic fields

View file

@ -55,7 +55,7 @@ UserAgent: #{request.env['HTTP_USER_AGENT']}
ticket = Ticket.find_by(id: ticket_id) ticket = Ticket.find_by(id: ticket_id)
next if !ticket next if !ticket
article = Ticket::Article.create!( Ticket::Article.create!(
ticket_id: ticket_id, ticket_id: ticket_id,
type_id: Ticket::Article::Type.find_by(name: 'web').id, type_id: Ticket::Article::Type.find_by(name: 'web').id,
sender_id: Ticket::Article::Sender.find_by(name: 'Customer').id, sender_id: Ticket::Article::Sender.find_by(name: 'Customer').id,
@ -81,7 +81,6 @@ UserAgent: #{request.env['HTTP_USER_AGENT']}
} }
return return
end end
state = Ticket::State.lookup(id: auto_close_state_id)
ticket_ids_found.each do |ticket_id| ticket_ids_found.each do |ticket_id|
ticket = Ticket.find_by(id: ticket_id) ticket = Ticket.find_by(id: ticket_id)
next if !ticket next if !ticket
@ -107,7 +106,7 @@ UserAgent: #{request.env['HTTP_USER_AGENT']}
}, },
} }
) )
article = Ticket::Article.create!( Ticket::Article.create!(
ticket_id: ticket.id, ticket_id: ticket.id,
type_id: Ticket::Article::Type.find_by(name: 'web').id, type_id: Ticket::Article::Type.find_by(name: 'web').id,
sender_id: Ticket::Article::Sender.find_by(name: 'Customer').id, sender_id: Ticket::Article::Sender.find_by(name: 'Customer').id,

View file

@ -9,7 +9,7 @@ class KnowledgeBase::Answer::AttachmentsController < ApplicationController
def create def create
file = params[:file] file = params[:file]
store = Store.add( Store.add(
object: @answer.class.name, object: @answer.class.name,
o_id: @answer.id, o_id: @answer.id,
data: file.read, data: file.read,

View file

@ -89,7 +89,7 @@ class LongPollingController < ApplicationController
return return
end end
end end
rescue => e rescue
raise Exceptions::UnprocessableEntity, 'Invalid client_id in receive loop!' raise Exceptions::UnprocessableEntity, 'Invalid client_id in receive loop!'
end end
end end

View file

@ -52,7 +52,6 @@ curl http://localhost/api/v1/slas.json -v -u #{login}:#{password}
# calendars # calendars
assets = {} assets = {}
calendar_ids = []
Calendar.all.each do |calendar| Calendar.all.each do |calendar|
assets = calendar.assets(assets) assets = calendar.assets(assets)
end end

View file

@ -10,7 +10,6 @@ class TicketOverviewsController < ApplicationController
index_and_lists = Ticket::Overviews.index(current_user) index_and_lists = Ticket::Overviews.index(current_user)
indexes = [] indexes = []
index_and_lists.each do |index| index_and_lists.each do |index|
assets = {}
overview = Overview.lookup(id: index[:overview][:id]) overview = Overview.lookup(id: index[:overview][:id])
meta = { meta = {
name: overview.name, name: overview.name,

View file

@ -49,7 +49,6 @@ class TimeAccountingsController < ApplicationController
end end
if !agents[local_time_unit[:agent_id]] if !agents[local_time_unit[:agent_id]]
agent_user = User.lookup(id: local_time_unit[:agent_id]) agent_user = User.lookup(id: local_time_unit[:agent_id])
agent = '-'
if agent_user if agent_user
agents[local_time_unit[:agent_id]] = agent_user.fullname agents[local_time_unit[:agent_id]] = agent_user.fullname
end end

View file

@ -380,7 +380,7 @@ class UsersController < ApplicationController
query = params[:query] query = params[:query]
if query.respond_to?(:permit!) if query.respond_to?(:permit!)
query = query.permit!.to_h query.permit!.to_h
end end
query = params[:query] || params[:term] query = params[:query] || params[:term]
@ -543,7 +543,7 @@ curl http://localhost/api/v1/users/email_verify_send -v -u #{login}:#{password}
# return # return
#end #end
token = Token.create(action: 'Signup', user_id: user.id) Token.create(action: 'Signup', user_id: user.id)
result = User.signup_new_token(user) result = User.signup_new_token(user)
if result && result[:token] if result && result[:token]

View file

@ -9,7 +9,6 @@ class TicketArticleCommunicateEmailJob < ApplicationJob
# build subject # build subject
ticket = Ticket.lookup(id: record.ticket_id) ticket = Ticket.lookup(id: record.ticket_id)
article_count = Ticket::Article.where(ticket_id: ticket.id).count
subject_prefix_mode = record.preferences[:subtype] subject_prefix_mode = record.preferences[:subtype]

View file

@ -25,8 +25,7 @@ returns
attr.transform_keys!(&:to_sym).slice!(*lookup_keys) attr.transform_keys!(&:to_sym).slice!(*lookup_keys)
raise ArgumentError, "Valid lookup attribute required (#{lookup_keys.join(', ')})" if attr.empty? raise ArgumentError, "Valid lookup attribute required (#{lookup_keys.join(', ')})" if attr.empty?
record = cache_get(attr.values.first) cache_get(attr.values.first) || find_and_save_to_cache_by(attr)
record ||= find_and_save_to_cache_by(attr)
end end
=begin =begin

View file

@ -22,7 +22,6 @@ returns
next if !value next if !value
# get attribute name # get attribute name
attribute_name_with_id = key.to_s
attribute_name = key.to_s attribute_name = key.to_s
next if attribute_name[-3, 3] != '_id' next if attribute_name[-3, 3] != '_id'

View file

@ -86,6 +86,5 @@ store attachments for this object
created_by_id: created_by_id, created_by_id: created_by_id,
) )
end end
attachments_buffer = nil
end end
end end

View file

@ -40,7 +40,7 @@ class Channel::Driver::Sms::Twilio
# find sender # find sender
user = User.where(mobile: attr[:From]).order(:updated_at).first user = User.where(mobile: attr[:From]).order(:updated_at).first
if !user if !user
from_comment, preferences = Cti::CallerId.get_comment_preferences(attr[:From], 'from') _from_comment, preferences = Cti::CallerId.get_comment_preferences(attr[:From], 'from')
if preferences && preferences['from'] && preferences['from'][0] if preferences && preferences['from'] && preferences['from'][0]
if preferences['from'][0]['level'] == 'known' && preferences['from'][0]['object'] == 'User' if preferences['from'][0]['level'] == 'known' && preferences['from'][0]['object'] == 'User'
user = User.find_by(id: preferences['from'][0]['o_id']) user = User.find_by(id: preferences['from'][0]['o_id'])

View file

@ -202,9 +202,6 @@ returns
# save changes set by x-zammad-ticket-followup-* headers # save changes set by x-zammad-ticket-followup-* headers
ticket.save! if ticket.has_changes_to_save? ticket.save! if ticket.has_changes_to_save?
state = Ticket::State.find(ticket.state_id)
state_type = Ticket::StateType.find(state.state_type_id)
# set ticket to open again or keep create state # set ticket to open again or keep create state
if !mail['x-zammad-ticket-followup-state'.to_sym] && !mail['x-zammad-ticket-followup-state_id'.to_sym] if !mail['x-zammad-ticket-followup-state'.to_sym] && !mail['x-zammad-ticket-followup-state_id'.to_sym]
new_state = Ticket::State.find_by(default_create: true) new_state = Ticket::State.find_by(default_create: true)
@ -480,7 +477,7 @@ process unprocessable_mails (tmp/unprocessable_mail/*.eml) again
path = Rails.root.join('tmp', 'unprocessable_mail') path = Rails.root.join('tmp', 'unprocessable_mail')
files = [] files = []
Dir.glob("#{path}/*.eml") do |entry| Dir.glob("#{path}/*.eml") do |entry|
ticket, article, user, mail = Channel::EmailParser.new.process(params, IO.binread(entry)) ticket, _article, _user, _mail = Channel::EmailParser.new.process(params, IO.binread(entry))
next if ticket.blank? next if ticket.blank?
files.push entry files.push entry
@ -608,15 +605,13 @@ process unprocessable_mails (tmp/unprocessable_mail/*.eml) again
file.header.fields.each do |field| file.header.fields.each do |field|
# full line, encode, ready for storage # full line, encode, ready for storage
value = field.to_utf8 value = field.to_utf8
if value.blank? if value.blank?
value = field.raw_value value = field.raw_value
end end
headers_store[field.name.to_s] = value headers_store[field.name.to_s] = value
rescue => e rescue
headers_store[field.name.to_s] = field.raw_value headers_store[field.name.to_s] = field.raw_value
end end
# cleanup content id, <> will be added automatically later # cleanup content id, <> will be added automatically later

View file

@ -80,9 +80,6 @@ class Channel::Filter::MonitoringBase
end end
end end
# check if ticket with host is open
customer = User.lookup(id: session_user_id)
# follow up detection by meta data # follow up detection by meta data
open_states = Ticket::State.by_category(:open) open_states = Ticket::State.by_category(:open)
ticket_ids = Ticket.where(state: open_states).order(created_at: :desc).limit(5000).pluck(:id) ticket_ids = Ticket.where(state: open_states).order(created_at: :desc).limit(5000).pluck(:id)

View file

@ -26,7 +26,7 @@ module ChecksConditionValidation
value: 1, value: 1,
} }
ticket_count, tickets = Ticket.selectors(validate_condition, limit: 1, current_user: User.find(1)) ticket_count, _tickets = Ticket.selectors(validate_condition, limit: 1, current_user: User.find(1))
return true if ticket_count.present? return true if ticket_count.present?
raise Exceptions::UnprocessableEntity, 'Invalid ticket selector conditions' raise Exceptions::UnprocessableEntity, 'Invalid ticket selector conditions'

View file

@ -248,7 +248,7 @@ module HasGroups
return if group_access_buffer.nil? return if group_access_buffer.nil?
yield yield
group_access_buffer = nil self.group_access_buffer = nil
cache_delete cache_delete
end end

View file

@ -135,7 +135,7 @@ job.run(true)
end end
def matching_count def matching_count
ticket_count, tickets = Ticket.selectors(condition, limit: 1) ticket_count, _tickets = Ticket.selectors(condition, limit: 1)
ticket_count || 0 ticket_count || 0
end end

View file

@ -49,7 +49,7 @@ class KnowledgeBase::Answer < ApplicationModel
end end
data = ApplicationModel::CanAssets.reduce(siblings, data) data = ApplicationModel::CanAssets.reduce(siblings, data)
data = ApplicationModel::CanAssets.reduce(translations, data) ApplicationModel::CanAssets.reduce(translations, data)
end end
attachments_cleanup! attachments_cleanup!

View file

@ -50,7 +50,7 @@ class KnowledgeBase::Category < ApplicationModel
data = ApplicationModel::CanAssets.reduce(translations, data) data = ApplicationModel::CanAssets.reduce(translations, data)
# include parent category or KB for root to have full path # include parent category or KB for root to have full path
data = (parent || knowledge_base).assets(data) (parent || knowledge_base).assets(data)
end end
def self_parent?(candidate) def self_parent?(candidate)

View file

@ -54,7 +54,6 @@ list of all attributes
result = ObjectManager::Attribute.all.order('position ASC, name ASC') result = ObjectManager::Attribute.all.order('position ASC, name ASC')
references = ObjectManager::Attribute.attribute_to_references_hash references = ObjectManager::Attribute.attribute_to_references_hash
attributes = [] attributes = []
assets = {}
result.each do |item| result.each do |item|
attribute = item.attributes attribute = item.attributes
attribute[:object] = ObjectLookup.by_id(item.object_lookup_id) attribute[:object] = ObjectLookup.by_id(item.object_lookup_id)
@ -908,7 +907,7 @@ is certain attribute used by triggers, overviews or schedulers
# fixes issue #2236 - Naming an attribute "attribute" causes ActiveRecord failure # fixes issue #2236 - Naming an attribute "attribute" causes ActiveRecord failure
begin begin
ObjectLookup.by_id(object_lookup_id).constantize.instance_method_already_implemented? name ObjectLookup.by_id(object_lookup_id).constantize.instance_method_already_implemented? name
rescue ActiveRecord::DangerousAttributeError => e rescue ActiveRecord::DangerousAttributeError
raise "#{name} is a reserved word, please choose a different one" raise "#{name} is a reserved word, please choose a different one"
end end

View file

@ -22,7 +22,7 @@ class ObjectManager::Attribute::Validation::Required < ObjectManager::Attribute:
end end
def user_id def user_id
user_id ||= UserInfo.current_user_id @user_id ||= UserInfo.current_user_id
end end
def user def user

View file

@ -25,7 +25,6 @@ class Observer::Sla::TicketRebuildEscalation < ActiveRecord::Observer
# check if condition has changed # check if condition has changed
changed = false changed = false
fields_to_check = nil
fields_to_check = if record.class == Sla fields_to_check = if record.class == Sla
%w[condition calendar_id first_response_time update_time solution_time] %w[condition calendar_id first_response_time update_time solution_time]
else else

View file

@ -217,7 +217,6 @@ class Observer::Transaction < ActiveRecord::Observer
# do not send anything if nothing has changed # do not send anything if nothing has changed
return true if real_changes.blank? return true if real_changes.blank?
changed_by_id = nil
changed_by_id = if record.respond_to?('updated_by_id') changed_by_id = if record.respond_to?('updated_by_id')
record.updated_by_id record.updated_by_id
else else

View file

@ -505,8 +505,6 @@ execute all pending package migrations at once
return true if !File.exist?(location) return true if !File.exist?(location)
migrations_done = Package::Migration.where(name: package.underscore)
# get existing migrations # get existing migrations
migrations_existing = [] migrations_existing = []
Dir.foreach(location) do |entry| Dir.foreach(location) do |entry|

View file

@ -287,7 +287,6 @@ returns
local_sha = Digest::SHA256.hexdigest(content) local_sha = Digest::SHA256.hexdigest(content)
cache_key = "image-resize-#{local_sha}_#{width}" cache_key = "image-resize-#{local_sha}_#{width}"
all = nil
image = Cache.get(cache_key) image = Cache.get(cache_key)
return image if image return image if image

View file

@ -108,7 +108,7 @@ class Store::Provider::File
if !File.exist?(location) if !File.exist?(location)
FileUtils.mkdir_p(location) FileUtils.mkdir_p(location)
end end
full_path = location += file full_path = location + file
full_path.gsub('//', '/') full_path.gsub('//', '/')
end end

View file

@ -100,7 +100,7 @@ push text_modules to online
# set new translator_key if given # set new translator_key if given
if result.data['translator_key'] if result.data['translator_key']
translator_key = Setting.set('translator_key', result.data['translator_key']) Setting.set('translator_key', result.data['translator_key'])
end end
true true

View file

@ -197,7 +197,7 @@ returns
tickets.each do |ticket| tickets.each do |ticket|
# get sla # get sla
sla = ticket.escalation_calculation_get_sla ticket.escalation_calculation_get_sla
article_id = nil article_id = nil
article = Ticket::Article.last_customer_agent_article(ticket.id) article = Ticket::Article.last_customer_agent_article(ticket.id)
@ -1129,10 +1129,8 @@ perform active triggers on ticket
return [true, message] return [true, message]
end end
local_send_notification = true
if article && send_notification == false && trigger.perform['notification.email'] && trigger.perform['notification.email']['recipient'] if article && send_notification == false && trigger.perform['notification.email'] && trigger.perform['notification.email']['recipient']
recipient = trigger.perform['notification.email']['recipient'] recipient = trigger.perform['notification.email']['recipient']
local_send_notification = false
local_options[:send_notification] = false local_options[:send_notification] = false
if recipient.include?('ticket_customer') || recipient.include?('article_last_sender') if recipient.include?('ticket_customer') || recipient.include?('article_last_sender')
logger.info { "Skip trigger (#{trigger.name}/#{trigger.id}) because sender do not want to get auto responder for object (Ticket/#{ticket.id}/Article/#{article.id})" } logger.info { "Skip trigger (#{trigger.name}/#{trigger.id}) because sender do not want to get auto responder for object (Ticket/#{ticket.id}/Article/#{article.id})" }
@ -1576,7 +1574,7 @@ result
).render.html2text.tr(' ', ' ') # convert non-breaking space to simple space ).render.html2text.tr(' ', ' ') # convert non-breaking space to simple space
# attributes content_type is not needed for SMS # attributes content_type is not needed for SMS
article = Ticket::Article.create( Ticket::Article.create(
ticket_id: id, ticket_id: id,
subject: 'SMS notification', subject: 'SMS notification',
to: sms_recipients_to, to: sms_recipients_to,

View file

@ -88,7 +88,6 @@ class Transaction::Notification
end end
# send notifications # send notifications
recipient_list = ''
recipients_and_channels.each do |item| recipients_and_channels.each do |item|
user = item[:user] user = item[:user]
channels = item[:channels] channels = item[:channels]

View file

@ -90,7 +90,7 @@ push translations to online
# set new translator_key if given # set new translator_key if given
if result.data['translator_key'] if result.data['translator_key']
translator_key = Setting.set('translator_key', result.data['translator_key']) Setting.set('translator_key', result.data['translator_key'])
end end
true true
@ -147,7 +147,6 @@ get list of translations
Translation.where(locale: locale.downcase).where.not(target: '').order(:source) Translation.where(locale: locale.downcase).where.not(target: '').order(:source)
end end
translations.each do |item| translations.each do |item|
translation_item = []
translation_item = if admin translation_item = if admin
[ [
item.id, item.id,
@ -405,7 +404,7 @@ Get source file at https://i18n.zammad.com/api/v1/translations_empty_translation
col_sep: ',', col_sep: ',',
} }
rows = ::CSV.parse(content, params) rows = ::CSV.parse(content, params)
header = rows.shift rows.shift # remove header
translation_raw = [] translation_raw = []
rows.each do |row| rows.each do |row|

View file

@ -441,7 +441,6 @@ returns
def permissions?(key) def permissions?(key)
keys = key keys = key
names = []
if key.class == String if key.class == String
keys = [key] keys = [key]
end end
@ -715,8 +714,14 @@ returns
def merge(user_id_of_duplicate_user) def merge(user_id_of_duplicate_user)
# find email addresses and move them to primary user # Raise an exception if the user is not found (?)
duplicate_user = User.find(user_id_of_duplicate_user) #
# (This line used to contain a useless variable assignment,
# and was changed to satisfy the linter.
# We're not certain of its original intention,
# so the User.find call has been kept
# to prevent any unexpected regressions.)
User.find(user_id_of_duplicate_user)
# merge missing attibutes # merge missing attibutes
Models.merge('User', id, user_id_of_duplicate_user) Models.merge('User', id, user_id_of_duplicate_user)

View file

@ -22,7 +22,6 @@ class OutOfOffice2 < ActiveRecord::Migration[4.2]
end end
role_ids = Role.with_permissions(['ticket.agent']).map(&:id) role_ids = Role.with_permissions(['ticket.agent']).map(&:id)
overview_role = Role.find_by(name: 'Agent')
Overview.create_or_update( Overview.create_or_update(
name: 'My replacement Tickets', name: 'My replacement Tickets',
link: 'my_replacement_tickets', link: 'my_replacement_tickets',

View file

@ -153,7 +153,8 @@ class String
text_compare.downcase! text_compare.downcase!
text_compare.sub!(%r{/$}, '') text_compare.sub!(%r{/$}, '')
end end
placeholder = if link_compare.present? && text_compare.blank?
if link_compare.present? && text_compare.blank?
link link
elsif link_compare.blank? && text_compare.present? elsif link_compare.blank? && text_compare.present?
text text
@ -180,10 +181,10 @@ class String
# pre/code handling 1/2 # pre/code handling 1/2
string.gsub!(%r{<pre>(.+?)</pre>}m) do |placeholder| string.gsub!(%r{<pre>(.+?)</pre>}m) do |placeholder|
placeholder = placeholder.gsub(/\n/, '###BR###') placeholder.gsub(/\n/, '###BR###')
end end
string.gsub!(%r{<code>(.+?)</code>}m) do |placeholder| string.gsub!(%r{<code>(.+?)</code>}m) do |placeholder|
placeholder = placeholder.gsub(/\n/, '###BR###') placeholder.gsub(/\n/, '###BR###')
end end
# insert spaces on [A-z]\n[A-z] # insert spaces on [A-z]\n[A-z]
@ -231,7 +232,8 @@ class String
if content.match?(/^www/i) if content.match?(/^www/i)
content = "http://#{content}" content = "http://#{content}"
end end
placeholder = if content =~ /^(http|https|ftp|tel)/i
if content =~ /^(http|https|ftp|tel)/i
"#{pre}######LINKRAW:#{content}#######{post}" "#{pre}######LINKRAW:#{content}#######{post}"
else else
"#{pre}#{content}#{post}" "#{pre}#{content}#{post}"
@ -374,7 +376,7 @@ class String
] ]
map.each do |regexp| map.each do |regexp|
string.sub!(/#{regexp}/m) do |placeholder| string.sub!(/#{regexp}/m) do |placeholder|
placeholder = "#{marker}#{placeholder}" "#{marker}#{placeholder}"
end end
end end
return string return string
@ -388,7 +390,7 @@ class String
# search for signature separator "--\n" # search for signature separator "--\n"
string.sub!(/^\s{0,2}--\s{0,2}$/) do |placeholder| string.sub!(/^\s{0,2}--\s{0,2}$/) do |placeholder|
placeholder = "#{marker}#{placeholder}" "#{marker}#{placeholder}"
end end
map = {} map = {}
@ -444,14 +446,12 @@ class String
#map['word-en-de'] = "[^#{marker}].{1,250}\s(wrote|schrieb):" #map['word-en-de'] = "[^#{marker}].{1,250}\s(wrote|schrieb):"
map.each_value do |regexp| map.each_value do |regexp|
string.sub!(/#{regexp}/) do |placeholder| string.sub!(/#{regexp}/) do |placeholder|
placeholder = "#{marker}#{placeholder}" "#{marker}#{placeholder}"
end
rescue rescue
# regexp was not possible because of some string encoding issue, use next # regexp was not possible because of some string encoding issue, use next
Rails.logger.debug { "Invalid string/charset combination with regexp #{regexp} in string" } Rails.logger.debug { "Invalid string/charset combination with regexp #{regexp} in string" }
end
end end
string string

View file

@ -155,7 +155,7 @@ class ExternalCredential::Twitter
# verify if webhook is already registered # verify if webhook is already registered
begin begin
webhooks = client.webhooks_by_env_name(env_name) webhooks = client.webhooks_by_env_name(env_name)
rescue => e rescue
begin begin
webhooks = client.webhooks webhooks = client.webhooks
raise "Unable to get list of webooks. You use the wrong 'Dev environment label', only #{webhooks.inspect} available." raise "Unable to get list of webooks. You use the wrong 'Dev environment label', only #{webhooks.inspect} available."

View file

@ -143,7 +143,7 @@ or if you only want to create 100 tickets
if !overviews.zero? if !overviews.zero?
(1..overviews).each do (1..overviews).each do
ActiveRecord::Base.transaction do ActiveRecord::Base.transaction do
overview = Overview.create!( Overview.create!(
name: "Filloverview::#{rand(999_999)}", name: "Filloverview::#{rand(999_999)}",
role_ids: [Role.find_by(name: 'Agent').id], role_ids: [Role.find_by(name: 'Agent').id],
condition: { condition: {
@ -190,7 +190,7 @@ or if you only want to create 100 tickets
) )
# create article # create article
article = Ticket::Article.create!( Ticket::Article.create!(
ticket_id: ticket.id, ticket_id: ticket.id,
from: customer.email, from: customer.email,
to: 'some_recipient@example.com', to: 'some_recipient@example.com',

View file

@ -193,7 +193,6 @@ satinize html string based on whiltelist
end end
end end
new_string = ''
done = true done = true
while done while done
new_string = Loofah.fragment(string).scrub!(scrubber_wipe).to_s new_string = Loofah.fragment(string).scrub!(scrubber_wipe).to_s
@ -205,7 +204,7 @@ satinize html string based on whiltelist
Loofah.fragment(string).scrub!(scrubber_link).to_s Loofah.fragment(string).scrub!(scrubber_link).to_s
end end
rescue Timeout::Error => e rescue Timeout::Error
UNPROCESSABLE_HTML_MSG UNPROCESSABLE_HTML_MSG
end end
@ -237,7 +236,7 @@ cleanup html string:
string = cleanup_structure(string) string = cleanup_structure(string)
string string
end end
rescue Timeout::Error => e rescue Timeout::Error
UNPROCESSABLE_HTML_MSG UNPROCESSABLE_HTML_MSG
end end
@ -302,7 +301,6 @@ cleanup html string:
end end
end end
new_string = ''
done = true done = true
while done while done
new_string = Loofah.fragment(string).scrub!(scrubber_structure).to_s new_string = Loofah.fragment(string).scrub!(scrubber_structure).to_s

View file

@ -15,7 +15,7 @@ module Import
properties = @resource.get_all_properties! properties = @resource.get_all_properties!
result = normalize(properties) result = normalize(properties)
flattened = flatten(result) flattened = flatten(result)
booleanized = booleanize_values(flattened) booleanize_values(flattened)
end end
end end

View file

@ -5,7 +5,7 @@ module Import
def initialize(article) def initialize(article)
import(article) import(article)
rescue Exceptions::UnprocessableEntity => e rescue Exceptions::UnprocessableEntity
log "ERROR: Can't extract customer from Article #{article[:id]}" log "ERROR: Can't extract customer from Article #{article[:id]}"
end end

View file

@ -18,7 +18,7 @@ module Import
def add(object, name, attribute) def add(object, name, attribute)
ObjectManager::Attribute.add( attribute_config(object, name, attribute) ) ObjectManager::Attribute.add( attribute_config(object, name, attribute) )
ObjectManager::Attribute.migration_execute(false) ObjectManager::Attribute.migration_execute(false)
rescue => e rescue
# rubocop:disable Style/SpecialGlobalVars # rubocop:disable Style/SpecialGlobalVars
raise $!, "Problem with ObjectManager Attribute '#{name}': #{$!}", $!.backtrace raise $!, "Problem with ObjectManager Attribute '#{name}': #{$!}", $!.backtrace
# rubocop:enable Style/SpecialGlobalVars # rubocop:enable Style/SpecialGlobalVars

View file

@ -22,11 +22,6 @@ returns
def self.aggs(params_origin) def self.aggs(params_origin)
params = params_origin.dup params = params_origin.dup
interval = params[:interval]
if params[:interval] == 'week'
interval = 'day'
end
result = [] result = []
if params[:interval] == 'month' if params[:interval] == 'month'
stop_interval = 12 stop_interval = 12

View file

@ -263,7 +263,6 @@ class Report::Base
query, bind_params, tables = Ticket.selector2sql(data[:condition]) query, bind_params, tables = Ticket.selector2sql(data[:condition])
ticket_list = Ticket.where('tickets.created_at >= ? AND tickets.created_at <= ?', data[:start], data[:end]) ticket_list = Ticket.where('tickets.created_at >= ? AND tickets.created_at <= ?', data[:start], data[:end])
.where(query, *bind_params).joins(tables) .where(query, *bind_params).joins(tables)
tickets = 0
time_min = 0 time_min = 0
ticket_ids = [] ticket_ids = []
ticket_list.each do |ticket| ticket_list.each do |ticket|
@ -301,7 +300,6 @@ class Report::Base
query, bind_params, tables = Ticket.selector2sql(data[:condition]) query, bind_params, tables = Ticket.selector2sql(data[:condition])
ticket_list = Ticket.where('tickets.created_at >= ? AND tickets.created_at <= ?', data[:start], data[:end]) ticket_list = Ticket.where('tickets.created_at >= ? AND tickets.created_at <= ?', data[:start], data[:end])
.where(query, *bind_params).joins(tables) .where(query, *bind_params).joins(tables)
tickets = 0
time_max = 0 time_max = 0
ticket_ids = [] ticket_ids = []
ticket_list.each do |ticket| ticket_list.each do |ticket|
@ -334,7 +332,6 @@ class Report::Base
def self.ticket_condition(ticket_id, condition) def self.ticket_condition(ticket_id, condition)
ticket = Ticket.lookup( id: ticket_id ) ticket = Ticket.lookup( id: ticket_id )
match = true
condition.each do |key, value| condition.each do |key, value|
if ticket[key.to_sym] != value if ticket[key.to_sym] != value
return false return false

View file

@ -17,10 +17,6 @@ returns
def self.aggs(params_origin) def self.aggs(params_origin)
params = params_origin.dup params = params_origin.dup
interval = params[:interval]
if params[:interval] == 'week'
interval = 'day'
end
result = [] result = []
if params[:interval] == 'month' if params[:interval] == 'month'

View file

@ -26,11 +26,6 @@ returns
return [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] return [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
end end
interval = params[:interval]
if params[:interval] == 'week'
interval = 'day'
end
result = [] result = []
if params[:interval] == 'month' if params[:interval] == 'month'
stop_interval = 12 stop_interval = 12
@ -113,7 +108,6 @@ returns
} }
end end
local_params = group_attributes(selector, params) local_params = group_attributes(selector, params)
local_selector = params[:selector].clone
without_merged_tickets = { without_merged_tickets = {
'ticket_state.name' => { 'ticket_state.name' => {
'operator' => 'is not', 'operator' => 'is not',

View file

@ -20,11 +20,6 @@ returns
params = params_origin.dup params = params_origin.dup
ticket_state_ids = ticket_ids ticket_state_ids = ticket_ids
interval = params[:interval]
if params[:interval] == 'week'
interval = 'day'
end
result = [] result = []
if params[:interval] == 'month' if params[:interval] == 'month'
stop_interval = 12 stop_interval = 12

View file

@ -171,7 +171,7 @@ class SearchKnowledgeBaseBackend
} }
end end
if (scope = @params.fetch(:scope, nil)) if @params.fetch(:scope, nil)
scope = { terms: { scope_id: @cached_scope_ids } } scope = { terms: { scope_id: @cached_scope_ids } }
output[:query_extension][:bool][:must].push scope output[:query_extension][:bool][:must].push scope

View file

@ -37,7 +37,7 @@ class Sequencer
def mandatory_missing? def mandatory_missing?
values = attribute_value.fetch_values(*mandatory) values = attribute_value.fetch_values(*mandatory)
values.none?(&:present?) values.none?(&:present?)
rescue KeyError => e rescue KeyError
false false
end end
end end

View file

@ -35,7 +35,7 @@ class Sequencer
# per request # per request
def update_ticket_count def update_ticket_count
update_import_job update_import_job
previous_page = next_page next_page
end end
attr_accessor :previous_page attr_accessor :previous_page

View file

@ -23,7 +23,7 @@ class Service::GeoLocation::Gmaps
lat = result['results'].first['geometry']['location']['lat'] lat = result['results'].first['geometry']['location']['lat']
lng = result['results'].first['geometry']['location']['lng'] lng = result['results'].first['geometry']['location']['lng']
latlng = [lat, lng] [lat, lng]
end end
def self.reverse_geocode(lat, lng) def self.reverse_geocode(lat, lng)

View file

@ -440,7 +440,6 @@ returns
files.push entry files.push entry
end end
files.sort.each do |entry| files.sort.each do |entry|
filename = "#{path}/#{entry}"
next if entry !~ /^send/ next if entry !~ /^send/
message = Sessions.queue_file_read(path, entry) message = Sessions.queue_file_read(path, entry)

View file

@ -72,7 +72,6 @@ class Sessions::Backend::TicketOverviewList < Sessions::Backend::Base
# push overview index # push overview index
indexes = [] indexes = []
index_and_lists.each do |index| index_and_lists.each do |index|
assets = {}
overview = Overview.lookup(id: index[:overview][:id]) overview = Overview.lookup(id: index[:overview][:id])
next if !overview next if !overview

View file

@ -20,7 +20,6 @@ class Stats::TicketEscalation
).count ).count
average = '-' average = '-'
state = 'supergood'
state = if own_escalated.zero? state = if own_escalated.zero?
'supergood' 'supergood'
elsif own_escalated <= 1 elsif own_escalated <= 1

View file

@ -23,7 +23,6 @@ class Stats::TicketResponseTime
def self.generate(user) def self.generate(user)
items = StatsStore.where('created_at > ? AND created_at < ?', Time.zone.now - 7.days, Time.zone.now).where(key: 'ticket:response_time') items = StatsStore.where('created_at > ? AND created_at < ?', Time.zone.now - 7.days, Time.zone.now).where(key: 'ticket:response_time')
count_total = items.count
total = 0 total = 0
count_own = 0 count_own = 0
own = 0 own = 0

View file

@ -25,7 +25,6 @@ class Stats::TicketWaitingTime
average_per_agent = (average_per_agent / 60).round average_per_agent = (average_per_agent / 60).round
end end
state = 'supergood'
percent = 0 percent = 0
state = if handling_time <= 60 state = if handling_time <= 60
percent = handling_time.to_f / 60 percent = handling_time.to_f / 60

View file

@ -24,7 +24,7 @@ namespace :zammad do
env env
] ]
stdout, stderr, status = Open3.capture3(*command) _stdout, stderr, status = Open3.capture3(*command)
next if status.success? next if status.success?

View file

@ -16,7 +16,7 @@ namespace :zammad do
'start', 'start',
] ]
stdout, stderr, status = Open3.capture3(*command) _stdout, stderr, status = Open3.capture3(*command)
next if status.success? next if status.success?

View file

@ -16,7 +16,7 @@ namespace :zammad do
'stop', 'stop',
] ]
stdout, stderr, status = Open3.capture3(*command) _stdout, stderr, status = Open3.capture3(*command)
next if status.success? next if status.success?

View file

@ -20,7 +20,7 @@ namespace :zammad do
port port
] ]
stdout, stderr, status = Open3.capture3(*command) _stdout, stderr, status = Open3.capture3(*command)
next if status.success? next if status.success?

View file

@ -16,7 +16,7 @@ namespace :zammad do
'stop', 'stop',
] ]
stdout, stderr, status = Open3.capture3(*command) _stdout, stderr, status = Open3.capture3(*command)
next if status.success? next if status.success?

View file

@ -345,10 +345,6 @@ class TwitterSync
# import tweet # import tweet
to = nil to = nil
from = nil
article_type = nil
in_reply_to = nil
twitter_preferences = {}
raise "Unknown tweet type '#{tweet.class}'" if tweet.class != Twitter::Tweet raise "Unknown tweet type '#{tweet.class}'" if tweet.class != Twitter::Tweet
article_type = 'twitter status' article_type = 'twitter status'
@ -504,7 +500,6 @@ create a tweet ot direct message from an article
def get_state(channel, tweet, ticket = nil) def get_state(channel, tweet, ticket = nil)
user_id = nil
user_id = if tweet.is_a?(Hash) user_id = if tweet.is_a?(Hash)
if tweet['user'] && tweet['user']['id'] if tweet['user'] && tweet['user']['id']
tweet['user']['id'] tweet['user']['id']

View file

@ -64,7 +64,6 @@ before_fork
i: "#{dir}/tmp/pids/websocket.pid" i: "#{dir}/tmp/pids/websocket.pid"
} }
tls_options = {}
OptionParser.new do |opts| OptionParser.new do |opts|
opts.banner = 'Usage: websocket-server.rb start|stop [options]' opts.banner = 'Usage: websocket-server.rb start|stop [options]'

View file

@ -12,7 +12,7 @@ RSpec.describe Issue1977RemoveInvalidUserForeignKeys, type: :db_migration do
without_foreign_key(:online_notifications, column: :user_id) without_foreign_key(:online_notifications, column: :user_id)
create(:online_notification, user_id: 1337) create(:online_notification, user_id: 1337)
valid = create(:online_notification, user_id: existing_user_id) create(:online_notification, user_id: existing_user_id)
expect do expect do
migrate migrate
@ -24,7 +24,7 @@ RSpec.describe Issue1977RemoveInvalidUserForeignKeys, type: :db_migration do
without_foreign_key(:recent_views, column: :created_by_id) without_foreign_key(:recent_views, column: :created_by_id)
create(:recent_view, created_by_id: 1337) create(:recent_view, created_by_id: 1337)
valid = create(:recent_view, created_by_id: existing_user_id) create(:recent_view, created_by_id: existing_user_id)
expect do expect do
migrate migrate
@ -35,8 +35,8 @@ RSpec.describe Issue1977RemoveInvalidUserForeignKeys, type: :db_migration do
without_foreign_key(:online_notifications, column: :user_id) without_foreign_key(:online_notifications, column: :user_id)
create(:avatar, object_lookup_id: ObjectLookup.by_name('User'), o_id: 1337) create(:avatar, object_lookup_id: ObjectLookup.by_name('User'), o_id: 1337)
valid_ticket = create(:avatar, object_lookup_id: ObjectLookup.by_name('Ticket'), o_id: 1337) create(:avatar, object_lookup_id: ObjectLookup.by_name('Ticket'), o_id: 1337)
valid_user = create(:avatar, object_lookup_id: ObjectLookup.by_name('User'), o_id: existing_user_id) create(:avatar, object_lookup_id: ObjectLookup.by_name('User'), o_id: existing_user_id)
expect do expect do
migrate migrate

View file

@ -4,13 +4,15 @@ RSpec.describe TicketUserTicketCounterJob, type: :job do
let!(:customer) { create(:user) } let!(:customer) { create(:user) }
let!(:tickets) do let!(:ticket_states) do
ticket_states = { {
open: Ticket::State.by_category(:open).first, open: Ticket::State.by_category(:open).first,
closed: Ticket::State.by_category(:closed).first, closed: Ticket::State.by_category(:closed).first,
} }
end
tickets = { let!(:tickets) do
{
open: [ open: [
create(:ticket, state_id: ticket_states[:open].id, customer_id: customer.id), create(:ticket, state_id: ticket_states[:open].id, customer_id: customer.id),
create(:ticket, state_id: ticket_states[:open].id, customer_id: customer.id), create(:ticket, state_id: ticket_states[:open].id, customer_id: customer.id),

View file

@ -67,6 +67,6 @@ RSpec.describe Import::Zendesk::ObjectAttribute::Dropdown do
expect(ObjectManager::Attribute).to receive(:add).with(expected_structure) expect(ObjectManager::Attribute).to receive(:add).with(expected_structure)
expect(ObjectManager::Attribute).to receive(:migration_execute) expect(ObjectManager::Attribute).to receive(:migration_execute)
created_instance = described_class.new('Ticket', 'example_field', attribute) described_class.new('Ticket', 'example_field', attribute)
end end
end end

View file

@ -67,6 +67,6 @@ RSpec.describe Import::Zendesk::ObjectAttribute::Tagger do
expect(ObjectManager::Attribute).to receive(:add).with(expected_structure) expect(ObjectManager::Attribute).to receive(:add).with(expected_structure)
expect(ObjectManager::Attribute).to receive(:migration_execute) expect(ObjectManager::Attribute).to receive(:migration_execute)
created_instance = described_class.new('Ticket', 'example_field', attribute) described_class.new('Ticket', 'example_field', attribute)
end end
end end

View file

@ -96,7 +96,7 @@ RSpec.describe Ldap::User do
connection = double() connection = double()
expect(mocked_ldap).to receive(:connection).and_return(connection) expect(mocked_ldap).to receive(:connection).and_return(connection)
ldap_entry = build(:ldap_entry) build(:ldap_entry)
expect(mocked_ldap).to receive(:base_dn) expect(mocked_ldap).to receive(:base_dn)
expect(connection).to receive(:bind_as).and_return(true) expect(connection).to receive(:bind_as).and_return(true)
@ -108,7 +108,7 @@ RSpec.describe Ldap::User do
connection = double() connection = double()
expect(mocked_ldap).to receive(:connection).and_return(connection) expect(mocked_ldap).to receive(:connection).and_return(connection)
ldap_entry = build(:ldap_entry) build(:ldap_entry)
expect(mocked_ldap).to receive(:base_dn) expect(mocked_ldap).to receive(:base_dn)
expect(connection).to receive(:bind_as).and_return(false) expect(connection).to receive(:bind_as).and_return(false)

View file

@ -32,7 +32,7 @@ RSpec.describe NotificationFactory::Renderer do
end end
it 'correctly renders simple select attributes' do it 'correctly renders simple select attributes' do
attribute = create :object_manager_attribute_select, name: 'select' create :object_manager_attribute_select, name: 'select'
ObjectManager::Attribute.migration_execute ObjectManager::Attribute.migration_execute
ticket = create :ticket, customer: @user, select: 'key_1' ticket = create :ticket, customer: @user, select: 'key_1'
@ -52,7 +52,7 @@ RSpec.describe NotificationFactory::Renderer do
end end
it 'correctly renders select attributes on chained user object' do it 'correctly renders select attributes on chained user object' do
attribute = create :object_manager_attribute_select, create :object_manager_attribute_select,
object_lookup_id: ObjectLookup.by_name('User'), object_lookup_id: ObjectLookup.by_name('User'),
name: 'select' name: 'select'
ObjectManager::Attribute.migration_execute ObjectManager::Attribute.migration_execute
@ -77,7 +77,7 @@ RSpec.describe NotificationFactory::Renderer do
end end
it 'correctly renders select attributes on chained group object' do it 'correctly renders select attributes on chained group object' do
attribute = create :object_manager_attribute_select, create :object_manager_attribute_select,
object_lookup_id: ObjectLookup.by_name('Group'), object_lookup_id: ObjectLookup.by_name('Group'),
name: 'select' name: 'select'
ObjectManager::Attribute.migration_execute ObjectManager::Attribute.migration_execute
@ -102,7 +102,7 @@ RSpec.describe NotificationFactory::Renderer do
end end
it 'correctly renders select attributes on chained organization object' do it 'correctly renders select attributes on chained organization object' do
attribute = create :object_manager_attribute_select, create :object_manager_attribute_select,
object_lookup_id: ObjectLookup.by_name('Organization'), object_lookup_id: ObjectLookup.by_name('Organization'),
name: 'select' name: 'select'
ObjectManager::Attribute.migration_execute ObjectManager::Attribute.migration_execute
@ -126,7 +126,7 @@ RSpec.describe NotificationFactory::Renderer do
end end
it 'correctly renders tree select attributes' do it 'correctly renders tree select attributes' do
attribute = create :object_manager_attribute_tree_select, name: 'tree_select' create :object_manager_attribute_tree_select, name: 'tree_select'
ObjectManager::Attribute.migration_execute ObjectManager::Attribute.migration_execute
ticket = create :ticket, customer: @user, tree_select: 'Incident::Hardware::Laptop' ticket = create :ticket, customer: @user, tree_select: 'Incident::Hardware::Laptop'

View file

@ -8,8 +8,6 @@ RSpec.describe Sequencer::Unit::Import::Common::Model::ResetPrimaryKeySequence,
expect(DbHelper).to receive(:import_post).with(model_class.table_name) expect(DbHelper).to receive(:import_post).with(model_class.table_name)
provided = process( process(model_class: model_class)
model_class: model_class,
)
end end
end end

View file

@ -9,8 +9,8 @@ RSpec.describe Trigger do
another_agent = create(:admin_user, mobile: '+37061010000') another_agent = create(:admin_user, mobile: '+37061010000')
Group.lookup(id: 1).users << another_agent Group.lookup(id: 1).users << another_agent
channel = create(:channel, area: 'Sms::Notification') create(:channel, area: 'Sms::Notification')
trigger = create(:trigger, create(:trigger,
disable_notification: false, disable_notification: false,
perform: { perform: {
'notification.sms': { 'notification.sms': {

View file

@ -257,7 +257,6 @@ RSpec.describe 'Monitoring', type: :request do
expect(json_response).to be_a_kind_of(Hash) expect(json_response).to be_a_kind_of(Hash)
expect(json_response['token']).to be_truthy expect(json_response['token']).to be_truthy
token = json_response['token']
expect(json_response['error']).to be_falsey expect(json_response['error']).to be_falsey
end end

View file

@ -11,7 +11,6 @@ RSpec.describe 'ObjectManager Attributes', type: :request do
it 'does add new ticket text object' do it 'does add new ticket text object' do
authenticated_as(admin_user) authenticated_as(admin_user)
post '/api/v1/object_manager_attributes', params: {}, as: :json post '/api/v1/object_manager_attributes', params: {}, as: :json
token = response.headers['CSRF-TOKEN']
# token based on headers # token based on headers
params = { params = {
@ -59,7 +58,6 @@ RSpec.describe 'ObjectManager Attributes', type: :request do
it 'does add new ticket text object - no default' do it 'does add new ticket text object - no default' do
authenticated_as(admin_user) authenticated_as(admin_user)
post '/api/v1/object_manager_attributes', params: {}, as: :json post '/api/v1/object_manager_attributes', params: {}, as: :json
token = response.headers['CSRF-TOKEN']
# token based on headers # token based on headers
params = { params = {
@ -113,7 +111,6 @@ RSpec.describe 'ObjectManager Attributes', type: :request do
authenticated_as(admin_user) authenticated_as(admin_user)
post "/api/v1/object_manager_attributes/#{object.id}", params: {}, as: :json post "/api/v1/object_manager_attributes/#{object.id}", params: {}, as: :json
token = response.headers['CSRF-TOKEN']
# parameters for updating # parameters for updating
params = { params = {
@ -162,7 +159,6 @@ RSpec.describe 'ObjectManager Attributes', type: :request do
it 'does add new ticket boolean object' do it 'does add new ticket boolean object' do
authenticated_as(admin_user) authenticated_as(admin_user)
post '/api/v1/object_manager_attributes', params: {}, as: :json post '/api/v1/object_manager_attributes', params: {}, as: :json
token = response.headers['CSRF-TOKEN']
# token based on headers # token based on headers
params = { params = {
@ -211,7 +207,6 @@ RSpec.describe 'ObjectManager Attributes', type: :request do
it 'does add new user select object' do it 'does add new user select object' do
authenticated_as(admin_user) authenticated_as(admin_user)
post '/api/v1/object_manager_attributes', params: {}, as: :json post '/api/v1/object_manager_attributes', params: {}, as: :json
token = response.headers['CSRF-TOKEN']
# token based on headers # token based on headers
params = { params = {
@ -277,7 +272,6 @@ RSpec.describe 'ObjectManager Attributes', type: :request do
expect(migration).to eq(true) expect(migration).to eq(true)
post "/api/v1/object_manager_attributes/#{object.id}", params: {}, as: :json post "/api/v1/object_manager_attributes/#{object.id}", params: {}, as: :json
token = response.headers['CSRF-TOKEN']
# parameters for updating # parameters for updating
params = { params = {
@ -441,7 +435,7 @@ RSpec.describe 'ObjectManager Attributes', type: :request do
it 'does ticket attributes cannot be removed when it is referenced by an overview (03)', db_strategy: :reset do it 'does ticket attributes cannot be removed when it is referenced by an overview (03)', db_strategy: :reset do
# 1. create a new ticket attribute and execute migration # 1. create a new ticket attribute and execute migration
migration = ObjectManager::Attribute.migration_execute ObjectManager::Attribute.migration_execute
params = { params = {
'name': 'test_attribute_referenced_by_an_overview', 'name': 'test_attribute_referenced_by_an_overview',
@ -536,7 +530,7 @@ RSpec.describe 'ObjectManager Attributes', type: :request do
it 'does ticket attributes cannot be removed when it is referenced by a trigger (04)', db_strategy: :reset do it 'does ticket attributes cannot be removed when it is referenced by a trigger (04)', db_strategy: :reset do
# 1. create a new ticket attribute and execute migration # 1. create a new ticket attribute and execute migration
migration = ObjectManager::Attribute.migration_execute ObjectManager::Attribute.migration_execute
params = { params = {
'name': 'test_attribute_referenced_by_a_trigger', 'name': 'test_attribute_referenced_by_a_trigger',
@ -622,7 +616,7 @@ RSpec.describe 'ObjectManager Attributes', type: :request do
it 'does ticket attributes cannot be removed when it is referenced by a scheduler (05)', db_strategy: :reset do it 'does ticket attributes cannot be removed when it is referenced by a scheduler (05)', db_strategy: :reset do
# 1. create a new ticket attribute and execute migration # 1. create a new ticket attribute and execute migration
migration = ObjectManager::Attribute.migration_execute ObjectManager::Attribute.migration_execute
params = { params = {
'name': 'test_attribute_referenced_by_a_scheduler', 'name': 'test_attribute_referenced_by_a_scheduler',
@ -755,7 +749,7 @@ RSpec.describe 'ObjectManager Attributes', type: :request do
it 'does ticket attributes can be removed when it is referenced by an overview but by user object (06)', db_strategy: :reset do it 'does ticket attributes can be removed when it is referenced by an overview but by user object (06)', db_strategy: :reset do
# 1. create a new ticket attribute and execute migration # 1. create a new ticket attribute and execute migration
migration = ObjectManager::Attribute.migration_execute ObjectManager::Attribute.migration_execute
params = { params = {
'name': 'test_attribute_referenced_by_an_overview', 'name': 'test_attribute_referenced_by_an_overview',

View file

@ -11,7 +11,6 @@ RSpec.describe 'Twilio SMS', type: :request do
it 'does basic call' do it 'does basic call' do
# configure twilio channel # configure twilio channel
bot_id = 123_456_789
group_id = Group.find_by(name: 'Users').id group_id = Group.find_by(name: 'Users').id
UserInfo.current_user_id = 1 UserInfo.current_user_id = 1
@ -179,11 +178,8 @@ RSpec.describe 'Twilio SMS', type: :request do
Observer::Transaction.commit Observer::Transaction.commit
Scheduler.worker(true) Scheduler.worker(true)
# configure twilio channel
bot_id = 123_456_789
UserInfo.current_user_id = 1 UserInfo.current_user_id = 1
channel = create( create(
:channel, :channel,
area: 'Sms::Account', area: 'Sms::Account',
options: { options: {

View file

@ -68,7 +68,7 @@ RSpec.describe 'Ticket Article Attachments', type: :request do
it 'does test attachments for split' do it 'does test attachments for split' do
email_file_path = Rails.root.join('test', 'data', 'mail', 'mail024.box') email_file_path = Rails.root.join('test', 'data', 'mail', 'mail024.box')
email_raw_string = File.read(email_file_path) email_raw_string = File.read(email_file_path)
ticket_p, article_p, user_p = Channel::EmailParser.new.process({}, email_raw_string) ticket_p, article_p, _user_p = Channel::EmailParser.new.process({}, email_raw_string)
authenticated_as(agent_user) authenticated_as(agent_user)
get '/api/v1/ticket_split', params: { form_id: '1234-2', ticket_id: ticket_p.id, article_id: article_p.id }, as: :json get '/api/v1/ticket_split', params: { form_id: '1234-2', ticket_id: ticket_p.id, article_id: article_p.id }, as: :json
@ -83,7 +83,7 @@ RSpec.describe 'Ticket Article Attachments', type: :request do
it 'does test attachments for forward' do it 'does test attachments for forward' do
email_file_path = Rails.root.join('test', 'data', 'mail', 'mail008.box') email_file_path = Rails.root.join('test', 'data', 'mail', 'mail008.box')
email_raw_string = File.read(email_file_path) email_raw_string = File.read(email_file_path)
ticket_p, article_p, user_p = Channel::EmailParser.new.process({}, email_raw_string) _ticket_p, article_p, _user_p = Channel::EmailParser.new.process({}, email_raw_string)
authenticated_as(agent_user) authenticated_as(agent_user)
post "/api/v1/ticket_attachment_upload_clone_by_article/#{article_p.id}", params: {}, as: :json post "/api/v1/ticket_attachment_upload_clone_by_article/#{article_p.id}", params: {}, as: :json
@ -98,7 +98,7 @@ RSpec.describe 'Ticket Article Attachments', type: :request do
email_file_path = Rails.root.join('test', 'data', 'mail', 'mail024.box') email_file_path = Rails.root.join('test', 'data', 'mail', 'mail024.box')
email_raw_string = File.read(email_file_path) email_raw_string = File.read(email_file_path)
ticket_p, article_p, user_p = Channel::EmailParser.new.process({}, email_raw_string) _ticket_p, article_p, _user_p = Channel::EmailParser.new.process({}, email_raw_string)
post "/api/v1/ticket_attachment_upload_clone_by_article/#{article_p.id}", params: { form_id: '1234-2' }, as: :json post "/api/v1/ticket_attachment_upload_clone_by_article/#{article_p.id}", params: { form_id: '1234-2' }, as: :json
expect(response).to have_http_status(:ok) expect(response).to have_http_status(:ok)

View file

@ -110,7 +110,7 @@ Subject: some value 123
Some Text" Some Text"
ticket_p, article_p, user_p, mail = Channel::EmailParser.new.process({}, email) ticket_p, _article_p, user_p, _mail = Channel::EmailParser.new.process({}, email)
ticket_p.reload ticket_p.reload
expect(ticket_p.escalation_at).to be_truthy expect(ticket_p.escalation_at).to be_truthy
expect(ticket_p.first_response_escalation_at.to_i).to be_within(90.seconds).of((ticket_p.created_at + 1.hour).to_i) expect(ticket_p.first_response_escalation_at.to_i).to be_within(90.seconds).of((ticket_p.created_at + 1.hour).to_i)

View file

@ -1951,7 +1951,6 @@ RSpec.describe 'Ticket', type: :request do
it 'does ticket search sorted (08.01)' do it 'does ticket search sorted (08.01)' do
title = "ticket pagination #{rand(999_999_999)}" title = "ticket pagination #{rand(999_999_999)}"
tickets = []
ticket1 = create( ticket1 = create(
:ticket, :ticket,

View file

@ -24,7 +24,7 @@ RSpec.describe 'Time Accounting API endpoints', type: :request do
context 'when requesting a log report download' do context 'when requesting a log report download' do
it 'responds with an Excel spreadsheet' do it 'responds with an Excel spreadsheet' do
group = create(:group) create(:group)
ticket = create(:ticket, state: Ticket::State.lookup(name: 'open'), customer: customer ) ticket = create(:ticket, state: Ticket::State.lookup(name: 'open'), customer: customer )
article = create(:ticket_article, ticket: ticket, type: Ticket::Article::Type.lookup(name: 'note') ) article = create(:ticket_article, ticket: ticket, type: Ticket::Article::Type.lookup(name: 'note') )
@ -46,7 +46,7 @@ RSpec.describe 'Time Accounting API endpoints', type: :request do
it 'responds with an Excel spreadsheet' do it 'responds with an Excel spreadsheet' do
ObjectManager::Attribute.add attributes_for :object_manager_attribute_select ObjectManager::Attribute.add attributes_for :object_manager_attribute_select
group = create(:group) create(:group)
ticket = create(:ticket, state: Ticket::State.lookup(name: 'open'), customer: customer ) ticket = create(:ticket, state: Ticket::State.lookup(name: 'open'), customer: customer )
article = create(:ticket_article, ticket: ticket, type: Ticket::Article::Type.lookup(name: 'note') ) article = create(:ticket_article, ticket: ticket, type: Ticket::Article::Type.lookup(name: 'note') )

View file

@ -14,7 +14,7 @@ class AgentTicketActionLevel0Test < TestCase
tasks_close_all() tasks_close_all()
# create new ticket # create new ticket
ticket1 = ticket_create( ticket_create(
data: { data: {
customer: 'nico', customer: 'nico',
group: '-NONE-', group: '-NONE-',
@ -230,7 +230,7 @@ class AgentTicketActionLevel0Test < TestCase
sleep 12 sleep 12
# create new ticket # create new ticket
ticket1 = ticket_create( ticket_create(
data: { data: {
customer: 'nico', customer: 'nico',
group: 'Users', group: 'Users',

View file

@ -80,7 +80,7 @@ class AdminObjectManagerTest < TestCase
) )
# create new ticket # create new ticket
ticket = ticket_create( ticket_create(
data: { data: {
customer: 'nico', customer: 'nico',
group: 'Users', group: 'Users',
@ -283,7 +283,7 @@ class AdminObjectManagerTest < TestCase
) )
# create new ticket # create new ticket
ticket = ticket_create( ticket_create(
data: { data: {
customer: 'nico', customer: 'nico',
group: 'Users', group: 'Users',
@ -696,7 +696,7 @@ class AdminObjectManagerTest < TestCase
) )
object_manager_attribute_migrate object_manager_attribute_migrate
ticket = ticket_create( ticket_create(
data: { data: {
customer: 'nico', customer: 'nico',
group: 'Users', group: 'Users',

View file

@ -41,7 +41,7 @@ class AdminOverviewTest < TestCase
name = "overview_#{rand(99_999_999)}" name = "overview_#{rand(99_999_999)}"
ticket_titles = (1..3).map { |i| "Priority #{i} ticket" } ticket_titles = (1..3).map { |i| "Priority #{i} ticket" }
@browser = instance = browser_instance @browser = browser_instance
login( login(
username: 'master@example.com', username: 'master@example.com',
password: 'test', password: 'test',

View file

@ -2,8 +2,6 @@ require 'browser_test_helper'
class AdminRoleTest < TestCase class AdminRoleTest < TestCase
def test_role_device def test_role_device
name = "some role #{rand(99_999_999)}"
@browser = browser_instance @browser = browser_instance
login( login(
username: 'master@example.com', username: 'master@example.com',

View file

@ -67,7 +67,7 @@ class AgentNavigationAndTitleTest < TestCase
exists_not(css: '#navigation .js-menu .is-active') exists_not(css: '#navigation .js-menu .is-active')
# ticket zoom screen # ticket zoom screen
ticket1 = ticket_create( ticket_create(
data: { data: {
customer: 'nico', customer: 'nico',
group: 'Users', group: 'Users',

View file

@ -315,7 +315,7 @@ class AgentTicketAttachmentTest < TestCase
) )
tasks_close_all() tasks_close_all()
ticket1 = ticket_create( ticket_create(
data: { data: {
customer: 'Nico', customer: 'Nico',
group: 'Users', group: 'Users',

View file

@ -13,7 +13,7 @@ class AgentTicketEmailReplyKeepBodyTest < TestCase
tasks_close_all() tasks_close_all()
# create new ticket # create new ticket
ticket1 = ticket_create( ticket_create(
data: { data: {
customer: 'nico', customer: 'nico',
group: 'Users', group: 'Users',
@ -98,7 +98,7 @@ class AgentTicketEmailReplyKeepBodyTest < TestCase
end end
def test_full_quote def test_full_quote
@browser = instance = browser_instance @browser = browser_instance
login( login(
username: 'master@example.com', username: 'master@example.com',
password: 'test', password: 'test',
@ -174,7 +174,7 @@ class AgentTicketEmailReplyKeepBodyTest < TestCase
# Regression test for issue #2344 - Missing translation for Full-Quote-Text "on xy wrote" # Regression test for issue #2344 - Missing translation for Full-Quote-Text "on xy wrote"
def test_full_quote_german_locale def test_full_quote_german_locale
@browser = instance = browser_instance @browser = browser_instance
login( login(
username: 'master@example.com', username: 'master@example.com',
password: 'test', password: 'test',

View file

@ -101,7 +101,7 @@ class AgentTicketMacroTest < TestCase
ux_flow_next_up: ux_flow_next_up, ux_flow_next_up: ux_flow_next_up,
) )
ticket = ticket_create( ticket_create(
data: { data: {
customer: 'nico', customer: 'nico',
group: 'Users', group: 'Users',

View file

@ -13,7 +13,7 @@ class AgentTicketOnlineNotificationTest < TestCase
tasks_close_all() tasks_close_all()
# create new ticket # create new ticket
ticket1 = ticket_create( ticket_create(
data: { data: {
customer: 'nico', customer: 'nico',
group: 'Users', group: 'Users',
@ -66,7 +66,7 @@ class AgentTicketOnlineNotificationTest < TestCase
no_quote: true, no_quote: true,
) )
ticket2 = ticket_create( ticket_create(
data: { data: {
customer: 'nico', customer: 'nico',
group: 'Users', group: 'Users',
@ -92,7 +92,7 @@ class AgentTicketOnlineNotificationTest < TestCase
css: '.js-mark.hide', css: '.js-mark.hide',
) )
ticket3 = ticket_create( ticket_create(
data: { data: {
customer: 'nico', customer: 'nico',
group: 'Users', group: 'Users',
@ -138,7 +138,7 @@ class AgentTicketOnlineNotificationTest < TestCase
items = browser2.find_elements(css: '.js-notificationsContainer .js-item.is-inactive') items = browser2.find_elements(css: '.js-notificationsContainer .js-item.is-inactive')
assert_equal(1, items.count) assert_equal(1, items.count)
ticket4 = ticket_create( ticket_create(
data: { data: {
customer: 'nico', customer: 'nico',
group: 'Users', group: 'Users',
@ -179,7 +179,7 @@ class AgentTicketOnlineNotificationTest < TestCase
no_quote: true, no_quote: true,
) )
ticket5 = ticket_create( ticket_create(
data: { data: {
customer: 'nico', customer: 'nico',
group: 'Users', group: 'Users',
@ -260,7 +260,7 @@ class AgentTicketOnlineNotificationTest < TestCase
) )
online_notitifcation_close_all(browser: browser2) online_notitifcation_close_all(browser: browser2)
ticket1 = ticket_create( ticket_create(
data: { data: {
customer: 'nico', customer: 'nico',
group: 'Users', group: 'Users',
@ -268,7 +268,7 @@ class AgentTicketOnlineNotificationTest < TestCase
body: 'online notification render #1', body: 'online notification render #1',
}, },
) )
ticket2 = ticket_create( ticket_create(
data: { data: {
customer: 'nico', customer: 'nico',
group: 'Users', group: 'Users',
@ -301,7 +301,7 @@ class AgentTicketOnlineNotificationTest < TestCase
css: '.js-notificationsContainer .js-items .js-item:nth-child(2) .activity-text', css: '.js-notificationsContainer .js-items .js-item:nth-child(2) .activity-text',
value: 'render test 1', value: 'render test 1',
) )
ticket3 = ticket_create( ticket_create(
data: { data: {
customer: 'nico', customer: 'nico',
group: 'Users', group: 'Users',

View file

@ -21,14 +21,14 @@ class AgentTicketOverviewGroupByOrganizationTest < TestCase
tasks_close_all() tasks_close_all()
# 1. Create a new test organization with special characters in its name # 1. Create a new test organization with special characters in its name
organization = organization_create( organization_create(
data: { data: {
name: 'äöüß & Test Organization', name: 'äöüß & Test Organization',
} }
) )
# 2. Create a new user that belongs to the test organization # 2. Create a new user that belongs to the test organization
user = user_create( user_create(
data: { data: {
login: 'test user', login: 'test user',
firstname: 'Max', firstname: 'Max',
@ -40,7 +40,7 @@ class AgentTicketOverviewGroupByOrganizationTest < TestCase
) )
# 3. Create a new ticket for the test user # 3. Create a new ticket for the test user
ticket = ticket_create( ticket_create(
data: { data: {
customer: user_email, customer: user_email,
title: 'test ticket', title: 'test ticket',
@ -50,7 +50,7 @@ class AgentTicketOverviewGroupByOrganizationTest < TestCase
) )
# 4. Create an overview grouping by organization # 4. Create an overview grouping by organization
overview = overview_create( overview_create(
data: { data: {
name: overview_name, name: overview_name,
roles: %w[Agent Admin Customer], roles: %w[Agent Admin Customer],

View file

@ -21,7 +21,7 @@ class AgentTicketOverviewTabTest < TestCase
body: "overview tab test #1 - #{title}", body: "overview tab test #1 - #{title}",
} }
) )
ticket2 = ticket_create( ticket_create(
data: { data: {
customer: 'nico', customer: 'nico',
group: 'Users', group: 'Users',
@ -29,7 +29,7 @@ class AgentTicketOverviewTabTest < TestCase
body: "overview tab test #2 - #{title}", body: "overview tab test #2 - #{title}",
} }
) )
ticket3 = ticket_create( ticket_create(
data: { data: {
customer: 'nico', customer: 'nico',
group: 'Users', group: 'Users',

View file

@ -11,7 +11,7 @@ class AgentTicketTagTest < TestCase
tasks_close_all() tasks_close_all()
# set tag (by tab) # set tag (by tab)
ticket1 = ticket_create( ticket_create(
data: { data: {
customer: 'nico', customer: 'nico',
group: 'Users', group: 'Users',
@ -51,7 +51,7 @@ class AgentTicketTagTest < TestCase
) )
# set tag (by blur) # set tag (by blur)
ticket2 = ticket_create( ticket_create(
data: { data: {
customer: 'nico', customer: 'nico',
group: 'Users', group: 'Users',
@ -398,7 +398,7 @@ class AgentTicketTagTest < TestCase
click(css: '.content.active .js-create .js-submit') click(css: '.content.active .js-create .js-submit')
# set tag (by tab) # set tag (by tab)
ticket1 = ticket_create( ticket_create(
data: { data: {
customer: 'nico', customer: 'nico',
group: 'Users', group: 'Users',
@ -456,7 +456,7 @@ class AgentTicketTagTest < TestCase
) )
# new ticket with tags in zoom # new ticket with tags in zoom
ticket1 = ticket_create( ticket_create(
data: { data: {
customer: 'nico', customer: 'nico',
group: 'Users', group: 'Users',

View file

@ -12,7 +12,7 @@ class AgentTicketTaskChangedTest < TestCase
) )
tasks_close_all() tasks_close_all()
ticket = ticket_create( ticket_create(
data: { data: {
customer: 'nico', customer: 'nico',
group: 'Users', group: 'Users',

View file

@ -22,7 +22,7 @@ class AgentTicketTimeAccountingTest < TestCase
type: 'on', type: 'on',
) )
ticket1 = ticket_create( ticket_create(
data: { data: {
customer: 'nico', customer: 'nico',
group: 'Users', group: 'Users',
@ -55,7 +55,7 @@ class AgentTicketTimeAccountingTest < TestCase
value: '4', value: '4',
) )
ticket2 = ticket_create( ticket_create(
data: { data: {
customer: 'nico', customer: 'nico',
group: 'Users', group: 'Users',
@ -161,7 +161,7 @@ class AgentTicketTimeAccountingTest < TestCase
type: 'on', type: 'on',
) )
ticket1 = ticket_create( ticket_create(
data: { data: {
customer: 'nico', customer: 'nico',
group: 'Users', group: 'Users',

View file

@ -29,7 +29,7 @@ class AgentTicketUpdate1Test < TestCase
sleep 1 sleep 1
# confirm on zoom # confirm on zoom
ticket1 = ticket_create( ticket_create(
data: { data: {
customer: 'nico', customer: 'nico',
group: 'Users', group: 'Users',

View file

@ -12,7 +12,7 @@ class AgentTicketUpdate5Test < TestCase
# create ticket # create ticket
ticket1 = ticket_create( ticket_create(
data: { data: {
customer: 'Nico', customer: 'Nico',
group: 'Users', group: 'Users',

View file

@ -21,7 +21,7 @@ class AgentTicketZoomHideTest < TestCase
) )
# create two tickets # create two tickets
ticket1 = ticket_create( ticket_create(
data: { data: {
customer: 'Nico', customer: 'Nico',
group: 'Users', group: 'Users',
@ -30,7 +30,7 @@ class AgentTicketZoomHideTest < TestCase
} }
) )
ticket2 = ticket_create( ticket_create(
data: { data: {
customer: 'Nico', customer: 'Nico',
group: 'Users', group: 'Users',

View file

@ -213,7 +213,7 @@ class CustomerTicketCreateTest < TestCase
) )
tasks_close_all() tasks_close_all()
ticket1 = ticket_create( ticket_create(
data: { data: {
customer: 'nico', customer: 'nico',
group: 'Users', group: 'Users',

View file

@ -11,7 +11,7 @@ class UserSwitchCache < TestCase
url: browser_url, url: browser_url,
) )
tasks_close_all() tasks_close_all()
ticket1 = ticket_create( ticket_create(
data: { data: {
customer: 'nico', customer: 'nico',
group: 'Users', group: 'Users',

Some files were not shown because too many files have changed in this diff Show more