diff --git a/.rubocop.yml b/.rubocop.yml index 3f5b06089..36f578fe6 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -173,11 +173,6 @@ Style/Documentation: Description: 'Document classes and non-namespace modules.' Enabled: false -Style/SignalException: - Description: 'Checks for proper usage of fail and raise.' - StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#fail-method' - Enabled: false - Metrics/AbcSize: Description: >- A calculated magnitude based on number of assignments, diff --git a/app/controllers/getting_started_controller.rb b/app/controllers/getting_started_controller.rb index 7f77410cb..c0f8486dc 100644 --- a/app/controllers/getting_started_controller.rb +++ b/app/controllers/getting_started_controller.rb @@ -831,7 +831,7 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password} # validate params if !params[:adapter] - raise 'need :adapter param' + fail 'need :adapter param' end # connection test diff --git a/app/controllers/tickets_controller.rb b/app/controllers/tickets_controller.rb index 2d100c581..5d99d19a0 100644 --- a/app/controllers/tickets_controller.rb +++ b/app/controllers/tickets_controller.rb @@ -350,7 +350,7 @@ class TicketsController < ApplicationController def stats if !params[:user_id] && !params[:organization_id] - raise 'Need user_id or organization_id as param' + fail 'Need user_id or organization_id as param' end # permissin check diff --git a/app/models/activity_stream.rb b/app/models/activity_stream.rb index 582a79e77..4ac607f50 100644 --- a/app/models/activity_stream.rb +++ b/app/models/activity_stream.rb @@ -34,7 +34,7 @@ add a new activity entry for an object if data[:role] role = Role.lookup( name: data[:role] ) if !role - raise "No such Role #{data[:role]}" + fail "No such Role #{data[:role]}" end role_id = role.id end diff --git a/app/models/application_model.rb b/app/models/application_model.rb index bd23ebfb0..e76cfdacf 100644 --- a/app/models/application_model.rb +++ b/app/models/application_model.rb @@ -70,7 +70,7 @@ returns def self.param_cleanup(params, newObject = false) if params.nil? - raise "No params for #{self}!" + fail "No params for #{self}!" end # ignore id for new objects @@ -340,7 +340,7 @@ returns } return else - raise 'Need name, id or login for lookup()' + fail 'Need name, id or login for lookup()' end end @@ -435,7 +435,7 @@ returns record.save return record else - raise 'Need name, login or locale for create_or_update()' + fail 'Need name, login or locale for create_or_update()' end end diff --git a/app/models/locale.rb b/app/models/locale.rb index 0b329d19a..5635f7ae6 100644 --- a/app/models/locale.rb +++ b/app/models/locale.rb @@ -13,7 +13,7 @@ class Locale < ApplicationModel } ) - raise "Can't load locales from #{url}: #{result.error}" if !result.success? + fail "Can't load locales from #{url}: #{result.error}" if !result.success? ActiveRecord::Base.transaction do result.data.each {|locale| diff --git a/app/models/observer/ticket/article/fillup_from_email.rb b/app/models/observer/ticket/article/fillup_from_email.rb index 59f6adc22..55bbbdc98 100644 --- a/app/models/observer/ticket/article/fillup_from_email.rb +++ b/app/models/observer/ticket/article/fillup_from_email.rb @@ -33,7 +33,7 @@ class Observer::Ticket::Article::FillupFromEmail < ActiveRecord::Observer # set sender email_address = ticket.group.email_address if !email_address - raise "No email address found for group '#{ticket.group.name}'" + fail "No email address found for group '#{ticket.group.name}'" end system_sender = "#{email_address.realname} <#{email_address.email}>" if Setting.get('ticket_define_email_from') == 'AgentNameSystemAddressName' diff --git a/app/models/observer/ticket/notification.rb b/app/models/observer/ticket/notification.rb index c0ff9b67f..0b7445e3a 100644 --- a/app/models/observer/ticket/notification.rb +++ b/app/models/observer/ticket/notification.rb @@ -100,7 +100,7 @@ class Observer::Ticket::Notification < ActiveRecord::Observer end end else - raise "unknown object for notification #{event[:name]}" + fail "unknown object for notification #{event[:name]}" end } list_objects diff --git a/app/models/observer/ticket/notification/background_job.rb b/app/models/observer/ticket/notification/background_job.rb index f92241ee5..c390ee559 100644 --- a/app/models/observer/ticket/notification/background_job.rb +++ b/app/models/observer/ticket/notification/background_job.rb @@ -97,7 +97,7 @@ class Observer::Ticket::Notification::BackgroundJob elsif @p[:type] == 'update' template = self.template_update(user, ticket, article, changes) else - raise "unknown type for notification #{@p[:type]}" + fail "unknown type for notification #{@p[:type]}" end # prepare subject & body diff --git a/app/models/package.rb b/app/models/package.rb index 823dd0230..4095d28c8 100644 --- a/app/models/package.rb +++ b/app/models/package.rb @@ -85,7 +85,7 @@ class Package < ApplicationModel package = entry.sub( %r{^.*/(.+?)\.szpm$}, '\1') end if package == false - raise "Can't link package, '#{package_base_dir}' is no package source directory!" + fail "Can't link package, '#{package_base_dir}' is no package source directory!" end logger.debug package.inspect package @@ -154,7 +154,7 @@ class Package < ApplicationModel if File.file?( entry.to_s ) && ( File.file?( dest.to_s ) && !File.symlink?( dest.to_s ) ) backup_file = dest.to_s + '.link_backup' if File.exist?( backup_file ) - raise "Can't link #{entry} -> #{dest}, destination and .link_backup already exists!" + fail "Can't link #{entry} -> #{dest}, destination and .link_backup already exists!" else logger.info "Create backup file of #{dest} -> #{backup_file}." File.rename( dest.to_s, backup_file ) @@ -199,10 +199,10 @@ class Package < ApplicationModel if package_db if !data[:reinstall] if Gem::Version.new( package_db.version ) == Gem::Version.new( meta[:version] ) - raise "Package '#{meta[:name]}-#{meta[:version]}' already installed!" + fail "Package '#{meta[:name]}-#{meta[:version]}' already installed!" end if Gem::Version.new( package_db.version ) > Gem::Version.new( meta[:version] ) - raise "Newer version (#{package_db.version}) of package '#{meta[:name]}-#{meta[:version]}' already installed!" + fail "Newer version (#{package_db.version}) of package '#{meta[:name]}-#{meta[:version]}' already installed!" end end @@ -255,7 +255,7 @@ class Package < ApplicationModel def self.reinstall(package_name) package = Package.find_by( name: package_name ) if !package - raise "No such package '#{package_name}'" + fail "No such package '#{package_name}'" end file = self._get_bin( package.name, package.version ) @@ -345,7 +345,7 @@ class Package < ApplicationModel version: version, ) if !package - raise "No such package '#{name}' version '#{version}'" + fail "No such package '#{name}' version '#{version}'" end list = Store.list( object: 'Package', @@ -354,10 +354,10 @@ class Package < ApplicationModel # find file if !list || !list.first - raise "No such file in storage list #{name} #{version}" + fail "No such file in storage list #{name} #{version}" end if !list.first.content - raise "No such file in storage #{name} #{version}" + fail "No such file in storage #{name} #{version}" end list.first.content end @@ -470,7 +470,7 @@ class Package < ApplicationModel name = $2 end if !version || !name - raise "Invalid package migration '#{migration}'" + fail "Invalid package migration '#{migration}'" end # down diff --git a/app/models/setting.rb b/app/models/setting.rb index d6132d9c9..72089fb32 100644 --- a/app/models/setting.rb +++ b/app/models/setting.rb @@ -39,7 +39,7 @@ class Setting < ApplicationModel def self.set(name, value) setting = Setting.find_by( name: name ) if !setting - raise "Can't find config setting '#{name}'" + fail "Can't find config setting '#{name}'" end setting.state = { value: value } setting.save diff --git a/app/models/store.rb b/app/models/store.rb index e74d03569..7dd028434 100644 --- a/app/models/store.rb +++ b/app/models/store.rb @@ -142,7 +142,7 @@ returns def content file = Store::File.find_by( id: self.store_file_id ) if !file - raise "No such file #{ self.store_file_id }!" + fail "No such file #{ self.store_file_id }!" end file.content end @@ -150,7 +150,7 @@ returns def provider file = Store::File.find_by( id: self.store_file_id ) if !file - raise "No such file #{ self.store_file_id }!" + fail "No such file #{ self.store_file_id }!" end file.provider end diff --git a/app/models/store/file.rb b/app/models/store/file.rb index 202844a35..ceb4648b3 100644 --- a/app/models/store/file.rb +++ b/app/models/store/file.rb @@ -15,7 +15,7 @@ class Store # load backend based on config adapter_name = Setting.get('storage_provider') || 'DB' if !adapter_name - raise 'Missing storage_provider setting option' + fail 'Missing storage_provider setting option' end adapter = self.load_adapter( "Store::Provider::#{ adapter_name }" ) adapter.add( data, sha ) diff --git a/app/models/store/provider/file.rb b/app/models/store/provider/file.rb index 0aecfde31..2629a762e 100644 --- a/app/models/store/provider/file.rb +++ b/app/models/store/provider/file.rb @@ -19,7 +19,7 @@ class Store::Provider::File # check sha local_sha = Digest::SHA256.hexdigest( get(sha) ) if sha != local_sha - raise "ERROR: Corrupt file in fs #{ get_locaton(sha) }, sha should be #{sha} but is #{local_sha}" + fail "ERROR: Corrupt file in fs #{ get_locaton(sha) }, sha should be #{sha} but is #{local_sha}" end true @@ -29,7 +29,7 @@ class Store::Provider::File def self.get(sha) Rails.logger.debug "read from fs #{ get_locaton(sha) }" if !File.exist?( get_locaton(sha) ) - raise "ERROR: No such file #{ get_locaton(sha) }" + fail "ERROR: No such file #{ get_locaton(sha) }" end data = File.open( get_locaton(sha), 'rb' ) content = data.read @@ -37,7 +37,7 @@ class Store::Provider::File # check sha local_sha = Digest::SHA256.hexdigest( content ) if local_sha != sha - raise "ERROR: Corrupt file in fs #{ get_locaton(sha) }, sha should be #{sha} but is #{local_sha}" + fail "ERROR: Corrupt file in fs #{ get_locaton(sha) }, sha should be #{sha} but is #{local_sha}" end content end diff --git a/app/models/ticket/escalation.rb b/app/models/ticket/escalation.rb index 060a00f36..c746eb51b 100644 --- a/app/models/ticket/escalation.rb +++ b/app/models/ticket/escalation.rb @@ -300,7 +300,7 @@ returns relative = total_time - total_time_without_pending return relative else - raise "ERROR: Unknown type #{type}" + fail "ERROR: Unknown type #{type}" end end diff --git a/app/models/ticket/number.rb b/app/models/ticket/number.rb index 2936721c7..d5fde9ac6 100644 --- a/app/models/ticket/number.rb +++ b/app/models/ticket/number.rb @@ -23,7 +23,7 @@ returns ticket = Ticket.find_by( number: number ) return number if !ticket } - raise "Can't generate new ticket number!" + fail "Can't generate new ticket number!" end =begin @@ -47,11 +47,11 @@ returns # load backend based on config adapter_name = Setting.get('ticket_number') if !adapter_name - raise 'Missing ticket_number setting option' + fail 'Missing ticket_number setting option' end adapter = load_adapter(adapter_name) if !adapter - raise "Can't load ticket_number adapter '#{adapter_name}'" + fail "Can't load ticket_number adapter '#{adapter_name}'" end adapter end diff --git a/app/models/ticket/overviews.rb b/app/models/ticket/overviews.rb index 444055349..f7635b898 100644 --- a/app/models/ticket/overviews.rb +++ b/app/models/ticket/overviews.rb @@ -88,7 +88,7 @@ returns } if data[:view] && !overview_selected - raise "No such view '#{ data[:view] }'" + fail "No such view '#{ data[:view] }'" end # sortby diff --git a/app/models/ticket/state.rb b/app/models/ticket/state.rb index a38866f51..adcd506c6 100644 --- a/app/models/ticket/state.rb +++ b/app/models/ticket/state.rb @@ -28,7 +28,7 @@ returns: state_type_id: Ticket::StateType.where( name: ['closed'] ) ) end - raise "Unknown category '#{category}'" + fail "Unknown category '#{category}'" end =begin diff --git a/app/models/translation.rb b/app/models/translation.rb index c809a6c42..b49e04680 100644 --- a/app/models/translation.rb +++ b/app/models/translation.rb @@ -26,7 +26,7 @@ load translations from online json: true, } ) - raise "Can't load translations from #{url}: #{result.error}" if !result.success? + fail "Can't load translations from #{url}: #{result.error}" if !result.success? ActiveRecord::Base.transaction do result.data.each {|translation| @@ -87,7 +87,7 @@ push translations to online json: true, } ) - raise "Can't push translations to #{url}: #{result.error}" if !result.success? + fail "Can't push translations to #{url}: #{result.error}" if !result.success? true end diff --git a/lib/application_lib.rb b/lib/application_lib.rb index 4ea188f2c..da8537a6e 100644 --- a/lib/application_lib.rb +++ b/lib/application_lib.rb @@ -53,7 +53,7 @@ returns adapter = adapter.constantize if !adapter - raise "Can't load adapter '#{adapter_name}'" + fail "Can't load adapter '#{adapter_name}'" end adapter diff --git a/lib/geo_ip/zammad_geo_ip.rb b/lib/geo_ip/zammad_geo_ip.rb index b3a317e8d..a49daa5e8 100644 --- a/lib/geo_ip/zammad_geo_ip.rb +++ b/lib/geo_ip/zammad_geo_ip.rb @@ -25,7 +25,7 @@ class GeoIp::ZammadGeoIp }, ) if !response.success? && response.code.to_s !~ /^40.$/ - raise "ERROR: #{response.code}/#{response.body}" + fail "ERROR: #{response.code}/#{response.body}" end data = response.data diff --git a/lib/import/otrs.rb b/lib/import/otrs.rb index d8aec9cd8..81f91ea08 100644 --- a/lib/import/otrs.rb +++ b/lib/import/otrs.rb @@ -117,7 +117,7 @@ module Import::OTRS # check if system is in import mode if !Setting.get('import_mode') - raise 'System is not in import mode!' + fail 'System is not in import mode!' end response = request('public.pl?Action=Export') @@ -180,7 +180,7 @@ module Import::OTRS # check if system is in import mode if !Setting.get('import_mode') - raise 'System is not in import mode!' + fail 'System is not in import mode!' end # create states diff --git a/lib/import/otrs2.rb b/lib/import/otrs2.rb index f731951a8..0f5fbb729 100644 --- a/lib/import/otrs2.rb +++ b/lib/import/otrs2.rb @@ -21,14 +21,14 @@ module Import::OTRS2 def self.request_json(data, data_only = false) response = post(data) if !response - raise "Can't connect to Zammad Migrator" + fail "Can't connect to Zammad Migrator" end if !response.success? - raise "Can't connect to Zammad Migrator" + fail "Can't connect to Zammad Migrator" end result = json(response) if !result - raise 'Invalid response' + fail 'Invalid response' end if data_only result['Result'] @@ -297,7 +297,7 @@ module Import::OTRS2 # check if system is in import mode if !Setting.get('import_mode') - raise 'System is not in import mode!' + fail 'System is not in import mode!' end result = request_json({}) @@ -423,7 +423,7 @@ module Import::OTRS2 # check if system is in import mode if !Setting.get('import_mode') - raise 'System is not in import mode!' + fail 'System is not in import mode!' end # create states diff --git a/lib/rss.rb b/lib/rss.rb index e5d3b3009..819ac02e5 100644 --- a/lib/rss.rb +++ b/lib/rss.rb @@ -9,7 +9,7 @@ module Rss Rails.logger.info "fetch rss... #{url}" response = UserAgent.request(url) if !response.success? - raise "Can't fetch '#{url}', http code: #{response.code}" + fail "Can't fetch '#{url}', http code: #{response.code}" return end rss = SimpleRSS.parse response.body diff --git a/lib/search_index_backend.rb b/lib/search_index_backend.rb index e2aba5d93..30d2efa4b 100644 --- a/lib/search_index_backend.rb +++ b/lib/search_index_backend.rb @@ -59,7 +59,7 @@ create/update/delete index ) Rails.logger.info "# #{response.code}" return true if response.success? - raise response.inspect + fail response.inspect end =begin @@ -91,7 +91,7 @@ add new object to search index ) Rails.logger.info "# #{response.code}" return true if response.success? - raise response.inspect + fail response.inspect end =begin diff --git a/lib/static_assets.rb b/lib/static_assets.rb index 892cf7ea8..a8638ada6 100644 --- a/lib/static_assets.rb +++ b/lib/static_assets.rb @@ -7,7 +7,7 @@ module StaticAssets data[:content] = Base64.decode64($2) return data end - raise "Unable to parse data url: #{data_url.substr(0, 100)}" + fail "Unable to parse data url: #{data_url.substr(0, 100)}" end # store image 1:1 @@ -31,7 +31,7 @@ module StaticAssets if list && list[0] return Store.find( list[0] ) end - raise 'No such raw logo!' + fail 'No such raw logo!' end # store image in right size diff --git a/lib/tasks/test_browser.rake b/lib/tasks/test_browser.rake index 50d56df85..21e7aa956 100644 --- a/lib/tasks/test_browser.rake +++ b/lib/tasks/test_browser.rake @@ -11,7 +11,7 @@ namespace :test do end Dir.glob('test/browser/*_test.rb').sort.each { |r| sh "#{args.opts} ruby -Itest #{r}" do |ok, res| - raise 'Failed test. ' + res.inspect if !ok + fail 'Failed test. ' + res.inspect if !ok end } puts 'All browser tests, elapsed: ' + (Time.now() - start).to_s + ' seconds' diff --git a/lib/time_calculation.rb b/lib/time_calculation.rb index d306258db..67e0f3004 100644 --- a/lib/time_calculation.rb +++ b/lib/time_calculation.rb @@ -53,7 +53,7 @@ put working hours matrix and timezone in function, returns UTC working hours mat } if !config_ok - raise 'sla config is invalid! ' + config.inspect + fail 'sla config is invalid! ' + config.inspect end # shift working hours / if needed diff --git a/lib/user_agent.rb b/lib/user_agent.rb index 814fce72f..7c19b126d 100644 --- a/lib/user_agent.rb +++ b/lib/user_agent.rb @@ -307,7 +307,7 @@ returns code: response.code, ) when Net::HTTPRedirection - raise 'Too many redirections for the original URL, halting.' if count <= 0 + fail 'Too many redirections for the original URL, halting.' if count <= 0 url = response['location'] return get(url, params, options, count - 1) when Net::HTTPOK @@ -336,7 +336,7 @@ returns ) end - raise "Unable to process http call '#{response.inspect}'" + fail "Unable to process http call '#{response.inspect}'" end def self.ftp(uri, options) diff --git a/test/browser_test_helper.rb b/test/browser_test_helper.rb index ecd9bd578..e8b6a684b 100644 --- a/test/browser_test_helper.rb +++ b/test/browser_test_helper.rb @@ -105,7 +105,7 @@ class TestCase < Test::Unit::TestCase element = instance.find_elements( { css: '#login input[name="username"]' } )[0] if !element screenshot( browser: instance, comment: 'login_failed' ) - raise 'No login box found' + fail 'No login box found' end screenshot( browser: instance, comment: 'login' ) @@ -126,7 +126,7 @@ class TestCase < Test::Unit::TestCase login = instance.find_elements( { css: '.user-menu .user a' } )[0].attribute('title') if login != params[:username] screenshot( browser: instance, comment: 'login_failed' ) - raise 'login failed' + fail 'login failed' end screenshot( browser: instance, comment: 'login_ok' ) assert( true, 'login ok' ) @@ -159,7 +159,7 @@ class TestCase < Test::Unit::TestCase end } screenshot( browser: instance, comment: 'logout_failed' ) - raise 'no login box found, seems logout was not successfully!' + fail 'no login box found, seems logout was not successfully!' end =begin @@ -194,7 +194,7 @@ class TestCase < Test::Unit::TestCase instance = params[:browser] || @browser if instance.current_url !~ /#{Regexp.quote(params[:url])}/ screenshot( browser: instance, comment: 'location_check_failed' ) - raise "url #{instance.current_url} is not matching #{params[:url]}" + fail "url #{instance.current_url} is not matching #{params[:url]}" end assert( true, "url #{instance.current_url} is matching #{params[:url]}" ) end @@ -259,7 +259,7 @@ class TestCase < Test::Unit::TestCase instance = params[:browser] || @browser if !instance.find_elements( { css: params[:css] } )[0] screenshot( browser: instance, comment: 'exists_failed' ) - raise "#{params[:css]} dosn't exist, but should" + fail "#{params[:css]} dosn't exist, but should" end true end @@ -279,7 +279,7 @@ class TestCase < Test::Unit::TestCase instance = params[:browser] || @browser if instance.find_elements( { css: params[:css] } )[0] screenshot( browser: instance, comment: 'exists_not_failed' ) - raise "#{params[:css]} exists but should not" + fail "#{params[:css]} exists but should not" end true end @@ -454,12 +454,12 @@ class TestCase < Test::Unit::TestCase end if params[:should_not_match] if success - raise "should not match '#{params[:value]}' in select list, but is matching" + fail "should not match '#{params[:value]}' in select list, but is matching" end return true else if !success - raise "not matching '#{params[:value]}' in select list" + fail "not matching '#{params[:value]}' in select list" end return true end @@ -503,11 +503,11 @@ class TestCase < Test::Unit::TestCase end if match if params[:should_not_match] - raise "matching '#{params[:value]}' in content '#{text}' but should not!" + fail "matching '#{params[:value]}' in content '#{text}' but should not!" end else if !params[:should_not_match] - raise "not matching '#{params[:value]}' in content '#{text}' but should!" + fail "not matching '#{params[:value]}' in content '#{text}' but should!" end end sleep 0.8 @@ -569,16 +569,16 @@ class TestCase < Test::Unit::TestCase if params.key?( :value ) && cookie[:value].to_s =~ /#{params[:value]}/i assert( true, "matching value '#{params[:value]}' in cookie '#{cookie}'" ) else - raise "not matching value '#{params[:value]}' in cookie '#{cookie}'" + fail "not matching value '#{params[:value]}' in cookie '#{cookie}'" end if params.key?( :expires ) && cookie[:expires].to_s =~ /#{params[:expires]}/i assert( true, "matching expires '#{params[:expires].inspect}' in cookie '#{cookie}'" ) else - raise "not matching expires '#{params[:expires]}' in cookie '#{cookie}'" + fail "not matching expires '#{params[:expires]}' in cookie '#{cookie}'" end if params[:should_not_exist] - raise "cookie with name '#{params[:name]}' should not exist, but exists '#{cookies}'" + fail "cookie with name '#{params[:name]}' should not exist, but exists '#{cookies}'" end return end @@ -587,7 +587,7 @@ class TestCase < Test::Unit::TestCase assert( true, "cookie with name '#{params[:name]}' is not existing" ) return end - raise "not matching name '#{params[:name]}' in cookie '#{cookies}'" + fail "not matching name '#{params[:name]}' in cookie '#{cookies}'" end =begin @@ -608,7 +608,7 @@ class TestCase < Test::Unit::TestCase if title =~ /#{params[:value]}/i assert( true, "matching '#{params[:value]}' in title '#{title}'" ) else - raise "not matching '#{params[:value]}' in title '#{title}'" + fail "not matching '#{params[:value]}' in title '#{title}'" end end @@ -640,7 +640,7 @@ class TestCase < Test::Unit::TestCase if title =~ /#{data[:title]}/i assert( true, "matching '#{data[:title]}' in title '#{title}'" ) else - raise "not matching '#{data[:title]}' in title '#{title}'" + fail "not matching '#{data[:title]}' in title '#{title}'" end end puts "tv #{params.inspect}" @@ -659,17 +659,17 @@ class TestCase < Test::Unit::TestCase if is_modified assert( true, "task '#{data[:title]}' is modifed" ) elsif !exists - raise "task '#{data[:title]}' not exists, should not modified" + fail "task '#{data[:title]}' not exists, should not modified" else - raise "task '#{data[:title]}' is not modifed" + fail "task '#{data[:title]}' is not modifed" end else if !is_modified assert( true, "task '#{data[:title]}' is modifed" ) elsif !exists - raise "task '#{data[:title]}' not exists, should be not modified" + fail "task '#{data[:title]}' not exists, should be not modified" else - raise "task '#{data[:title]}' is modifed, but should not" + fail "task '#{data[:title]}' is modifed, but should not" end end end @@ -705,7 +705,7 @@ class TestCase < Test::Unit::TestCase element = instance.find_elements( { partial_link_text: data[:title] } )[0] if !element screenshot( browser: instance, comment: 'open_task_failed' ) - raise "no task with title '#{data[:title]}' found" + fail "no task with title '#{data[:title]}' found" end element.click true @@ -785,7 +785,7 @@ class TestCase < Test::Unit::TestCase sleep 0.5 } screenshot( browser: instance, comment: 'watch_for_failed' ) - raise "'#{params[:value]}' found in '#{text}'" + fail "'#{params[:value]}' found in '#{text}'" end =begin @@ -842,7 +842,7 @@ wait untill text in selector disabppears sleep 1 } screenshot( browser: instance, comment: 'disappear_failed' ) - raise "#{params[:css]}) still exsists" + fail "#{params[:css]}) still exsists" end =begin @@ -955,7 +955,7 @@ wait untill text in selector disabppears sleep 1 } screenshot( browser: instance, comment: 'overview_create_failed' ) - raise 'overview creation failed' + fail 'overview creation failed' end =begin @@ -990,7 +990,7 @@ wait untill text in selector disabppears element = instance.find_elements( { css: '.active .newTicket' } )[0] if !element screenshot( browser: instance, comment: 'ticket_create_failed' ) - raise 'no ticket create screen found!' + fail 'no ticket create screen found!' end sleep 1 @@ -1086,7 +1086,7 @@ wait untill text in selector disabppears sleep 1 } screenshot( browser: instance, comment: 'ticket_create_failed' ) - raise "ticket creation failed, can't get zoom url (current url is '#{ instance.current_url }')" + fail "ticket creation failed, can't get zoom url (current url is '#{ instance.current_url }')" end =begin @@ -1235,7 +1235,7 @@ wait untill text in selector disabppears } if !found screenshot( browser: instance, comment: 'ticket_update_discard_message_failed' ) - raise 'no discard message found' + fail 'no discard message found' end end @@ -1259,7 +1259,7 @@ wait untill text in selector disabppears sleep 1 } screenshot( browser: instance, comment: 'ticket_update_failed' ) - raise 'unable to update ticket' + fail 'unable to update ticket' end =begin @@ -1287,7 +1287,7 @@ wait untill text in selector disabppears if title =~ /#{data[:title]}/i assert( true, "matching '#{data[:title]}' in title '#{title}'" ) else - raise "not matching '#{data[:title]}' in title '#{title}'" + fail "not matching '#{data[:title]}' in title '#{title}'" end end @@ -1296,7 +1296,7 @@ wait untill text in selector disabppears if body =~ /#{data[:body]}/i assert( true, "matching '#{data[:body]}' in body '#{body}'" ) else - raise "not matching '#{data[:body]}' in body '#{body}'" + fail "not matching '#{data[:body]}' in body '#{body}'" end end true @@ -1326,7 +1326,7 @@ wait untill text in selector disabppears number = instance.find_elements( { css: '.active .page-header .ticket-number' } )[0].text if number !~ /#{params[:number]}/ screenshot( browser: instance, comment: 'ticket_open_by_overview_failed' ) - raise "unable to search/find ticket #{params[:number]}!" + fail "unable to search/find ticket #{params[:number]}!" end sleep 1 assert( true, "ticket #{params[:number]} found" ) @@ -1359,7 +1359,7 @@ wait untill text in selector disabppears sleep 0.5 text = instance.find_elements( { css: '#global-search' } )[0].attribute('value') if !text - raise '#global-search is not empty!' + fail '#global-search is not empty!' end # search by number again @@ -1374,7 +1374,7 @@ wait untill text in selector disabppears number = instance.find_elements( { css: '.active .page-header .ticket-number' } )[0].text if number !~ /#{params[:number]}/ screenshot( browser: instance, comment: 'ticket_open_by_search_failed' ) - raise "unable to search/find ticket #{params[:number]}!" + fail "unable to search/find ticket #{params[:number]}!" end sleep 1 true @@ -1439,7 +1439,7 @@ wait untill text in selector disabppears sleep 0.5 text = instance.find_elements( { css: '#global-search' } )[0].attribute('value') if !text - raise '#global-search is not empty!' + fail '#global-search is not empty!' end element = instance.find_elements( { css: '#global-search' } )[0] element.click @@ -1450,7 +1450,7 @@ wait untill text in selector disabppears name = instance.find_elements( { css: '.active h1' } )[0].text if name !~ /#{params[:value]}/ screenshot( browser: instance, comment: 'organization_open_by_search_failed' ) - raise "unable to search/find org #{params[:value]}!" + fail "unable to search/find org #{params[:value]}!" end assert( true, "org #{params[:value]} found" ) sleep 2 @@ -1480,7 +1480,7 @@ wait untill text in selector disabppears name = instance.find_elements( { css: '.active h1' } )[0].text if name !~ /#{params[:value]}/ screenshot( browser: instance, comment: 'user_open_by_search_failed' ) - raise "unable to search/find user #{params[:value]}!" + fail "unable to search/find user #{params[:value]}!" end assert( true, "user #{params[:term]} found" ) sleep 2 @@ -1586,7 +1586,7 @@ wait untill text in selector disabppears sleep 1 } screenshot( browser: instance, comment: 'sla_create_failed' ) - raise 'sla creation failed' + fail 'sla creation failed' end =begin @@ -1633,7 +1633,7 @@ wait untill text in selector disabppears sleep 1 } screenshot( browser: instance, comment: 'text_module_create_failed' ) - raise 'text module creation failed' + fail 'text module creation failed' end =begin @@ -1677,7 +1677,7 @@ wait untill text in selector disabppears sleep 1 } screenshot( browser: instance, comment: 'signature_create_failed' ) - raise 'signature creation failed' + fail 'signature creation failed' end =begin @@ -1748,7 +1748,7 @@ wait untill text in selector disabppears return true } screenshot( browser: instance, comment: 'group_create_failed' ) - raise 'group creation failed' + fail 'group creation failed' end def quote(string) diff --git a/test/integration/elasticsearch_test.rb b/test/integration/elasticsearch_test.rb index 374309685..ed2385a85 100644 --- a/test/integration/elasticsearch_test.rb +++ b/test/integration/elasticsearch_test.rb @@ -6,11 +6,11 @@ class ElasticsearchTest < ActiveSupport::TestCase # set config if !ENV['ES_URL'] - raise "ERROR: Need ES_URL - hint ES_URL='http://172.0.0.1:9200'" + fail "ERROR: Need ES_URL - hint ES_URL='http://172.0.0.1:9200'" end Setting.set('es_url', ENV['ES_URL']) if !ENV['ES_INDEX'] - raise "ERROR: Need ES_INDEX - hint ES_INDEX='estest.local_zammad'" + fail "ERROR: Need ES_INDEX - hint ES_INDEX='estest.local_zammad'" end Setting.set('es_index', ENV['ES_INDEX']) diff --git a/test/integration/geo_location_test.rb b/test/integration/geo_location_test.rb index 894d4ca24..da928f104 100644 --- a/test/integration/geo_location_test.rb +++ b/test/integration/geo_location_test.rb @@ -66,7 +66,6 @@ class GeoLocationTest < ActiveSupport::TestCase assert_equal(52.52204, user2.preferences['lat']) assert_equal(13.38319, user2.preferences['lng']) - user3 = User.create( login: 'some_geo_login3', firstname: 'First', @@ -84,7 +83,6 @@ class GeoLocationTest < ActiveSupport::TestCase assert_equal(47.4366664, user3.preferences['lat']) assert_equal(9.409814899999999, user3.preferences['lng']) - user4 = User.create( login: 'some_geo_login4', firstname: 'First', diff --git a/test/integration/otrs_import_test.rb b/test/integration/otrs_import_test.rb index 9e5e380d8..c1c509a03 100644 --- a/test/integration/otrs_import_test.rb +++ b/test/integration/otrs_import_test.rb @@ -4,10 +4,10 @@ require 'integration_test_helper' class OtrsImportTest < ActiveSupport::TestCase if !ENV['IMPORT_OTRS_ENDPOINT'] - raise "ERROR: Need IMPORT_OTRS_ENDPOINT - hint IMPORT_OTRS_ENDPOINT='http://vz305.demo.znuny.com/otrs/public.pl?Action=ZammadMigrator'" + fail "ERROR: Need IMPORT_OTRS_ENDPOINT - hint IMPORT_OTRS_ENDPOINT='http://vz305.demo.znuny.com/otrs/public.pl?Action=ZammadMigrator'" end if !ENV['IMPORT_OTRS_ENDPOINT_KEY'] - raise "ERROR: Need IMPORT_OTRS_ENDPOINT_KEY - hint IMPORT_OTRS_ENDPOINT_KEY='01234567899876543210'" + fail "ERROR: Need IMPORT_OTRS_ENDPOINT_KEY - hint IMPORT_OTRS_ENDPOINT_KEY='01234567899876543210'" end Setting.set('import_otrs_endpoint', ENV['IMPORT_OTRS_ENDPOINT']) diff --git a/test/unit/assets_test.rb b/test/unit/assets_test.rb index 52e90ec5f..ea7426c6d 100644 --- a/test/unit/assets_test.rb +++ b/test/unit/assets_test.rb @@ -76,6 +76,6 @@ class AssetsTest < ActiveSupport::TestCase def diff(o1, o2) return true if o1 #== o2 - raise "ERROR: difference #{o1.inspect}, #{o2.inspect}" + fail "ERROR: difference #{o1.inspect}, #{o2.inspect}" end end