Fix rubocop violations
This commit is contained in:
parent
1c386bc0b1
commit
79d4284365
19 changed files with 22 additions and 36 deletions
|
@ -36,7 +36,7 @@ module CreatesTicketArticles
|
||||||
clean_params.delete(:sender)
|
clean_params.delete(:sender)
|
||||||
clean_params.delete(:origin_by_id)
|
clean_params.delete(:origin_by_id)
|
||||||
type = Ticket::Article::Type.lookup(id: clean_params[:type_id])
|
type = Ticket::Article::Type.lookup(id: clean_params[:type_id])
|
||||||
if type.name !~ /^(note|web)$/
|
unless type.name.match?(/^(note|web)$/)
|
||||||
clean_params[:type_id] = Ticket::Article::Type.lookup(name: 'note').id
|
clean_params[:type_id] = Ticket::Article::Type.lookup(name: 'note').id
|
||||||
end
|
end
|
||||||
clean_params.delete(:type)
|
clean_params.delete(:type)
|
||||||
|
@ -89,7 +89,7 @@ module CreatesTicketArticles
|
||||||
preferences[store_key] = attachment[key]
|
preferences[store_key] = attachment[key]
|
||||||
end
|
end
|
||||||
|
|
||||||
if attachment[:data] !~ %r{^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{4}|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)$}
|
unless attachment[:data].match?(%r{^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{4}|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)$})
|
||||||
raise Exceptions::UnprocessableEntity, "Invalid base64 for attachment with index '#{index}'"
|
raise Exceptions::UnprocessableEntity, "Invalid base64 for attachment with index '#{index}'"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ class FormController < ApplicationController
|
||||||
end
|
end
|
||||||
if params[:email].blank?
|
if params[:email].blank?
|
||||||
errors['email'] = 'required'
|
errors['email'] = 'required'
|
||||||
elsif params[:email] !~ /@/
|
elsif !/@/.match?(params[:email])
|
||||||
errors['email'] = 'invalid'
|
errors['email'] = 'invalid'
|
||||||
elsif params[:email].match?(/(>|<|\||\!|"|§|'|\$|%|&|\(|\)|\?|\s|\.\.)/)
|
elsif params[:email].match?(/(>|<|\||\!|"|§|'|\$|%|&|\(|\)|\?|\s|\.\.)/)
|
||||||
errors['email'] = 'invalid'
|
errors['email'] = 'invalid'
|
||||||
|
@ -67,7 +67,7 @@ class FormController < ApplicationController
|
||||||
Rails.logger.info "Can't verify email #{params[:email]}: #{message}"
|
Rails.logger.info "Can't verify email #{params[:email]}: #{message}"
|
||||||
|
|
||||||
# ignore 450, graylistings
|
# ignore 450, graylistings
|
||||||
if message !~ /450/
|
unless message.match?(/450/)
|
||||||
errors['email'] = message
|
errors['email'] = message
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -39,7 +39,7 @@ class ImportZendeskController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
# since 2016-10-15 a redirect to a marketing page has been implemented
|
# since 2016-10-15 a redirect to a marketing page has been implemented
|
||||||
if response.body !~ /#{params[:url]}/
|
unless response.body.match?(/#{params[:url]}/)
|
||||||
render json: {
|
render json: {
|
||||||
result: 'invalid',
|
result: 'invalid',
|
||||||
message_human: 'Hostname not found!',
|
message_human: 'Hostname not found!',
|
||||||
|
|
|
@ -45,7 +45,7 @@ class SettingsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
# validate image
|
# validate image
|
||||||
if clean_params[:logo] !~ /^data:image/i
|
unless clean_params[:logo].match?(/^data:image/i)
|
||||||
render json: {
|
render json: {
|
||||||
result: 'invalid',
|
result: 'invalid',
|
||||||
message: 'Invalid payload, need data:image in logo param',
|
message: 'Invalid payload, need data:image in logo param',
|
||||||
|
|
|
@ -91,7 +91,7 @@ returns
|
||||||
next if !mail
|
next if !mail
|
||||||
|
|
||||||
# check how many content messages we have, for notice used
|
# check how many content messages we have, for notice used
|
||||||
if mail !~ /x-zammad-ignore/i
|
unless mail.match?(/x-zammad-ignore/i)
|
||||||
content_messages += 1
|
content_messages += 1
|
||||||
break if content_max_check < content_messages
|
break if content_max_check < content_messages
|
||||||
end
|
end
|
||||||
|
|
|
@ -144,7 +144,7 @@ module Channel::Filter::IdentifySender
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.user_create(data, role_ids = nil)
|
def self.user_create(data, role_ids = nil)
|
||||||
if data[:email] !~ /@/
|
unless data[:email].match?(/@/)
|
||||||
data[:email] += '@local'
|
data[:email] += '@local'
|
||||||
end
|
end
|
||||||
user = User.find_by(email: data[:email].downcase)
|
user = User.find_by(email: data[:email].downcase)
|
||||||
|
|
|
@ -4,8 +4,6 @@ class History < ApplicationModel
|
||||||
include History::Assets
|
include History::Assets
|
||||||
|
|
||||||
self.table_name = 'histories'
|
self.table_name = 'histories'
|
||||||
|
|
||||||
# rubocop:disable Rails/InverseOf
|
|
||||||
belongs_to :history_type, class_name: 'History::Type'
|
belongs_to :history_type, class_name: 'History::Type'
|
||||||
belongs_to :history_object, class_name: 'History::Object'
|
belongs_to :history_object, class_name: 'History::Object'
|
||||||
belongs_to :history_attribute, class_name: 'History::Attribute'
|
belongs_to :history_attribute, class_name: 'History::Attribute'
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
# Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/
|
# Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class Link < ApplicationModel
|
class Link < ApplicationModel
|
||||||
|
|
||||||
# rubocop:disable Rails/InverseOf
|
|
||||||
belongs_to :link_type, class_name: 'Link::Type'
|
belongs_to :link_type, class_name: 'Link::Type'
|
||||||
belongs_to :link_object, class_name: 'Link::Object'
|
belongs_to :link_object, class_name: 'Link::Object'
|
||||||
# rubocop:enable Rails/InverseOf
|
# rubocop:enable Rails/InverseOf
|
||||||
|
|
|
@ -756,7 +756,7 @@ to send no browser reload event, pass false
|
||||||
if !data_type
|
if !data_type
|
||||||
raise 'Need data_type param'
|
raise 'Need data_type param'
|
||||||
end
|
end
|
||||||
if data_type !~ /^(input|user_autocompletion|checkbox|select|tree_select|datetime|date|tag|richtext|textarea|integer|autocompletion_ajax|boolean|user_permission|active)$/
|
unless data_type.match?(/^(input|user_autocompletion|checkbox|select|tree_select|datetime|date|tag|richtext|textarea|integer|autocompletion_ajax|boolean|user_permission|active)$/)
|
||||||
raise "Invalid data_type param '#{data_type}'"
|
raise "Invalid data_type param '#{data_type}'"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -12,8 +12,6 @@ class Organization < ApplicationModel
|
||||||
include Organization::Assets
|
include Organization::Assets
|
||||||
include Organization::Search
|
include Organization::Search
|
||||||
include Organization::SearchIndex
|
include Organization::SearchIndex
|
||||||
|
|
||||||
# rubocop:disable Rails/InverseOf
|
|
||||||
has_many :members, class_name: 'User'
|
has_many :members, class_name: 'User'
|
||||||
# rubocop:enable Rails/InverseOf
|
# rubocop:enable Rails/InverseOf
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,6 @@ require_dependency 'store/object'
|
||||||
require_dependency 'store/file'
|
require_dependency 'store/file'
|
||||||
|
|
||||||
class Store < ApplicationModel
|
class Store < ApplicationModel
|
||||||
# rubocop:disable Rails/InverseOf
|
|
||||||
belongs_to :store_object, class_name: 'Store::Object'
|
belongs_to :store_object, class_name: 'Store::Object'
|
||||||
belongs_to :store_file, class_name: 'Store::File'
|
belongs_to :store_file, class_name: 'Store::File'
|
||||||
# rubocop:enable Rails/InverseOf
|
# rubocop:enable Rails/InverseOf
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
# Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/
|
# Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
class Tag < ApplicationModel
|
class Tag < ApplicationModel
|
||||||
|
|
||||||
# rubocop:disable Rails/InverseOf
|
|
||||||
belongs_to :tag_object, class_name: 'Tag::Object'
|
belongs_to :tag_object, class_name: 'Tag::Object'
|
||||||
belongs_to :tag_item, class_name: 'Tag::Item'
|
belongs_to :tag_item, class_name: 'Tag::Item'
|
||||||
# rubocop:enable Rails/InverseOf
|
# rubocop:enable Rails/InverseOf
|
||||||
|
|
|
@ -57,8 +57,6 @@ class Ticket < ApplicationModel
|
||||||
belongs_to :organization
|
belongs_to :organization
|
||||||
has_many :articles, class_name: 'Ticket::Article', after_add: :cache_update, after_remove: :cache_update, dependent: :destroy, inverse_of: :ticket
|
has_many :articles, class_name: 'Ticket::Article', after_add: :cache_update, after_remove: :cache_update, dependent: :destroy, inverse_of: :ticket
|
||||||
has_many :ticket_time_accounting, class_name: 'Ticket::TimeAccounting', dependent: :destroy, inverse_of: :ticket
|
has_many :ticket_time_accounting, class_name: 'Ticket::TimeAccounting', dependent: :destroy, inverse_of: :ticket
|
||||||
|
|
||||||
# rubocop:disable Rails/InverseOf
|
|
||||||
belongs_to :state, class_name: 'Ticket::State'
|
belongs_to :state, class_name: 'Ticket::State'
|
||||||
belongs_to :priority, class_name: 'Ticket::Priority'
|
belongs_to :priority, class_name: 'Ticket::Priority'
|
||||||
belongs_to :owner, class_name: 'User'
|
belongs_to :owner, class_name: 'User'
|
||||||
|
|
|
@ -11,8 +11,6 @@ class Ticket::Article < ApplicationModel
|
||||||
|
|
||||||
belongs_to :ticket
|
belongs_to :ticket
|
||||||
has_one :ticket_time_accounting, class_name: 'Ticket::TimeAccounting', foreign_key: :ticket_article_id, dependent: :destroy, inverse_of: :ticket_article
|
has_one :ticket_time_accounting, class_name: 'Ticket::TimeAccounting', foreign_key: :ticket_article_id, dependent: :destroy, inverse_of: :ticket_article
|
||||||
|
|
||||||
# rubocop:disable Rails/InverseOf
|
|
||||||
belongs_to :type, class_name: 'Ticket::Article::Type'
|
belongs_to :type, class_name: 'Ticket::Article::Type'
|
||||||
belongs_to :sender, class_name: 'Ticket::Article::Sender'
|
belongs_to :sender, class_name: 'Ticket::Article::Sender'
|
||||||
belongs_to :created_by, class_name: 'User'
|
belongs_to :created_by, class_name: 'User'
|
||||||
|
|
|
@ -3,7 +3,6 @@ class Ticket::State < ApplicationModel
|
||||||
include ChecksLatestChangeObserved
|
include ChecksLatestChangeObserved
|
||||||
|
|
||||||
belongs_to :state_type, class_name: 'Ticket::StateType', inverse_of: :states
|
belongs_to :state_type, class_name: 'Ticket::StateType', inverse_of: :states
|
||||||
# rubocop:disable Rails/InverseOf
|
|
||||||
belongs_to :next_state, class_name: 'Ticket::State'
|
belongs_to :next_state, class_name: 'Ticket::State'
|
||||||
# rubocop:enable Rails/InverseOf
|
# rubocop:enable Rails/InverseOf
|
||||||
|
|
||||||
|
|
|
@ -134,7 +134,7 @@ satinize html string based on whiltelist
|
||||||
value = node[key]
|
value = node[key]
|
||||||
node.delete(key)
|
node.delete(key)
|
||||||
next if value.blank?
|
next if value.blank?
|
||||||
if value !~ /%|px|em/i
|
unless value.match?(/%|px|em/i)
|
||||||
value += 'px'
|
value += 'px'
|
||||||
end
|
end
|
||||||
node['style'] += "#{key}:#{value}"
|
node['style'] += "#{key}:#{value}"
|
||||||
|
|
|
@ -18,6 +18,6 @@ returns
|
||||||
File.read(Rails.root.join('VERSION')).strip
|
File.read(Rails.root.join('VERSION')).strip
|
||||||
rescue => e
|
rescue => e
|
||||||
Rails.logger.error "VERSION file could not be read: #{e}"
|
Rails.logger.error "VERSION file could not be read: #{e}"
|
||||||
return ''
|
''
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -37,7 +37,7 @@ class AgentTicketTagTest < TestCase
|
||||||
css: '.active .newTicket button.js-submit',
|
css: '.active .newTicket button.js-submit',
|
||||||
)
|
)
|
||||||
sleep 5
|
sleep 5
|
||||||
if @browser.current_url !~ /#{Regexp.quote('#ticket/zoom/')}/
|
unless @browser.current_url.match?(/#{Regexp.quote('#ticket/zoom/')}/)
|
||||||
raise 'Unable to create ticket!'
|
raise 'Unable to create ticket!'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ class AgentTicketTagTest < TestCase
|
||||||
click(css: '#global-search')
|
click(css: '#global-search')
|
||||||
click(css: '.active .newTicket button.js-submit')
|
click(css: '.active .newTicket button.js-submit')
|
||||||
sleep 5
|
sleep 5
|
||||||
if @browser.current_url !~ /#{Regexp.quote('#ticket/zoom/')}/
|
unless @browser.current_url.match?(/#{Regexp.quote('#ticket/zoom/')}/)
|
||||||
raise 'Unable to create ticket!'
|
raise 'Unable to create ticket!'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -428,7 +428,7 @@ class AgentTicketTagTest < TestCase
|
||||||
css: '.active .newTicket button.js-submit',
|
css: '.active .newTicket button.js-submit',
|
||||||
)
|
)
|
||||||
sleep 5
|
sleep 5
|
||||||
if @browser.current_url !~ /#{Regexp.quote('#ticket/zoom/')}/
|
unless @browser.current_url.match?(/#{Regexp.quote('#ticket/zoom/')}/)
|
||||||
raise 'Unable to create ticket!'
|
raise 'Unable to create ticket!'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -104,7 +104,7 @@ class TestCase < Test::Unit::TestCase
|
||||||
browser_width = ENV['BROWSER_WIDTH'] || 1024
|
browser_width = ENV['BROWSER_WIDTH'] || 1024
|
||||||
browser_height = ENV['BROWSER_HEIGHT'] || 800
|
browser_height = ENV['BROWSER_HEIGHT'] || 800
|
||||||
local_browser.manage.window.resize_to(browser_width, browser_height)
|
local_browser.manage.window.resize_to(browser_width, browser_height)
|
||||||
if ENV['REMOTE_URL'] !~ /saucelabs|(grid|ci)\.(zammad\.org|znuny\.com)/i
|
unless ENV['REMOTE_URL'].match?(/saucelabs|(grid|ci)\.(zammad\.org|znuny\.com)/i)
|
||||||
if @browsers.count == 1
|
if @browsers.count == 1
|
||||||
local_browser.manage.window.move_to(0, 0)
|
local_browser.manage.window.move_to(0, 0)
|
||||||
else
|
else
|
||||||
|
@ -362,7 +362,7 @@ class TestCase < Test::Unit::TestCase
|
||||||
instance = params[:browser] || @browser
|
instance = params[:browser] || @browser
|
||||||
sleep 0.7
|
sleep 0.7
|
||||||
current_url = instance.current_url
|
current_url = instance.current_url
|
||||||
if current_url !~ /#{Regexp.quote(params[:url])}/
|
unless current_url.match?(/#{Regexp.quote(params[:url])}/)
|
||||||
screenshot(browser: instance, comment: 'location_check_failed')
|
screenshot(browser: instance, comment: 'location_check_failed')
|
||||||
raise "url #{current_url} is not matching #{params[:url]}"
|
raise "url #{current_url} is not matching #{params[:url]}"
|
||||||
end
|
end
|
||||||
|
@ -1352,7 +1352,7 @@ wait untill text in selector disabppears
|
||||||
if params[:value]
|
if params[:value]
|
||||||
begin
|
begin
|
||||||
text = instance.find_elements(css: params[:css])[0].text
|
text = instance.find_elements(css: params[:css])[0].text
|
||||||
if text !~ /#{params[:value]}/i
|
unless text.match?(/#{params[:value]}/i)
|
||||||
assert(true, "not matching '#{params[:value]}' in text '#{text}'")
|
assert(true, "not matching '#{params[:value]}' in text '#{text}'")
|
||||||
sleep 1
|
sleep 1
|
||||||
return true
|
return true
|
||||||
|
@ -2427,7 +2427,7 @@ wait untill text in selector disabppears
|
||||||
element.click
|
element.click
|
||||||
sleep 1
|
sleep 1
|
||||||
number = instance.find_elements(css: '.content.active .ticketZoom-header .ticket-number')[0].text
|
number = instance.find_elements(css: '.content.active .ticketZoom-header .ticket-number')[0].text
|
||||||
if number !~ /#{params[:number]}/
|
unless number.match?(/#{params[:number]}/)
|
||||||
screenshot(browser: instance, comment: 'ticket_open_by_overview_open_failed_failed')
|
screenshot(browser: instance, comment: 'ticket_open_by_overview_open_failed_failed')
|
||||||
raise "unable to open ticket #{params[:number]}!"
|
raise "unable to open ticket #{params[:number]}!"
|
||||||
end
|
end
|
||||||
|
@ -2473,7 +2473,7 @@ wait untill text in selector disabppears
|
||||||
instance.execute_script("$(\".js-global-search-result a:contains('#{params[:number]}') .nav-tab-icon\").first().click()")
|
instance.execute_script("$(\".js-global-search-result a:contains('#{params[:number]}') .nav-tab-icon\").first().click()")
|
||||||
sleep 1
|
sleep 1
|
||||||
number = instance.find_elements(css: '.content.active .ticketZoom-header .ticket-number')[0].text
|
number = instance.find_elements(css: '.content.active .ticketZoom-header .ticket-number')[0].text
|
||||||
if number !~ /#{params[:number]}/
|
unless number.match?(/#{params[:number]}/)
|
||||||
screenshot(browser: instance, comment: 'ticket_open_by_search_failed')
|
screenshot(browser: instance, comment: 'ticket_open_by_search_failed')
|
||||||
raise "unable to search/find ticket #{params[:number]}!"
|
raise "unable to search/find ticket #{params[:number]}!"
|
||||||
end
|
end
|
||||||
|
@ -2509,7 +2509,7 @@ wait untill text in selector disabppears
|
||||||
instance.execute_script("$(\".js-global-search-result a:contains('#{params[:title]}') .nav-tab-icon\").click()")
|
instance.execute_script("$(\".js-global-search-result a:contains('#{params[:title]}') .nav-tab-icon\").click()")
|
||||||
sleep 1
|
sleep 1
|
||||||
title = instance.find_elements(css: '.content.active .ticketZoom-header .js-objectTitle')[0].text
|
title = instance.find_elements(css: '.content.active .ticketZoom-header .js-objectTitle')[0].text
|
||||||
if title !~ /#{params[:title]}/
|
unless title.match?(/#{params[:title]}/)
|
||||||
screenshot(browser: instance, comment: 'ticket_open_by_title_failed')
|
screenshot(browser: instance, comment: 'ticket_open_by_title_failed')
|
||||||
raise "unable to search/find ticket #{params[:title]}!"
|
raise "unable to search/find ticket #{params[:title]}!"
|
||||||
end
|
end
|
||||||
|
@ -2597,7 +2597,7 @@ wait untill text in selector disabppears
|
||||||
instance.execute_script("$(\".js-global-search-result a:contains('#{params[:value]}') .nav-tab-icon\").click()")
|
instance.execute_script("$(\".js-global-search-result a:contains('#{params[:value]}') .nav-tab-icon\").click()")
|
||||||
sleep 1
|
sleep 1
|
||||||
name = instance.find_elements(css: '.content.active h1')[0].text
|
name = instance.find_elements(css: '.content.active h1')[0].text
|
||||||
if name !~ /#{params[:value]}/
|
unless name.match?(/#{params[:value]}/)
|
||||||
screenshot(browser: instance, comment: 'organization_open_by_search_failed')
|
screenshot(browser: instance, comment: 'organization_open_by_search_failed')
|
||||||
raise "unable to search/find org #{params[:value]}!"
|
raise "unable to search/find org #{params[:value]}!"
|
||||||
end
|
end
|
||||||
|
@ -2632,7 +2632,7 @@ wait untill text in selector disabppears
|
||||||
instance.execute_script("$(\".js-global-search-result a:contains('#{params[:value]}') .nav-tab-icon\").click()")
|
instance.execute_script("$(\".js-global-search-result a:contains('#{params[:value]}') .nav-tab-icon\").click()")
|
||||||
sleep 1
|
sleep 1
|
||||||
name = instance.find_elements(css: '.content.active h1')[0].text
|
name = instance.find_elements(css: '.content.active h1')[0].text
|
||||||
if name !~ /#{params[:value]}/
|
unless name.match?(/#{params[:value]}/)
|
||||||
screenshot(browser: instance, comment: 'user_open_by_search_failed')
|
screenshot(browser: instance, comment: 'user_open_by_search_failed')
|
||||||
raise "unable to search/find user #{params[:value]}!"
|
raise "unable to search/find user #{params[:value]}!"
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue