Corrected with rubocop cop 'Style/SignalException'.

This commit is contained in:
Thorsten Eckel 2015-05-07 13:27:07 +02:00
parent 1e4f47acde
commit c2af4fdd30
34 changed files with 97 additions and 104 deletions

View file

@ -173,11 +173,6 @@ Style/Documentation:
Description: 'Document classes and non-namespace modules.' Description: 'Document classes and non-namespace modules.'
Enabled: false 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: Metrics/AbcSize:
Description: >- Description: >-
A calculated magnitude based on number of assignments, A calculated magnitude based on number of assignments,

View file

@ -831,7 +831,7 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
# validate params # validate params
if !params[:adapter] if !params[:adapter]
raise 'need :adapter param' fail 'need :adapter param'
end end
# connection test # connection test

View file

@ -350,7 +350,7 @@ class TicketsController < ApplicationController
def stats def stats
if !params[:user_id] && !params[:organization_id] 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 end
# permissin check # permissin check

View file

@ -34,7 +34,7 @@ add a new activity entry for an object
if data[:role] if data[:role]
role = Role.lookup( name: data[:role] ) role = Role.lookup( name: data[:role] )
if !role if !role
raise "No such Role #{data[:role]}" fail "No such Role #{data[:role]}"
end end
role_id = role.id role_id = role.id
end end

View file

@ -70,7 +70,7 @@ returns
def self.param_cleanup(params, newObject = false) def self.param_cleanup(params, newObject = false)
if params.nil? if params.nil?
raise "No params for #{self}!" fail "No params for #{self}!"
end end
# ignore id for new objects # ignore id for new objects
@ -340,7 +340,7 @@ returns
} }
return return
else else
raise 'Need name, id or login for lookup()' fail 'Need name, id or login for lookup()'
end end
end end
@ -435,7 +435,7 @@ returns
record.save record.save
return record return record
else else
raise 'Need name, login or locale for create_or_update()' fail 'Need name, login or locale for create_or_update()'
end end
end end

View file

@ -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 ActiveRecord::Base.transaction do
result.data.each {|locale| result.data.each {|locale|

View file

@ -33,7 +33,7 @@ class Observer::Ticket::Article::FillupFromEmail < ActiveRecord::Observer
# set sender # set sender
email_address = ticket.group.email_address email_address = ticket.group.email_address
if !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 end
system_sender = "#{email_address.realname} <#{email_address.email}>" system_sender = "#{email_address.realname} <#{email_address.email}>"
if Setting.get('ticket_define_email_from') == 'AgentNameSystemAddressName' if Setting.get('ticket_define_email_from') == 'AgentNameSystemAddressName'

View file

@ -100,7 +100,7 @@ class Observer::Ticket::Notification < ActiveRecord::Observer
end end
end end
else else
raise "unknown object for notification #{event[:name]}" fail "unknown object for notification #{event[:name]}"
end end
} }
list_objects list_objects

View file

@ -97,7 +97,7 @@ class Observer::Ticket::Notification::BackgroundJob
elsif @p[:type] == 'update' elsif @p[:type] == 'update'
template = self.template_update(user, ticket, article, changes) template = self.template_update(user, ticket, article, changes)
else else
raise "unknown type for notification #{@p[:type]}" fail "unknown type for notification #{@p[:type]}"
end end
# prepare subject & body # prepare subject & body

View file

@ -85,7 +85,7 @@ class Package < ApplicationModel
package = entry.sub( %r{^.*/(.+?)\.szpm$}, '\1') package = entry.sub( %r{^.*/(.+?)\.szpm$}, '\1')
end end
if package == false 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 end
logger.debug package.inspect logger.debug package.inspect
package package
@ -154,7 +154,7 @@ class Package < ApplicationModel
if File.file?( entry.to_s ) && ( File.file?( dest.to_s ) && !File.symlink?( dest.to_s ) ) if File.file?( entry.to_s ) && ( File.file?( dest.to_s ) && !File.symlink?( dest.to_s ) )
backup_file = dest.to_s + '.link_backup' backup_file = dest.to_s + '.link_backup'
if File.exist?( backup_file ) 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 else
logger.info "Create backup file of #{dest} -> #{backup_file}." logger.info "Create backup file of #{dest} -> #{backup_file}."
File.rename( dest.to_s, backup_file ) File.rename( dest.to_s, backup_file )
@ -199,10 +199,10 @@ class Package < ApplicationModel
if package_db if package_db
if !data[:reinstall] if !data[:reinstall]
if Gem::Version.new( package_db.version ) == Gem::Version.new( meta[:version] ) 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 end
if Gem::Version.new( package_db.version ) > Gem::Version.new( meta[:version] ) 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
end end
@ -255,7 +255,7 @@ class Package < ApplicationModel
def self.reinstall(package_name) def self.reinstall(package_name)
package = Package.find_by( name: package_name ) package = Package.find_by( name: package_name )
if !package if !package
raise "No such package '#{package_name}'" fail "No such package '#{package_name}'"
end end
file = self._get_bin( package.name, package.version ) file = self._get_bin( package.name, package.version )
@ -345,7 +345,7 @@ class Package < ApplicationModel
version: version, version: version,
) )
if !package if !package
raise "No such package '#{name}' version '#{version}'" fail "No such package '#{name}' version '#{version}'"
end end
list = Store.list( list = Store.list(
object: 'Package', object: 'Package',
@ -354,10 +354,10 @@ class Package < ApplicationModel
# find file # find file
if !list || !list.first if !list || !list.first
raise "No such file in storage list #{name} #{version}" fail "No such file in storage list #{name} #{version}"
end end
if !list.first.content if !list.first.content
raise "No such file in storage #{name} #{version}" fail "No such file in storage #{name} #{version}"
end end
list.first.content list.first.content
end end
@ -470,7 +470,7 @@ class Package < ApplicationModel
name = $2 name = $2
end end
if !version || !name if !version || !name
raise "Invalid package migration '#{migration}'" fail "Invalid package migration '#{migration}'"
end end
# down # down

View file

@ -39,7 +39,7 @@ class Setting < ApplicationModel
def self.set(name, value) def self.set(name, value)
setting = Setting.find_by( name: name ) setting = Setting.find_by( name: name )
if !setting if !setting
raise "Can't find config setting '#{name}'" fail "Can't find config setting '#{name}'"
end end
setting.state = { value: value } setting.state = { value: value }
setting.save setting.save

View file

@ -142,7 +142,7 @@ returns
def content def content
file = Store::File.find_by( id: self.store_file_id ) file = Store::File.find_by( id: self.store_file_id )
if !file if !file
raise "No such file #{ self.store_file_id }!" fail "No such file #{ self.store_file_id }!"
end end
file.content file.content
end end
@ -150,7 +150,7 @@ returns
def provider def provider
file = Store::File.find_by( id: self.store_file_id ) file = Store::File.find_by( id: self.store_file_id )
if !file if !file
raise "No such file #{ self.store_file_id }!" fail "No such file #{ self.store_file_id }!"
end end
file.provider file.provider
end end

View file

@ -15,7 +15,7 @@ class Store
# load backend based on config # load backend based on config
adapter_name = Setting.get('storage_provider') || 'DB' adapter_name = Setting.get('storage_provider') || 'DB'
if !adapter_name if !adapter_name
raise 'Missing storage_provider setting option' fail 'Missing storage_provider setting option'
end end
adapter = self.load_adapter( "Store::Provider::#{ adapter_name }" ) adapter = self.load_adapter( "Store::Provider::#{ adapter_name }" )
adapter.add( data, sha ) adapter.add( data, sha )

View file

@ -19,7 +19,7 @@ class Store::Provider::File
# check sha # check sha
local_sha = Digest::SHA256.hexdigest( get(sha) ) local_sha = Digest::SHA256.hexdigest( get(sha) )
if sha != local_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 end
true true
@ -29,7 +29,7 @@ class Store::Provider::File
def self.get(sha) def self.get(sha)
Rails.logger.debug "read from fs #{ get_locaton(sha) }" Rails.logger.debug "read from fs #{ get_locaton(sha) }"
if !File.exist?( 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 end
data = File.open( get_locaton(sha), 'rb' ) data = File.open( get_locaton(sha), 'rb' )
content = data.read content = data.read
@ -37,7 +37,7 @@ class Store::Provider::File
# check sha # check sha
local_sha = Digest::SHA256.hexdigest( content ) local_sha = Digest::SHA256.hexdigest( content )
if local_sha != sha 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 end
content content
end end

View file

@ -300,7 +300,7 @@ returns
relative = total_time - total_time_without_pending relative = total_time - total_time_without_pending
return relative return relative
else else
raise "ERROR: Unknown type #{type}" fail "ERROR: Unknown type #{type}"
end end
end end

View file

@ -23,7 +23,7 @@ returns
ticket = Ticket.find_by( number: number ) ticket = Ticket.find_by( number: number )
return number if !ticket return number if !ticket
} }
raise "Can't generate new ticket number!" fail "Can't generate new ticket number!"
end end
=begin =begin
@ -47,11 +47,11 @@ returns
# load backend based on config # load backend based on config
adapter_name = Setting.get('ticket_number') adapter_name = Setting.get('ticket_number')
if !adapter_name if !adapter_name
raise 'Missing ticket_number setting option' fail 'Missing ticket_number setting option'
end end
adapter = load_adapter(adapter_name) adapter = load_adapter(adapter_name)
if !adapter if !adapter
raise "Can't load ticket_number adapter '#{adapter_name}'" fail "Can't load ticket_number adapter '#{adapter_name}'"
end end
adapter adapter
end end

View file

@ -88,7 +88,7 @@ returns
} }
if data[:view] && !overview_selected if data[:view] && !overview_selected
raise "No such view '#{ data[:view] }'" fail "No such view '#{ data[:view] }'"
end end
# sortby # sortby

View file

@ -28,7 +28,7 @@ returns:
state_type_id: Ticket::StateType.where( name: ['closed'] ) state_type_id: Ticket::StateType.where( name: ['closed'] )
) )
end end
raise "Unknown category '#{category}'" fail "Unknown category '#{category}'"
end end
=begin =begin

View file

@ -26,7 +26,7 @@ load translations from online
json: true, 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 ActiveRecord::Base.transaction do
result.data.each {|translation| result.data.each {|translation|
@ -87,7 +87,7 @@ push translations to online
json: true, 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 true
end end

View file

@ -53,7 +53,7 @@ returns
adapter = adapter.constantize adapter = adapter.constantize
if !adapter if !adapter
raise "Can't load adapter '#{adapter_name}'" fail "Can't load adapter '#{adapter_name}'"
end end
adapter adapter

View file

@ -25,7 +25,7 @@ class GeoIp::ZammadGeoIp
}, },
) )
if !response.success? && response.code.to_s !~ /^40.$/ if !response.success? && response.code.to_s !~ /^40.$/
raise "ERROR: #{response.code}/#{response.body}" fail "ERROR: #{response.code}/#{response.body}"
end end
data = response.data data = response.data

View file

@ -117,7 +117,7 @@ module Import::OTRS
# check if system is in import mode # check if system is in import mode
if !Setting.get('import_mode') if !Setting.get('import_mode')
raise 'System is not in import mode!' fail 'System is not in import mode!'
end end
response = request('public.pl?Action=Export') response = request('public.pl?Action=Export')
@ -180,7 +180,7 @@ module Import::OTRS
# check if system is in import mode # check if system is in import mode
if !Setting.get('import_mode') if !Setting.get('import_mode')
raise 'System is not in import mode!' fail 'System is not in import mode!'
end end
# create states # create states

View file

@ -21,14 +21,14 @@ module Import::OTRS2
def self.request_json(data, data_only = false) def self.request_json(data, data_only = false)
response = post(data) response = post(data)
if !response if !response
raise "Can't connect to Zammad Migrator" fail "Can't connect to Zammad Migrator"
end end
if !response.success? if !response.success?
raise "Can't connect to Zammad Migrator" fail "Can't connect to Zammad Migrator"
end end
result = json(response) result = json(response)
if !result if !result
raise 'Invalid response' fail 'Invalid response'
end end
if data_only if data_only
result['Result'] result['Result']
@ -297,7 +297,7 @@ module Import::OTRS2
# check if system is in import mode # check if system is in import mode
if !Setting.get('import_mode') if !Setting.get('import_mode')
raise 'System is not in import mode!' fail 'System is not in import mode!'
end end
result = request_json({}) result = request_json({})
@ -423,7 +423,7 @@ module Import::OTRS2
# check if system is in import mode # check if system is in import mode
if !Setting.get('import_mode') if !Setting.get('import_mode')
raise 'System is not in import mode!' fail 'System is not in import mode!'
end end
# create states # create states

View file

@ -9,7 +9,7 @@ module Rss
Rails.logger.info "fetch rss... #{url}" Rails.logger.info "fetch rss... #{url}"
response = UserAgent.request(url) response = UserAgent.request(url)
if !response.success? if !response.success?
raise "Can't fetch '#{url}', http code: #{response.code}" fail "Can't fetch '#{url}', http code: #{response.code}"
return return
end end
rss = SimpleRSS.parse response.body rss = SimpleRSS.parse response.body

View file

@ -59,7 +59,7 @@ create/update/delete index
) )
Rails.logger.info "# #{response.code}" Rails.logger.info "# #{response.code}"
return true if response.success? return true if response.success?
raise response.inspect fail response.inspect
end end
=begin =begin
@ -91,7 +91,7 @@ add new object to search index
) )
Rails.logger.info "# #{response.code}" Rails.logger.info "# #{response.code}"
return true if response.success? return true if response.success?
raise response.inspect fail response.inspect
end end
=begin =begin

View file

@ -7,7 +7,7 @@ module StaticAssets
data[:content] = Base64.decode64($2) data[:content] = Base64.decode64($2)
return data return data
end end
raise "Unable to parse data url: #{data_url.substr(0, 100)}" fail "Unable to parse data url: #{data_url.substr(0, 100)}"
end end
# store image 1:1 # store image 1:1
@ -31,7 +31,7 @@ module StaticAssets
if list && list[0] if list && list[0]
return Store.find( list[0] ) return Store.find( list[0] )
end end
raise 'No such raw logo!' fail 'No such raw logo!'
end end
# store image in right size # store image in right size

View file

@ -11,7 +11,7 @@ namespace :test do
end end
Dir.glob('test/browser/*_test.rb').sort.each { |r| Dir.glob('test/browser/*_test.rb').sort.each { |r|
sh "#{args.opts} ruby -Itest #{r}" do |ok, res| sh "#{args.opts} ruby -Itest #{r}" do |ok, res|
raise 'Failed test. ' + res.inspect if !ok fail 'Failed test. ' + res.inspect if !ok
end end
} }
puts 'All browser tests, elapsed: ' + (Time.now() - start).to_s + ' seconds' puts 'All browser tests, elapsed: ' + (Time.now() - start).to_s + ' seconds'

View file

@ -53,7 +53,7 @@ put working hours matrix and timezone in function, returns UTC working hours mat
} }
if !config_ok if !config_ok
raise 'sla config is invalid! ' + config.inspect fail 'sla config is invalid! ' + config.inspect
end end
# shift working hours / if needed # shift working hours / if needed

View file

@ -307,7 +307,7 @@ returns
code: response.code, code: response.code,
) )
when Net::HTTPRedirection 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'] url = response['location']
return get(url, params, options, count - 1) return get(url, params, options, count - 1)
when Net::HTTPOK when Net::HTTPOK
@ -336,7 +336,7 @@ returns
) )
end end
raise "Unable to process http call '#{response.inspect}'" fail "Unable to process http call '#{response.inspect}'"
end end
def self.ftp(uri, options) def self.ftp(uri, options)

View file

@ -105,7 +105,7 @@ class TestCase < Test::Unit::TestCase
element = instance.find_elements( { css: '#login input[name="username"]' } )[0] element = instance.find_elements( { css: '#login input[name="username"]' } )[0]
if !element if !element
screenshot( browser: instance, comment: 'login_failed' ) screenshot( browser: instance, comment: 'login_failed' )
raise 'No login box found' fail 'No login box found'
end end
screenshot( browser: instance, comment: 'login' ) 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') login = instance.find_elements( { css: '.user-menu .user a' } )[0].attribute('title')
if login != params[:username] if login != params[:username]
screenshot( browser: instance, comment: 'login_failed' ) screenshot( browser: instance, comment: 'login_failed' )
raise 'login failed' fail 'login failed'
end end
screenshot( browser: instance, comment: 'login_ok' ) screenshot( browser: instance, comment: 'login_ok' )
assert( true, 'login ok' ) assert( true, 'login ok' )
@ -159,7 +159,7 @@ class TestCase < Test::Unit::TestCase
end end
} }
screenshot( browser: instance, comment: 'logout_failed' ) 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 end
=begin =begin
@ -194,7 +194,7 @@ class TestCase < Test::Unit::TestCase
instance = params[:browser] || @browser instance = params[:browser] || @browser
if instance.current_url !~ /#{Regexp.quote(params[:url])}/ if instance.current_url !~ /#{Regexp.quote(params[:url])}/
screenshot( browser: instance, comment: 'location_check_failed' ) 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 end
assert( true, "url #{instance.current_url} is matching #{params[:url]}" ) assert( true, "url #{instance.current_url} is matching #{params[:url]}" )
end end
@ -259,7 +259,7 @@ class TestCase < Test::Unit::TestCase
instance = params[:browser] || @browser instance = params[:browser] || @browser
if !instance.find_elements( { css: params[:css] } )[0] if !instance.find_elements( { css: params[:css] } )[0]
screenshot( browser: instance, comment: 'exists_failed' ) screenshot( browser: instance, comment: 'exists_failed' )
raise "#{params[:css]} dosn't exist, but should" fail "#{params[:css]} dosn't exist, but should"
end end
true true
end end
@ -279,7 +279,7 @@ class TestCase < Test::Unit::TestCase
instance = params[:browser] || @browser instance = params[:browser] || @browser
if instance.find_elements( { css: params[:css] } )[0] if instance.find_elements( { css: params[:css] } )[0]
screenshot( browser: instance, comment: 'exists_not_failed' ) screenshot( browser: instance, comment: 'exists_not_failed' )
raise "#{params[:css]} exists but should not" fail "#{params[:css]} exists but should not"
end end
true true
end end
@ -454,12 +454,12 @@ class TestCase < Test::Unit::TestCase
end end
if params[:should_not_match] if params[:should_not_match]
if success 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 end
return true return true
else else
if !success if !success
raise "not matching '#{params[:value]}' in select list" fail "not matching '#{params[:value]}' in select list"
end end
return true return true
end end
@ -503,11 +503,11 @@ class TestCase < Test::Unit::TestCase
end end
if match if match
if params[:should_not_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 end
else else
if !params[:should_not_match] 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
end end
sleep 0.8 sleep 0.8
@ -569,16 +569,16 @@ class TestCase < Test::Unit::TestCase
if params.key?( :value ) && cookie[:value].to_s =~ /#{params[:value]}/i if params.key?( :value ) && cookie[:value].to_s =~ /#{params[:value]}/i
assert( true, "matching value '#{params[:value]}' in cookie '#{cookie}'" ) assert( true, "matching value '#{params[:value]}' in cookie '#{cookie}'" )
else else
raise "not matching value '#{params[:value]}' in cookie '#{cookie}'" fail "not matching value '#{params[:value]}' in cookie '#{cookie}'"
end end
if params.key?( :expires ) && cookie[:expires].to_s =~ /#{params[:expires]}/i if params.key?( :expires ) && cookie[:expires].to_s =~ /#{params[:expires]}/i
assert( true, "matching expires '#{params[:expires].inspect}' in cookie '#{cookie}'" ) assert( true, "matching expires '#{params[:expires].inspect}' in cookie '#{cookie}'" )
else else
raise "not matching expires '#{params[:expires]}' in cookie '#{cookie}'" fail "not matching expires '#{params[:expires]}' in cookie '#{cookie}'"
end end
if params[:should_not_exist] 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 end
return return
end end
@ -587,7 +587,7 @@ class TestCase < Test::Unit::TestCase
assert( true, "cookie with name '#{params[:name]}' is not existing" ) assert( true, "cookie with name '#{params[:name]}' is not existing" )
return return
end end
raise "not matching name '#{params[:name]}' in cookie '#{cookies}'" fail "not matching name '#{params[:name]}' in cookie '#{cookies}'"
end end
=begin =begin
@ -608,7 +608,7 @@ class TestCase < Test::Unit::TestCase
if title =~ /#{params[:value]}/i if title =~ /#{params[:value]}/i
assert( true, "matching '#{params[:value]}' in title '#{title}'" ) assert( true, "matching '#{params[:value]}' in title '#{title}'" )
else else
raise "not matching '#{params[:value]}' in title '#{title}'" fail "not matching '#{params[:value]}' in title '#{title}'"
end end
end end
@ -640,7 +640,7 @@ class TestCase < Test::Unit::TestCase
if title =~ /#{data[:title]}/i if title =~ /#{data[:title]}/i
assert( true, "matching '#{data[:title]}' in title '#{title}'" ) assert( true, "matching '#{data[:title]}' in title '#{title}'" )
else else
raise "not matching '#{data[:title]}' in title '#{title}'" fail "not matching '#{data[:title]}' in title '#{title}'"
end end
end end
puts "tv #{params.inspect}" puts "tv #{params.inspect}"
@ -659,17 +659,17 @@ class TestCase < Test::Unit::TestCase
if is_modified if is_modified
assert( true, "task '#{data[:title]}' is modifed" ) assert( true, "task '#{data[:title]}' is modifed" )
elsif !exists elsif !exists
raise "task '#{data[:title]}' not exists, should not modified" fail "task '#{data[:title]}' not exists, should not modified"
else else
raise "task '#{data[:title]}' is not modifed" fail "task '#{data[:title]}' is not modifed"
end end
else else
if !is_modified if !is_modified
assert( true, "task '#{data[:title]}' is modifed" ) assert( true, "task '#{data[:title]}' is modifed" )
elsif !exists elsif !exists
raise "task '#{data[:title]}' not exists, should be not modified" fail "task '#{data[:title]}' not exists, should be not modified"
else else
raise "task '#{data[:title]}' is modifed, but should not" fail "task '#{data[:title]}' is modifed, but should not"
end end
end end
end end
@ -705,7 +705,7 @@ class TestCase < Test::Unit::TestCase
element = instance.find_elements( { partial_link_text: data[:title] } )[0] element = instance.find_elements( { partial_link_text: data[:title] } )[0]
if !element if !element
screenshot( browser: instance, comment: 'open_task_failed' ) screenshot( browser: instance, comment: 'open_task_failed' )
raise "no task with title '#{data[:title]}' found" fail "no task with title '#{data[:title]}' found"
end end
element.click element.click
true true
@ -785,7 +785,7 @@ class TestCase < Test::Unit::TestCase
sleep 0.5 sleep 0.5
} }
screenshot( browser: instance, comment: 'watch_for_failed' ) screenshot( browser: instance, comment: 'watch_for_failed' )
raise "'#{params[:value]}' found in '#{text}'" fail "'#{params[:value]}' found in '#{text}'"
end end
=begin =begin
@ -842,7 +842,7 @@ wait untill text in selector disabppears
sleep 1 sleep 1
} }
screenshot( browser: instance, comment: 'disappear_failed' ) screenshot( browser: instance, comment: 'disappear_failed' )
raise "#{params[:css]}) still exsists" fail "#{params[:css]}) still exsists"
end end
=begin =begin
@ -955,7 +955,7 @@ wait untill text in selector disabppears
sleep 1 sleep 1
} }
screenshot( browser: instance, comment: 'overview_create_failed' ) screenshot( browser: instance, comment: 'overview_create_failed' )
raise 'overview creation failed' fail 'overview creation failed'
end end
=begin =begin
@ -990,7 +990,7 @@ wait untill text in selector disabppears
element = instance.find_elements( { css: '.active .newTicket' } )[0] element = instance.find_elements( { css: '.active .newTicket' } )[0]
if !element if !element
screenshot( browser: instance, comment: 'ticket_create_failed' ) screenshot( browser: instance, comment: 'ticket_create_failed' )
raise 'no ticket create screen found!' fail 'no ticket create screen found!'
end end
sleep 1 sleep 1
@ -1086,7 +1086,7 @@ wait untill text in selector disabppears
sleep 1 sleep 1
} }
screenshot( browser: instance, comment: 'ticket_create_failed' ) 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 end
=begin =begin
@ -1235,7 +1235,7 @@ wait untill text in selector disabppears
} }
if !found if !found
screenshot( browser: instance, comment: 'ticket_update_discard_message_failed' ) screenshot( browser: instance, comment: 'ticket_update_discard_message_failed' )
raise 'no discard message found' fail 'no discard message found'
end end
end end
@ -1259,7 +1259,7 @@ wait untill text in selector disabppears
sleep 1 sleep 1
} }
screenshot( browser: instance, comment: 'ticket_update_failed' ) screenshot( browser: instance, comment: 'ticket_update_failed' )
raise 'unable to update ticket' fail 'unable to update ticket'
end end
=begin =begin
@ -1287,7 +1287,7 @@ wait untill text in selector disabppears
if title =~ /#{data[:title]}/i if title =~ /#{data[:title]}/i
assert( true, "matching '#{data[:title]}' in title '#{title}'" ) assert( true, "matching '#{data[:title]}' in title '#{title}'" )
else else
raise "not matching '#{data[:title]}' in title '#{title}'" fail "not matching '#{data[:title]}' in title '#{title}'"
end end
end end
@ -1296,7 +1296,7 @@ wait untill text in selector disabppears
if body =~ /#{data[:body]}/i if body =~ /#{data[:body]}/i
assert( true, "matching '#{data[:body]}' in body '#{body}'" ) assert( true, "matching '#{data[:body]}' in body '#{body}'" )
else else
raise "not matching '#{data[:body]}' in body '#{body}'" fail "not matching '#{data[:body]}' in body '#{body}'"
end end
end end
true true
@ -1326,7 +1326,7 @@ wait untill text in selector disabppears
number = instance.find_elements( { css: '.active .page-header .ticket-number' } )[0].text number = instance.find_elements( { css: '.active .page-header .ticket-number' } )[0].text
if number !~ /#{params[:number]}/ if number !~ /#{params[:number]}/
screenshot( browser: instance, comment: 'ticket_open_by_overview_failed' ) 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 end
sleep 1 sleep 1
assert( true, "ticket #{params[:number]} found" ) assert( true, "ticket #{params[:number]} found" )
@ -1359,7 +1359,7 @@ wait untill text in selector disabppears
sleep 0.5 sleep 0.5
text = instance.find_elements( { css: '#global-search' } )[0].attribute('value') text = instance.find_elements( { css: '#global-search' } )[0].attribute('value')
if !text if !text
raise '#global-search is not empty!' fail '#global-search is not empty!'
end end
# search by number again # 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 number = instance.find_elements( { css: '.active .page-header .ticket-number' } )[0].text
if number !~ /#{params[:number]}/ if number !~ /#{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]}!" fail "unable to search/find ticket #{params[:number]}!"
end end
sleep 1 sleep 1
true true
@ -1439,7 +1439,7 @@ wait untill text in selector disabppears
sleep 0.5 sleep 0.5
text = instance.find_elements( { css: '#global-search' } )[0].attribute('value') text = instance.find_elements( { css: '#global-search' } )[0].attribute('value')
if !text if !text
raise '#global-search is not empty!' fail '#global-search is not empty!'
end end
element = instance.find_elements( { css: '#global-search' } )[0] element = instance.find_elements( { css: '#global-search' } )[0]
element.click element.click
@ -1450,7 +1450,7 @@ wait untill text in selector disabppears
name = instance.find_elements( { css: '.active h1' } )[0].text name = instance.find_elements( { css: '.active h1' } )[0].text
if name !~ /#{params[:value]}/ if name !~ /#{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]}!" fail "unable to search/find org #{params[:value]}!"
end end
assert( true, "org #{params[:value]} found" ) assert( true, "org #{params[:value]} found" )
sleep 2 sleep 2
@ -1480,7 +1480,7 @@ wait untill text in selector disabppears
name = instance.find_elements( { css: '.active h1' } )[0].text name = instance.find_elements( { css: '.active h1' } )[0].text
if name !~ /#{params[:value]}/ if name !~ /#{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]}!" fail "unable to search/find user #{params[:value]}!"
end end
assert( true, "user #{params[:term]} found" ) assert( true, "user #{params[:term]} found" )
sleep 2 sleep 2
@ -1586,7 +1586,7 @@ wait untill text in selector disabppears
sleep 1 sleep 1
} }
screenshot( browser: instance, comment: 'sla_create_failed' ) screenshot( browser: instance, comment: 'sla_create_failed' )
raise 'sla creation failed' fail 'sla creation failed'
end end
=begin =begin
@ -1633,7 +1633,7 @@ wait untill text in selector disabppears
sleep 1 sleep 1
} }
screenshot( browser: instance, comment: 'text_module_create_failed' ) screenshot( browser: instance, comment: 'text_module_create_failed' )
raise 'text module creation failed' fail 'text module creation failed'
end end
=begin =begin
@ -1677,7 +1677,7 @@ wait untill text in selector disabppears
sleep 1 sleep 1
} }
screenshot( browser: instance, comment: 'signature_create_failed' ) screenshot( browser: instance, comment: 'signature_create_failed' )
raise 'signature creation failed' fail 'signature creation failed'
end end
=begin =begin
@ -1748,7 +1748,7 @@ wait untill text in selector disabppears
return true return true
} }
screenshot( browser: instance, comment: 'group_create_failed' ) screenshot( browser: instance, comment: 'group_create_failed' )
raise 'group creation failed' fail 'group creation failed'
end end
def quote(string) def quote(string)

View file

@ -6,11 +6,11 @@ class ElasticsearchTest < ActiveSupport::TestCase
# set config # set config
if !ENV['ES_URL'] 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 end
Setting.set('es_url', ENV['ES_URL']) Setting.set('es_url', ENV['ES_URL'])
if !ENV['ES_INDEX'] 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 end
Setting.set('es_index', ENV['ES_INDEX']) Setting.set('es_index', ENV['ES_INDEX'])

View file

@ -66,7 +66,6 @@ class GeoLocationTest < ActiveSupport::TestCase
assert_equal(52.52204, user2.preferences['lat']) assert_equal(52.52204, user2.preferences['lat'])
assert_equal(13.38319, user2.preferences['lng']) assert_equal(13.38319, user2.preferences['lng'])
user3 = User.create( user3 = User.create(
login: 'some_geo_login3', login: 'some_geo_login3',
firstname: 'First', firstname: 'First',
@ -84,7 +83,6 @@ class GeoLocationTest < ActiveSupport::TestCase
assert_equal(47.4366664, user3.preferences['lat']) assert_equal(47.4366664, user3.preferences['lat'])
assert_equal(9.409814899999999, user3.preferences['lng']) assert_equal(9.409814899999999, user3.preferences['lng'])
user4 = User.create( user4 = User.create(
login: 'some_geo_login4', login: 'some_geo_login4',
firstname: 'First', firstname: 'First',

View file

@ -4,10 +4,10 @@ require 'integration_test_helper'
class OtrsImportTest < ActiveSupport::TestCase class OtrsImportTest < ActiveSupport::TestCase
if !ENV['IMPORT_OTRS_ENDPOINT'] 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 end
if !ENV['IMPORT_OTRS_ENDPOINT_KEY'] 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 end
Setting.set('import_otrs_endpoint', ENV['IMPORT_OTRS_ENDPOINT']) Setting.set('import_otrs_endpoint', ENV['IMPORT_OTRS_ENDPOINT'])

View file

@ -76,6 +76,6 @@ class AssetsTest < ActiveSupport::TestCase
def diff(o1, o2) def diff(o1, o2)
return true if o1 #== o2 return true if o1 #== o2
raise "ERROR: difference #{o1.inspect}, #{o2.inspect}" fail "ERROR: difference #{o1.inspect}, #{o2.inspect}"
end end
end end