Upgrade to new rubocop.

This commit is contained in:
Martin Edenhofer 2016-03-01 15:26:46 +01:00
parent 8df44fd72b
commit ba3f868638
64 changed files with 221 additions and 219 deletions

View file

@ -354,7 +354,7 @@ class TicketsController < ApplicationController
def stats
if !params[:user_id] && !params[:organization_id]
fail 'Need user_id or organization_id as param'
raise 'Need user_id or organization_id as param'
end
# permission check

View file

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

View file

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

View file

@ -268,7 +268,7 @@ returns
if location =~ /^http/i
result = UserAgent.get(location)
if !result.success?
fail result.error
raise result.error
end
cal_file = result.body
else

View file

@ -29,7 +29,7 @@ class Channel::Driver::Facebook
access_token = page['access_token']
}
if !access_token
fail "No access_token found for fb_object_id: #{fb_object_id}"
raise "No access_token found for fb_object_id: #{fb_object_id}"
end
client = Facebook.new(access_token)
client.from_article(article)

View file

@ -184,7 +184,7 @@ returns
def stream
sync = @channel.options['sync']
fail 'Need channel.options[\'sync\'] for account, but no params found' if !sync
raise 'Need channel.options[\'sync\'] for account, but no params found' if !sync
filter = {}
if sync['search']
@ -315,7 +315,7 @@ returns
def check_external_credential(options)
if options[:auth] && options[:auth][:external_credential_id]
external_credential = ExternalCredential.find_by(id: options[:auth][:external_credential_id])
fail "No such ExternalCredential.find(#{options[:auth][:external_credential_id]})" if !external_credential
raise "No such ExternalCredential.find(#{options[:auth][:external_credential_id]})" if !external_credential
options[:auth][:consumer_key] = external_credential.credentials['consumer_key']
options[:auth][:consumer_secret] = external_credential.credentials['consumer_secret']
end

View file

@ -26,8 +26,8 @@ class Locale < ApplicationModel
}
)
fail "Can't load locales from #{url}" if !result
fail "Can't load locales from #{url}: #{result.error}" if !result.success?
raise "Can't load locales from #{url}" if !result
raise "Can't load locales from #{url}: #{result.error}" if !result.success?
ActiveRecord::Base.transaction do
result.data.each {|locale|

View file

@ -12,9 +12,9 @@ class Observer::Ticket::Article::CommunicateEmail::BackgroundJob
# send email
if !ticket.group.email_address_id
fail "Can't send email, no email address definde for group id '#{ticket.group.id}'"
raise "Can't send email, no email address definde for group id '#{ticket.group.id}'"
elsif !ticket.group.email_address.channel_id
fail "Can't send email, no channel definde for email_address id '#{ticket.group.email_address_id}'"
raise "Can't send email, no channel definde for email_address id '#{ticket.group.email_address_id}'"
end
channel = ticket.group.email_address.channel

View file

@ -20,15 +20,15 @@ class Observer::Ticket::Article::CommunicateFacebook < ActiveRecord::Observer
return if type['name'] !~ /\Afacebook/
ticket = Ticket.lookup(id: record.ticket_id)
fail "Can't find ticket.preferences for Ticket.find(#{record.ticket_id})" if !ticket.preferences
fail "Can't find ticket.preferences['channel_id'] for Ticket.find(#{record.ticket_id})" if !ticket.preferences['channel_id']
raise "Can't find ticket.preferences for Ticket.find(#{record.ticket_id})" if !ticket.preferences
raise "Can't find ticket.preferences['channel_id'] for Ticket.find(#{record.ticket_id})" if !ticket.preferences['channel_id']
channel = Channel.lookup(id: ticket.preferences['channel_id'])
fail "Channel.find(#{channel.id}) isn't a twitter channel!" if channel.options[:adapter] !~ /\Afacebook/i
raise "Channel.find(#{channel.id}) isn't a twitter channel!" if channel.options[:adapter] !~ /\Afacebook/i
# check source object id
ticket = record.ticket
if !ticket.preferences['channel_fb_object_id']
fail "fb object id is missing in ticket.preferences['channel_fb_object_id'] for Ticket.find(#{ticket.id})"
raise "fb object id is missing in ticket.preferences['channel_fb_object_id'] for Ticket.find(#{ticket.id})"
end
# fill in_reply_to

View file

@ -18,11 +18,11 @@ class Observer::Ticket::Article::CommunicateTwitter < ActiveRecord::Observer
return if type['name'] !~ /\Atwitter/i
ticket = Ticket.lookup(id: record.ticket_id)
fail "Can't find ticket.preferences for Ticket.find(#{record.ticket_id})" if !ticket.preferences
fail "Can't find ticket.preferences['channel_id'] for Ticket.find(#{record.ticket_id})" if !ticket.preferences['channel_id']
raise "Can't find ticket.preferences for Ticket.find(#{record.ticket_id})" if !ticket.preferences
raise "Can't find ticket.preferences['channel_id'] for Ticket.find(#{record.ticket_id})" if !ticket.preferences['channel_id']
channel = Channel.lookup(id: ticket.preferences['channel_id'])
fail "No such channel id #{ticket.preferences['channel_id']}" if !channel
fail "Channel.find(#{channel.id}) isn't a twitter channel!" if channel.options[:adapter] !~ /\Atwitter/i
raise "No such channel id #{ticket.preferences['channel_id']}" if !channel
raise "Channel.find(#{channel.id}) isn't a twitter channel!" if channel.options[:adapter] !~ /\Atwitter/i
tweet = channel.deliver(
type: type['name'],
to: record.to,
@ -54,7 +54,7 @@ class Observer::Ticket::Article::CommunicateTwitter < ActiveRecord::Observer
record.preferences[:twitter_mention_ids] = twitter_mention_ids
end
else
fail "Unknown tweet type '#{tweet.class}'"
raise "Unknown tweet type '#{tweet.class}'"
end
record.message_id = tweet.id

View file

@ -38,7 +38,7 @@ class Observer::Ticket::Article::FillupFromEmail < ActiveRecord::Observer
# set sender
email_address = ticket.group.email_address
if !email_address
fail "No email address found for group '#{ticket.group.name}'"
raise "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'

View file

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

View file

@ -162,7 +162,7 @@ class Observer::Ticket::Notification::BackgroundJob
elsif @p[:type] == 'escalation_warning'
template = 'ticket_escalation_warning'
else
fail "unknown type for notification #{@p[:type]}"
raise "unknown type for notification #{@p[:type]}"
end
NotificationFactory.notification(

View file

@ -103,7 +103,7 @@ note: will not take down package migrations, use Package.unlink instead
package = entry.sub(%r{^.*/(.+?)\.szpm$}, '\1')
end
if package == false
fail "Can't link package, '#{package_base_dir}' is no package source directory!"
raise "Can't link package, '#{package_base_dir}' is no package source directory!"
end
logger.debug package.inspect
package
@ -184,7 +184,7 @@ link files + execute migration up
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)
fail "Can't link #{entry} -> #{dest}, destination and .link_backup already exists!"
raise "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)
@ -243,10 +243,10 @@ returns
if package_db
if !data[:reinstall]
if Gem::Version.new(package_db.version) == Gem::Version.new(meta[:version])
fail "Package '#{meta[:name]}-#{meta[:version]}' already installed!"
raise "Package '#{meta[:name]}-#{meta[:version]}' already installed!"
end
if Gem::Version.new(package_db.version) > Gem::Version.new(meta[:version])
fail "Newer version (#{package_db.version}) of package '#{meta[:name]}-#{meta[:version]}' already installed!"
raise "Newer version (#{package_db.version}) of package '#{meta[:name]}-#{meta[:version]}' already installed!"
end
end
@ -306,7 +306,7 @@ returns
def self.reinstall(package_name)
package = Package.find_by(name: package_name)
if !package
fail "No such package '#{package_name}'"
raise "No such package '#{package_name}'"
end
file = _get_bin(package.name, package.version)
install(string: file, reinstall: true)
@ -367,7 +367,7 @@ returns
version: version,
)
if !package
fail "No such package '#{name}' version '#{version}'"
raise "No such package '#{name}' version '#{version}'"
end
list = Store.list(
object: 'Package',
@ -376,10 +376,10 @@ returns
# find file
if !list || !list.first
fail "No such file in storage list #{name} #{version}"
raise "No such file in storage list #{name} #{version}"
end
if !list.first.content
fail "No such file in storage #{name} #{version}"
raise "No such file in storage #{name} #{version}"
end
list.first.content
end
@ -497,7 +497,7 @@ returns
name = $2
end
if !version || !name
fail "Invalid package migration '#{migration}'"
raise "Invalid package migration '#{migration}'"
end
# down

View file

@ -33,7 +33,7 @@ set config setting
def self.set(name, value)
setting = Setting.find_by( name: name )
if !setting
fail "Can't find config setting '#{name}'"
raise "Can't find config setting '#{name}'"
end
setting.state_current = { value: value }
setting.save
@ -68,7 +68,7 @@ reset config setting to default
def self.reset(name)
setting = Setting.find_by( name: name )
if !setting
fail "Can't find config setting '#{name}'"
raise "Can't find config setting '#{name}'"
end
setting.state_current = setting.state_initial
setting.save

View file

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

View file

@ -26,7 +26,7 @@ do also verify of written data
# load backend based on config
adapter_name = Setting.get('storage_provider') || 'DB'
if !adapter_name
fail 'Missing storage_provider setting option'
raise 'Missing storage_provider setting option'
end
adapter = load_adapter("Store::Provider::#{adapter_name}")
adapter.add(data, sha)
@ -40,7 +40,7 @@ do also verify of written data
read_data = adapter.get(sha)
read_sha = Digest::SHA256.hexdigest(read_data)
if sha != read_sha
fail "Content not written correctly (provider #{adapter_name})."
raise "Content not written correctly (provider #{adapter_name})."
end
end
end

View file

@ -18,7 +18,7 @@ class Store::Provider::File
# check sha
local_sha = Digest::SHA256.hexdigest(get(sha))
if sha != local_sha
fail "ERROR: Corrupt file in fs #{location}, sha should be #{sha} but is #{local_sha}"
raise "ERROR: Corrupt file in fs #{location}, sha should be #{sha} but is #{local_sha}"
end
true
@ -29,7 +29,7 @@ class Store::Provider::File
location = get_location(sha)
Rails.logger.debug "read from fs #{location}"
if !File.exist?(location)
fail "ERROR: No such file #{location}"
raise "ERROR: No such file #{location}"
end
data = File.open(location, 'rb')
content = data.read
@ -37,7 +37,7 @@ class Store::Provider::File
# check sha
local_sha = Digest::SHA256.hexdigest(content)
if local_sha != sha
fail "ERROR: Corrupt file in fs #{location}, sha should be #{sha} but is #{local_sha}"
raise "ERROR: Corrupt file in fs #{location}, sha should be #{sha} but is #{local_sha}"
end
content
end

View file

@ -367,7 +367,7 @@ get count of tickets and tickets which match on selector
=end
def self.selectors(selectors, limit = 10, current_user = nil)
fail 'no selectors given' if !selectors
raise 'no selectors given' if !selectors
query, bind_params, tables = selector2sql(selectors, current_user)
return [] if !query
@ -454,7 +454,7 @@ condition example
tables += ', users owners'
query += 'tickets.owner_id = owners.id'
else
fail "invalid selector #{attribute.inspect}->#{selector.inspect}"
raise "invalid selector #{attribute.inspect}->#{selector.inspect}"
end
}
@ -462,10 +462,10 @@ condition example
selectors.each {|attribute, selector_raw|
# validation
fail "Invalid selector #{selector_raw.inspect}" if !selector_raw
fail "Invalid selector #{selector_raw.inspect}" if !selector_raw.respond_to?(:key?)
raise "Invalid selector #{selector_raw.inspect}" if !selector_raw
raise "Invalid selector #{selector_raw.inspect}" if !selector_raw.respond_to?(:key?)
selector = selector_raw.stringify_keys
fail "Invalid selector, operator missing #{selector.inspect}" if !selector['operator']
raise "Invalid selector, operator missing #{selector.inspect}" if !selector['operator']
# validate value / allow empty but only if pre_condition exists
if (selector['value'].class == String || selector['value'].class == Array) && (selector['value'].respond_to?(:empty?) && selector['value'].empty?)
@ -492,11 +492,11 @@ condition example
query += "#{attribute} IS NOT NULL"
end
elsif selector['pre_condition'] == 'current_user.id'
fail "Use current_user.id in selector, but no current_user is set #{selector.inspect}" if !current_user_id
raise "Use current_user.id in selector, but no current_user is set #{selector.inspect}" if !current_user_id
query += "#{attribute} IN (?)"
bind_params.push current_user_id
elsif selector['pre_condition'] == 'current_user.organization_id'
fail "Use current_user.id in selector, but no current_user is set #{selector.inspect}" if !current_user_id
raise "Use current_user.id in selector, but no current_user is set #{selector.inspect}" if !current_user_id
query += "#{attribute} IN (?)"
user = User.lookup(id: current_user_id)
bind_params.push user.organization_id
@ -563,7 +563,7 @@ condition example
elsif selector['range'] == 'year'
time = Time.zone.now - selector['value'].to_i.years
else
fail "Unknown selector attributes '#{selector.inspect}'"
raise "Unknown selector attributes '#{selector.inspect}'"
end
bind_params.push time
elsif selector['operator'] == 'within next (relative)'
@ -580,7 +580,7 @@ condition example
elsif selector['range'] == 'year'
time = Time.zone.now + selector['value'].to_i.years
else
fail "Unknown selector attributes '#{selector.inspect}'"
raise "Unknown selector attributes '#{selector.inspect}'"
end
bind_params.push time
elsif selector['operator'] == 'before (relative)'
@ -597,7 +597,7 @@ condition example
elsif selector['range'] == 'year'
time = Time.zone.now - selector['value'].to_i.years
else
fail "Unknown selector attributes '#{selector.inspect}'"
raise "Unknown selector attributes '#{selector.inspect}'"
end
bind_params.push time
elsif selector['operator'] == 'after (relative)'
@ -614,11 +614,11 @@ condition example
elsif selector['range'] == 'year'
time = Time.zone.now + selector['value'].to_i.years
else
fail "Unknown selector attributes '#{selector.inspect}'"
raise "Unknown selector attributes '#{selector.inspect}'"
end
bind_params.push time
else
fail "Invalid operator '#{selector['operator']}' for '#{selector['value'].inspect}'"
raise "Invalid operator '#{selector['operator']}' for '#{selector['value'].inspect}'"
end
}
[query, bind_params, tables]

View file

@ -84,7 +84,7 @@ returns
}
config.hours = hours
if !hours || hours.empty?
fail "No congifure hours found in calendar #{calendar.inspect}"
raise "No congifure hours found in calendar #{calendar.inspect}"
end
# get holidays

View file

@ -23,7 +23,7 @@ returns
ticket = Ticket.find_by( number: number )
return number if !ticket
}
fail "Can't generate new ticket number!"
raise "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
fail 'Missing ticket_number setting option'
raise 'Missing ticket_number setting option'
end
adapter = load_adapter(adapter_name)
if !adapter
fail "Can't load ticket_number adapter '#{adapter_name}'"
raise "Can't load ticket_number adapter '#{adapter_name}'"
end
adapter
end

View file

@ -72,7 +72,7 @@ returns
}
if data[:view] && !overview_selected
fail "No such view '#{data[:view]}'"
raise "No such view '#{data[:view]}'"
end
# get only tickets with permissions

View file

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

View file

@ -44,7 +44,7 @@ dedicated:
read_timeout: 16,
}
)
fail "Can't load translations from #{url}: #{result.error}" if !result.success?
raise "Can't load translations from #{url}: #{result.error}" if !result.success?
translations = Translation.where(locale: locale).all
ActiveRecord::Base.transaction do
@ -120,7 +120,7 @@ push translations to online
read_timeout: 16,
}
)
fail "Can't push translations to #{url}: #{result.error}" if !result.success?
raise "Can't push translations to #{url}: #{result.error}" if !result.success?
# set new translator_key if given
if result.data['translator_key']

View file

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

View file

@ -32,7 +32,7 @@ returns
def self.data
auto_wizard_file_location = file_location
fail "So such file #{auto_wizard_file_location}" if !File.file?(auto_wizard_file_location)
raise "So such file #{auto_wizard_file_location}" if !File.file?(auto_wizard_file_location)
JSON.parse( File.read(auto_wizard_file_location) )
end

View file

@ -23,6 +23,7 @@ class ExternalCredential::Facebook
state = rand(999_999_999_999).to_s
{
request_token: state,
#authorize_url: oauth.url_for_oauth_code(permissions: 'publish_pages, manage_pages, user_posts', state: state),
authorize_url: oauth.url_for_oauth_code(permissions: 'publish_pages, manage_pages', state: state),
}
end
@ -30,7 +31,7 @@ class ExternalCredential::Facebook
def self.link_account(_request_token, params)
# fail if request_token.params[:oauth_token] != params[:state]
external_credential = ExternalCredential.find_by(name: 'facebook')
fail 'No such account' if !external_credential
raise 'No such account' if !external_credential
oauth = Koala::Facebook::OAuth.new(
external_credential.credentials['application_id'],
external_credential.credentials['application_secret'],

View file

@ -27,7 +27,7 @@ class ExternalCredential::Twitter
end
def self.link_account(request_token, params)
fail if request_token.params[:oauth_token] != params[:oauth_token]
raise if request_token.params[:oauth_token] != params[:oauth_token]
external_credential = ExternalCredential.find_by(name: 'twitter')
access_token = request_token.get_access_token(oauth_verifier: params[:oauth_verifier])
client = Twitter::REST::Client.new(

View file

@ -309,7 +309,7 @@ result
Rails.logger.debug 'Create feed comment from article...'
post = @client.put_comment(article[:in_reply_to], article[:body])
else
fail "Can't handle unknown facebook article type '#{article[:type]}'."
raise "Can't handle unknown facebook article type '#{article[:type]}'."
end
Rails.logger.debug post.inspect
@client.get_object(post['id'])

View file

@ -23,14 +23,14 @@ module Import::OTRS
def self.request_json(data, data_only = false)
response = post(data)
if !response
fail "Can't connect to Zammad Migrator"
raise "Can't connect to Zammad Migrator"
end
if !response.success?
fail "Can't connect to Zammad Migrator"
raise "Can't connect to Zammad Migrator"
end
result = json(response)
if !result
fail 'Invalid response'
raise 'Invalid response'
end
if data_only
result['Result']
@ -303,12 +303,12 @@ module Import::OTRS
# check if system is in import mode
if !Setting.get('import_mode')
fail 'System is not in import mode!'
raise 'System is not in import mode!'
end
result = request_json({})
if !result['Success']
fail 'API key not valid!'
raise 'API key not valid!'
end
# set settings
@ -495,7 +495,7 @@ module Import::OTRS
# check if system is in import mode
if !Setting.get('import_mode')
fail 'System is not in import mode!'
raise 'System is not in import mode!'
end
# create states

View file

@ -12,7 +12,7 @@ module Import::Zendesk
# check if system is in import mode
if !Setting.get('import_mode')
fail 'System is not in import mode!'
raise 'System is not in import mode!'
end
initialize_client

View file

@ -215,7 +215,7 @@ returns
if force
total = references_total(object_name, object_id_to_merge)
if total > 1000
fail "Can't merge object because object has more then 1000 (#{total}) references, please contact your system administrator."
raise "Can't merge object because object has more then 1000 (#{total}) references, please contact your system administrator."
end
end

View file

@ -98,9 +98,9 @@ class Report::Base
).count
end
fail "UNKOWN params (#{params.inspect})!"
raise "UNKOWN params (#{params.inspect})!"
end
fail "UNKOWN :type (#{params[:type]})!"
raise "UNKOWN :type (#{params[:type]})!"
end
# :object
@ -219,7 +219,7 @@ class Report::Base
ticket_ids: ticket_ids,
}
end
fail "UNKOWN :type (#{data[:type]})!"
raise "UNKOWN :type (#{data[:type]})!"
end
# :type

View file

@ -56,16 +56,16 @@ returns
(1..stop_interval).each {|_counter|
match = false
if !result_es
fail "Invalid es result #{result_es.inspect}"
raise "Invalid es result #{result_es.inspect}"
end
if !result_es['aggregations']
fail "Invalid es result, no aggregations #{result_es.inspect}"
raise "Invalid es result, no aggregations #{result_es.inspect}"
end
if !result_es['aggregations']['time_buckets']
fail "Invalid es result, no time_buckets #{result_es.inspect}"
raise "Invalid es result, no time_buckets #{result_es.inspect}"
end
if !result_es['aggregations']['time_buckets']['buckets']
fail "Invalid es result, no buckets #{result_es.inspect}"
raise "Invalid es result, no buckets #{result_es.inspect}"
end
result_es['aggregations']['time_buckets']['buckets'].each {|item|
if params[:interval] == 'minute'

View file

@ -160,6 +160,6 @@ returns
}
end
end
fail "Unknown selector params '#{selector.inspect}'"
raise "Unknown selector params '#{selector.inspect}'"
end
end

View file

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

View file

@ -59,7 +59,7 @@ create/update/delete index
)
Rails.logger.info "# #{response.code}"
return true if response.success?
fail response.inspect
raise response.inspect
end
=begin
@ -91,7 +91,7 @@ add new object to search index
)
Rails.logger.info "# #{response.code}"
return true if response.success?
fail response.inspect
raise response.inspect
end
=begin
@ -270,7 +270,7 @@ get count of tickets and tickets which match on selector
=end
def self.selectors(index = nil, selectors = nil, limit = 10, current_user = nil, aggs_interval = nil)
fail 'no selectors given' if !selectors
raise 'no selectors given' if !selectors
url = build_url()
return if !url
@ -303,7 +303,7 @@ get count of tickets and tickets which match on selector
Rails.logger.info "# #{response.code}"
if !response.success?
fail "ERROR: #{response.inspect}"
raise "ERROR: #{response.inspect}"
end
Rails.logger.debug response.data.to_json
@ -345,7 +345,7 @@ get count of tickets and tickets which match on selector
elsif data['operator'] == 'contains not'
query_must_not.push t
else
fail "unknown operator '#{data['operator']}'"
raise "unknown operator '#{data['operator']}'"
end
}
end

View file

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

View file

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

View file

@ -1,6 +1,6 @@
class Sessions::Backend::ActivityStream
def initialize( user, client = nil, client_id = nil, ttl = 30 )
def initialize(user, client = nil, client_id = nil, ttl = 25)
@user = user
@client = client
@client_id = client_id
@ -11,7 +11,7 @@ class Sessions::Backend::ActivityStream
def load
# get whole collection
activity_stream = @user.activity_stream( 25 )
activity_stream = @user.activity_stream(25)
if activity_stream && !activity_stream.first
return
end
@ -25,7 +25,7 @@ class Sessions::Backend::ActivityStream
@last_change = activity_stream.first['created_at']
end
@user.activity_stream( 25, true )
@user.activity_stream(25, true)
end
def client_key
@ -35,11 +35,11 @@ class Sessions::Backend::ActivityStream
def push
# check timeout
timeout = Sessions::CacheIn.get( client_key )
timeout = Sessions::CacheIn.get(client_key)
return if timeout
# set new timeout
Sessions::CacheIn.set( client_key, true, { expires_in: @ttl.seconds } )
Sessions::CacheIn.set(client_key, true, { expires_in: @ttl.seconds })
data = load

View file

@ -1,6 +1,6 @@
class Sessions::Backend::Collections
def initialize( user, client, client_id, ttl = 10 )
def initialize(user, client, client_id, ttl = 10)
@user = user
@client = client
@client_id = client_id
@ -28,7 +28,7 @@ class Sessions::Backend::Collections
# load collections to deliver from external files
dir = File.expand_path('../../../../', __FILE__)
files = Dir.glob( "#{dir}/lib/sessions/backend/collections/*.rb" )
files = Dir.glob("#{dir}/lib/sessions/backend/collections/*.rb")
files.each { |file|
file.gsub!("#{dir}/lib/", '')
file.gsub!(/\.rb$/, '')

View file

@ -1,7 +1,7 @@
class Sessions::Backend::Collections::Base
class << self; attr_accessor :model, :roles, :not_roles end
def initialize( user, client, client_id, ttl )
def initialize(user, client, client_id, ttl)
@user = user
@client = client
@client_id = client_id
@ -42,11 +42,11 @@ class Sessions::Backend::Collections::Base
end
# check timeout
timeout = Sessions::CacheIn.get( client_key )
timeout = Sessions::CacheIn.get(client_key)
return if timeout
# set new timeout
Sessions::CacheIn.set( client_key, true, { expires_in: @ttl.seconds } )
Sessions::CacheIn.set(client_key, true, { expires_in: @ttl.seconds })
# check if update has been done
last_change = self.class.model.constantize.latest_change

View file

@ -8,7 +8,7 @@ class Sessions::Backend::Collections::Organization < Sessions::Backend::Collecti
if !@user.role?('Customer')
all = Organization.all
elsif @user.organization_id
all = Organization.where( id: @user.organization_id )
all = Organization.where(id: @user.organization_id)
end
all

View file

@ -2,7 +2,7 @@ require 'rss'
class Sessions::Backend::Rss
def initialize( user, client, client_id, ttl = 30 )
def initialize(user, client, client_id, ttl = 30)
@user = user
@client = client
@ttl = ttl
@ -16,14 +16,14 @@ class Sessions::Backend::Rss
def load
# check timeout
cache = Sessions::CacheIn.get( collection_key )
cache = Sessions::CacheIn.get(collection_key)
return cache if cache
url = 'http://www.heise.de/newsticker/heise-atom.xml'
rss_items = Rss.fetch( url, 8 )
rss_items = Rss.fetch(url, 8)
# set new timeout
Sessions::CacheIn.set( collection_key, rss_items, { expires_in: 1.hour } )
Sessions::CacheIn.set(collection_key, rss_items, { expires_in: 1.hour })
rss_items
end
@ -35,11 +35,11 @@ class Sessions::Backend::Rss
def push
# check timeout
timeout = Sessions::CacheIn.get( client_key )
timeout = Sessions::CacheIn.get(client_key)
return if timeout
# set new timeout
Sessions::CacheIn.set( client_key, true, { expires_in: @ttl.seconds } )
Sessions::CacheIn.set(client_key, true, { expires_in: @ttl.seconds })
data = load

View file

@ -1,5 +1,5 @@
class Sessions::Backend::TicketCreate
def initialize( user, client = nil, client_id = nil, ttl = 30 )
def initialize(user, client = nil, client_id = nil, ttl = 30)
@user = user
@client = client
@client_id = client_id
@ -33,11 +33,11 @@ class Sessions::Backend::TicketCreate
def push
# check timeout
timeout = Sessions::CacheIn.get( client_key )
timeout = Sessions::CacheIn.get(client_key)
return if timeout
# set new timeout
Sessions::CacheIn.set( client_key, true, { expires_in: @ttl.seconds } )
Sessions::CacheIn.set(client_key, true, { expires_in: @ttl.seconds })
data = load

View file

@ -1,5 +1,5 @@
class Sessions::Backend::TicketOverviewIndex
def initialize( user, client = nil, client_id = nil, ttl = 5 )
def initialize(user, client = nil, client_id = nil, ttl = 7)
@user = user
@client = client
@client_id = client_id
@ -34,10 +34,10 @@ class Sessions::Backend::TicketOverviewIndex
def push
# check check interval
return if Sessions::CacheIn.get( client_key )
return if Sessions::CacheIn.get(client_key)
# reset check interval
Sessions::CacheIn.set( client_key, true, { expires_in: @ttl.seconds } )
Sessions::CacheIn.set(client_key, true, { expires_in: @ttl.seconds })
# check if min one ticket has changed
last_ticket_change = Ticket.latest_change

View file

@ -1,5 +1,5 @@
class Sessions::Backend::TicketOverviewList
def initialize( user, client = nil, client_id = nil, ttl = 6 )
def initialize(user, client = nil, client_id = nil, ttl = 7)
@user = user
@client = client
@client_id = client_id
@ -45,10 +45,10 @@ class Sessions::Backend::TicketOverviewList
def push
# check interval
return if Sessions::CacheIn.get( client_key )
return if Sessions::CacheIn.get(client_key)
# reset check interval
Sessions::CacheIn.set( client_key, true, { expires_in: @ttl.seconds } )
Sessions::CacheIn.set(client_key, true, { expires_in: @ttl.seconds })
# check if min one ticket has changed
last_ticket_change = Ticket.latest_change
@ -67,7 +67,7 @@ class Sessions::Backend::TicketOverviewList
assets = {}
overview_data[:ticket_ids].each {|ticket_id|
ticket = Ticket.find( ticket_id )
ticket = Ticket.find(ticket_id)
assets = ticket.assets(assets)
}

View file

@ -20,7 +20,7 @@ returns
data[:content] = Base64.decode64($2)
return data
end
fail "Unable to parse data url: #{data_url.substr(0, 100)}"
raise "Unable to parse data url: #{data_url.substr(0, 100)}"
end
=begin
@ -67,7 +67,7 @@ returns
if list && list[0]
return Store.find( list[0] )
end
fail 'No such raw logo!'
raise 'No such raw logo!'
end
=begin

View file

@ -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|
fail 'Failed test. ' + res.inspect if !ok
raise 'Failed test. ' + res.inspect if !ok
end
}
puts 'All browser tests, elapsed: ' + (Time.zone.now - start).to_s + ' seconds'

View file

@ -18,7 +18,7 @@ class TweetBase
Rails.logger.debug tweet.user.inspect
return tweet.user
else
fail "Unknown tweet type '#{tweet.class}'"
raise "Unknown tweet type '#{tweet.class}'"
end
end
@ -100,6 +100,7 @@ class TweetBase
end
def to_ticket(tweet, user, group_id, channel)
UserInfo.current_user_id = user.id
Rails.logger.debug 'Create ticket from tweet...'
Rails.logger.debug tweet.inspect
@ -119,8 +120,6 @@ class TweetBase
return ticket if ticket
end
UserInfo.current_user_id = user.id
# prepare title
title = tweet.text
if title.length > 80
@ -177,7 +176,7 @@ class TweetBase
end
in_reply_to = tweet.in_reply_to_status_id
else
fail "Unknown tweet type '#{tweet.class}'"
raise "Unknown tweet type '#{tweet.class}'"
end
UserInfo.current_user_id = user.id
@ -233,7 +232,7 @@ class TweetBase
end
to_article(tweet, user, ticket)
else
fail "Unknown tweet type '#{tweet.class}'"
raise "Unknown tweet type '#{tweet.class}'"
end
# execute ticket events
@ -269,7 +268,7 @@ class TweetBase
}
)
else
fail "Can't handle unknown twitter article type '#{article[:type]}'."
raise "Can't handle unknown twitter article type '#{article[:type]}'."
end
Rails.logger.debug tweet.inspect

View file

@ -322,7 +322,7 @@ returns
code: response.code,
)
when Net::HTTPRedirection
fail 'Too many redirections for the original URL, halting.' if count <= 0
raise 'Too many redirections for the original URL, halting.' if count <= 0
url = response['location']
return get(url, params, options, count - 1)
when Net::HTTPOK
@ -351,7 +351,7 @@ returns
)
end
fail "Unable to process http call '#{response.inspect}'"
raise "Unable to process http call '#{response.inspect}'"
end
def self.ftp(uri, options)

View file

@ -9,6 +9,7 @@ if [ "$LEVEL" == '1' ]; then
rm test/browser/agent_organization_profile_test.rb
rm test/browser/agent_ticket_*.rb
rm test/browser/chat_test.rb
rm test/browser/first_steps_test.rb
rm test/browser/keyboard_shortcuts_test.rb
rm test/browser/prefereces_test.rb
rm test/browser/setting_test.rb
@ -25,6 +26,7 @@ elif [ "$LEVEL" == '2' ]; then
rm test/browser/auth_test.rb
rm test/browser/chat_test.rb
rm test/browser/customer_ticket_create_test.rb
rm test/browser/first_steps_test.rb
rm test/browser/form_test.rb
rm test/browser/keyboard_shortcuts_test.rb
rm test/browser/maintenance_*.rb

View file

@ -153,7 +153,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: 'auto wizard login failed')
fail 'auto wizard login failed'
raise 'auto wizard login failed'
end
assert(true, 'auto wizard login ok')
@ -165,7 +165,7 @@ class TestCase < Test::Unit::TestCase
return
end
screenshot(browser: instance, comment: 'login_failed')
fail 'No login box found'
raise 'No login box found'
end
screenshot(browser: instance, comment: 'login')
@ -186,7 +186,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')
fail 'login failed'
raise 'login failed'
end
clues_close(
@ -226,7 +226,7 @@ class TestCase < Test::Unit::TestCase
return
}
screenshot(browser: instance, comment: 'logout_failed')
fail 'no login box found, seems logout was not successfully!'
raise 'no login box found, seems logout was not successfully!'
end
=begin
@ -247,7 +247,7 @@ class TestCase < Test::Unit::TestCase
clues = instance.find_elements(css: '.js-modal--clue .js-close')[0]
if !params[:optional] && !clues
screenshot(browser: instance, comment: 'no_clues')
fail 'Unable to closes clues, no clues found!'
raise 'Unable to closes clues, no clues found!'
end
return if !clues
instance.execute_script("$('.js-modal--clue .js-close').click()")
@ -296,7 +296,7 @@ class TestCase < Test::Unit::TestCase
current_url = instance.current_url
if current_url !~ /#{Regexp.quote(params[:url])}/
screenshot(browser: instance, comment: 'location_check_failed')
fail "url #{current_url} is not matching #{params[:url]}"
raise "url #{current_url} is not matching #{params[:url]}"
end
assert(true, "url #{current_url} is matching #{params[:url]}")
end
@ -412,7 +412,7 @@ class TestCase < Test::Unit::TestCase
if params[:js]
return instance.execute_script(params[:js])
end
fail "Invalid execute params #{params.inspect}"
raise "Invalid execute params #{params.inspect}"
end
=begin
@ -431,7 +431,7 @@ class TestCase < Test::Unit::TestCase
instance = params[:browser] || @browser
if !instance.find_elements(css: params[:css])[0]
screenshot(browser: instance, comment: 'exists_failed')
fail "#{params[:css]} dosn't exist, but should"
raise "#{params[:css]} dosn't exist, but should"
end
true
end
@ -452,7 +452,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')
fail "#{params[:css]} exists but should not"
raise "#{params[:css]} exists but should not"
end
true
end
@ -673,10 +673,10 @@ class TestCase < Test::Unit::TestCase
end
if params[:should_not_match]
if success
fail "should not match '#{params[:value]}' in select list, but is matching"
raise "should not match '#{params[:value]}' in select list, but is matching"
end
elsif !success
fail "not matching '#{params[:value]}' in select list"
raise "not matching '#{params[:value]}' in select list"
end
return true
@ -719,10 +719,10 @@ class TestCase < Test::Unit::TestCase
if match
if params[:should_not_match]
fail "matching '#{params[:value]}' in content '#{text}' but should not!"
raise "matching '#{params[:value]}' in content '#{text}' but should not!"
end
elsif !params[:should_not_match]
fail "not matching '#{params[:value]}' in content '#{text}' but should!"
raise "not matching '#{params[:value]}' in content '#{text}' but should!"
end
sleep 0.8
match
@ -769,7 +769,7 @@ class TestCase < Test::Unit::TestCase
instance.find_elements(css: ".content.active .js-secondaryActionLabel[data-type=#{params[:type]}]")[0].click
return
end
fail "Unknown params for task_type: #{params.inspect}"
raise "Unknown params for task_type: #{params.inspect}"
end
=begin
@ -809,23 +809,23 @@ 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
fail "not matching value '#{params[:value]}' in cookie '#{cookie}'"
raise "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
fail "not matching expires '#{params[:expires]}' in cookie '#{cookie}'"
raise "not matching expires '#{params[:expires]}' in cookie '#{cookie}'"
end
return if !params[:should_not_exist]
fail "cookie with name '#{params[:name]}' should not exist, but exists '#{cookies}'"
raise "cookie with name '#{params[:name]}' should not exist, but exists '#{cookies}'"
}
if params[:should_not_exist]
assert(true, "cookie with name '#{params[:name]}' is not existing")
return
end
fail "not matching name '#{params[:name]}' in cookie '#{cookies}'"
raise "not matching name '#{params[:name]}' in cookie '#{cookies}'"
end
=begin
@ -847,7 +847,7 @@ class TestCase < Test::Unit::TestCase
if title =~ /#{params[:value]}/i
assert(true, "matching '#{params[:value]}' in title '#{title}'")
else
fail "not matching '#{params[:value]}' in title '#{title}'"
raise "not matching '#{params[:value]}' in title '#{title}'"
end
end
@ -880,7 +880,7 @@ class TestCase < Test::Unit::TestCase
if title =~ /#{data[:title]}/i
assert(true, "matching '#{data[:title]}' in title '#{title}'")
else
fail "not matching '#{data[:title]}' in title '#{title}'"
raise "not matching '#{data[:title]}' in title '#{title}'"
end
end
puts "tv #{params.inspect}"
@ -899,16 +899,16 @@ class TestCase < Test::Unit::TestCase
if is_modified
assert(true, "task '#{data[:title]}' is modifed")
elsif !exists
fail "task '#{data[:title]}' not exists, should not modified"
raise "task '#{data[:title]}' not exists, should not modified"
else
fail "task '#{data[:title]}' is not modifed"
raise "task '#{data[:title]}' is not modifed"
end
elsif !is_modified
assert(true, "task '#{data[:title]}' is modifed")
elsif !exists
fail "task '#{data[:title]}' not exists, should be not modified"
raise "task '#{data[:title]}' not exists, should be not modified"
else
fail "task '#{data[:title]}' is modifed, but should not"
raise "task '#{data[:title]}' is modifed, but should not"
end
end
rescue => e
@ -943,7 +943,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')
fail "no task with title '#{data[:title]}' found"
raise "no task with title '#{data[:title]}' found"
end
element.click
true
@ -971,7 +971,7 @@ class TestCase < Test::Unit::TestCase
element = instance.find_elements(partial_link_text: data[:title])[0]
if !element
screenshot(browser: instance, comment: 'close_task_failed')
fail "no task with title '#{data[:title]}' found"
raise "no task with title '#{data[:title]}' found"
end
instance.mouse.move_to(element)
@ -1058,7 +1058,7 @@ class TestCase < Test::Unit::TestCase
sleep 0.5
}
screenshot(browser: instance, comment: 'watch_for_failed')
fail "'#{params[:value]}' found in '#{text}'"
raise "'#{params[:value]}' found in '#{text}'"
end
=begin
@ -1116,7 +1116,7 @@ wait untill text in selector disabppears
sleep 1
}
screenshot(browser: instance, comment: 'disappear_failed')
fail "#{params[:css]}) still exsists"
raise "#{params[:css]}) still exsists"
end
=begin
@ -1310,7 +1310,7 @@ wait untill text in selector disabppears
sleep 1
}
screenshot(browser: instance, comment: 'overview_create_failed')
fail 'overview creation failed'
raise 'overview creation failed'
end
=begin
@ -1348,7 +1348,7 @@ wait untill text in selector disabppears
element = instance.find_elements(css: '.active .newTicket')[0]
if !element
screenshot(browser: instance, comment: 'ticket_create_failed')
fail 'no ticket create screen found!'
raise 'no ticket create screen found!'
end
sleep 1
@ -1448,7 +1448,7 @@ wait untill text in selector disabppears
sleep 1
}
screenshot(browser: instance, comment: 'ticket_create_failed')
fail "ticket creation failed, can't get zoom url (current url is '#{instance.current_url}')"
raise "ticket creation failed, can't get zoom url (current url is '#{instance.current_url}')"
end
=begin
@ -1604,7 +1604,7 @@ wait untill text in selector disabppears
if !found
screenshot(browser: instance, comment: 'ticket_update_discard_message_failed')
fail 'no discard message found'
raise 'no discard message found'
end
end
@ -1633,7 +1633,7 @@ wait untill text in selector disabppears
sleep 1
}
screenshot(browser: instance, comment: 'ticket_update_failed')
fail 'unable to update ticket'
raise 'unable to update ticket'
end
=begin
@ -1662,7 +1662,7 @@ wait untill text in selector disabppears
if title =~ /#{data[:title]}/i
assert(true, "matching '#{data[:title]}' in title '#{title}'")
else
fail "not matching '#{data[:title]}' in title '#{title}'"
raise "not matching '#{data[:title]}' in title '#{title}'"
end
end
@ -1671,7 +1671,7 @@ wait untill text in selector disabppears
if body =~ /#{data[:body]}/i
assert(true, "matching '#{data[:body]}' in body '#{body}'")
else
fail "not matching '#{data[:body]}' in body '#{body}'"
raise "not matching '#{data[:body]}' in body '#{body}'"
end
end
true
@ -1710,7 +1710,7 @@ wait untill text in selector disabppears
number = instance.find_elements(css: '.active .ticketZoom-header .ticket-number')[0].text
if number !~ /#{params[:number]}/
screenshot(browser: instance, comment: 'ticket_open_by_overview_failed')
fail "unable to search/find ticket #{params[:number]}!"
raise "unable to search/find ticket #{params[:number]}!"
end
sleep 1
assert(true, "ticket #{params[:number]} found")
@ -1744,7 +1744,7 @@ wait untill text in selector disabppears
sleep 0.5
text = instance.find_elements(css: '#global-search')[0].attribute('value')
if !text
fail '#global-search is not empty!'
raise '#global-search is not empty!'
end
# search by number again
@ -1760,7 +1760,7 @@ wait untill text in selector disabppears
number = instance.find_elements(css: '.active .ticketZoom-header .ticket-number')[0].text
if number !~ /#{params[:number]}/
screenshot(browser: instance, comment: 'ticket_open_by_search_failed')
fail "unable to search/find ticket #{params[:number]}!"
raise "unable to search/find ticket #{params[:number]}!"
end
sleep 1
true
@ -1794,7 +1794,7 @@ wait untill text in selector disabppears
title = instance.find_elements(css: '.active .ticketZoom-header .ticket-title-update')[0].text
if title !~ /#{params[:title]}/
screenshot(browser: instance, comment: 'ticket_open_by_title_failed')
fail "unable to search/find ticket #{params[:title]}!"
raise "unable to search/find ticket #{params[:title]}!"
end
sleep 1
true
@ -1872,7 +1872,7 @@ wait untill text in selector disabppears
sleep 0.5
text = instance.find_elements(css: '#global-search')[0].attribute('value')
if !text
fail '#global-search is not empty!'
raise '#global-search is not empty!'
end
element = instance.find_elements(css: '#global-search')[0]
element.click
@ -1884,7 +1884,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')
fail "unable to search/find org #{params[:value]}!"
raise "unable to search/find org #{params[:value]}!"
end
assert(true, "org #{params[:value]} found")
sleep 2
@ -1916,7 +1916,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')
fail "unable to search/find user #{params[:value]}!"
raise "unable to search/find user #{params[:value]}!"
end
assert(true, "user #{params[:term]} found")
sleep 2
@ -2025,7 +2025,7 @@ wait untill text in selector disabppears
sleep 1
}
screenshot(browser: instance, comment: 'sla_create_failed')
fail 'sla creation failed'
raise 'sla creation failed'
end
=begin
@ -2074,7 +2074,7 @@ wait untill text in selector disabppears
sleep 1
}
screenshot(browser: instance, comment: 'text_module_create_failed')
fail 'text module creation failed'
raise 'text module creation failed'
end
=begin
@ -2121,7 +2121,7 @@ wait untill text in selector disabppears
sleep 1
}
screenshot(browser: instance, comment: 'signature_create_failed')
fail 'signature creation failed'
raise 'signature creation failed'
end
=begin
@ -2195,7 +2195,7 @@ wait untill text in selector disabppears
return true
}
screenshot(browser: instance, comment: 'group_create_failed')
fail 'group creation failed'
raise 'group creation failed'
end
def quote(string)

View file

@ -5,11 +5,11 @@ class ElasticsearchTest < ActiveSupport::TestCase
# set config
if !ENV['ES_URL']
fail "ERROR: Need ES_URL - hint ES_URL='http://172.0.0.1:9200'"
raise "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'] && !ENV['ES_INDEX_RAND']
fail "ERROR: Need ES_INDEX - hint ES_INDEX='estest.local_zammad'"
raise "ERROR: Need ES_INDEX - hint ES_INDEX='estest.local_zammad'"
end
if ENV['ES_INDEX_RAND']
ENV['ES_INDEX'] = "es_index_#{rand(999_999_999)}"

View file

@ -249,7 +249,7 @@ class EmailHelperTest < ActiveSupport::TestCase
# realtest - test I
if !ENV['EMAILHELPER_MAILBOX_1']
fail "Need EMAILHELPER_MAILBOX_1 as ENV variable like export EMAILHELPER_MAILBOX_1='unittestemailhelper01@znuny.com:somepass'"
raise "Need EMAILHELPER_MAILBOX_1 as ENV variable like export EMAILHELPER_MAILBOX_1='unittestemailhelper01@znuny.com:somepass'"
end
mailbox_user = ENV['EMAILHELPER_MAILBOX_1'].split(':')[0]
mailbox_password = ENV['EMAILHELPER_MAILBOX_1'].split(':')[1]
@ -401,7 +401,7 @@ class EmailHelperTest < ActiveSupport::TestCase
# realtest - test I
if !ENV['EMAILHELPER_MAILBOX_1']
fail "Need EMAILHELPER_MAILBOX_1 as ENV variable like export EMAILHELPER_MAILBOX_1='unittestemailhelper01@znuny.com:somepass'"
raise "Need EMAILHELPER_MAILBOX_1 as ENV variable like export EMAILHELPER_MAILBOX_1='unittestemailhelper01@znuny.com:somepass'"
end
mailbox_user = ENV['EMAILHELPER_MAILBOX_1'].split(':')[0]
mailbox_password = ENV['EMAILHELPER_MAILBOX_1'].split(':')[1]
@ -433,7 +433,7 @@ class EmailHelperTest < ActiveSupport::TestCase
# realtest - test I, with imap
if !ENV['EMAILHELPER_MAILBOX_1']
fail "Need EMAILHELPER_MAILBOX_1 as ENV variable like export EMAILHELPER_MAILBOX_1='unittestemailhelper01@znuny.com:somepass'"
raise "Need EMAILHELPER_MAILBOX_1 as ENV variable like export EMAILHELPER_MAILBOX_1='unittestemailhelper01@znuny.com:somepass'"
end
mailbox_user = ENV['EMAILHELPER_MAILBOX_1'].split(':')[0]
mailbox_password = ENV['EMAILHELPER_MAILBOX_1'].split(':')[1]
@ -448,7 +448,7 @@ class EmailHelperTest < ActiveSupport::TestCase
# realtest - test II, gmail with only pop3
if !ENV['EMAILHELPER_MAILBOX_2']
fail "Need EMAILHELPER_MAILBOX_2 as ENV variable like export EMAILHELPER_MAILBOX_2='hansb36621@gmail.com:somepass'"
raise "Need EMAILHELPER_MAILBOX_2 as ENV variable like export EMAILHELPER_MAILBOX_2='hansb36621@gmail.com:somepass'"
end
mailbox_user = ENV['EMAILHELPER_MAILBOX_2'].split(':')[0]
mailbox_password = ENV['EMAILHELPER_MAILBOX_2'].split(':')[1]
@ -467,7 +467,7 @@ class EmailHelperTest < ActiveSupport::TestCase
# realtest - test I, with imap
if !ENV['EMAILHELPER_MAILBOX_1']
fail "Need EMAILHELPER_MAILBOX_1 as ENV variable like export EMAILHELPER_MAILBOX_1='unittestemailhelper01@znuny.com:somepass'"
raise "Need EMAILHELPER_MAILBOX_1 as ENV variable like export EMAILHELPER_MAILBOX_1='unittestemailhelper01@znuny.com:somepass'"
end
mailbox_user = ENV['EMAILHELPER_MAILBOX_1'].split(':')[0]
mailbox_password = ENV['EMAILHELPER_MAILBOX_1'].split(':')[1]
@ -499,7 +499,7 @@ class EmailHelperTest < ActiveSupport::TestCase
# realtest - test II, gmail with pop3
if !ENV['EMAILHELPER_MAILBOX_2']
fail "Need EMAILHELPER_MAILBOX_2 as ENV variable like export EMAILHELPER_MAILBOX_2='hansb36621@gmail.com:somepass'"
raise "Need EMAILHELPER_MAILBOX_2 as ENV variable like export EMAILHELPER_MAILBOX_2='hansb36621@gmail.com:somepass'"
end
mailbox_user = ENV['EMAILHELPER_MAILBOX_2'].split(':')[0]
mailbox_password = ENV['EMAILHELPER_MAILBOX_2'].split(':')[1]

View file

@ -6,28 +6,28 @@ class FacebookBrowserTest < TestCase
# app config
if !ENV['FACEBOOK_BT_APP_ID']
fail "ERROR: Need FACEBOOK_BT_APP_ID - hint FACEBOOK_BT_APP_ID='1234'"
raise "ERROR: Need FACEBOOK_BT_APP_ID - hint FACEBOOK_BT_APP_ID='1234'"
end
app_id = ENV['FACEBOOK_BT_APP_ID']
if !ENV['FACEBOOK_BT_APP_SECRET']
fail "ERROR: Need FACEBOOK_BT_APP_SECRET - hint FACEBOOK_BT_APP_SECRET='1234'"
raise "ERROR: Need FACEBOOK_BT_APP_SECRET - hint FACEBOOK_BT_APP_SECRET='1234'"
end
app_secret = ENV['FACEBOOK_BT_APP_SECRET']
if !ENV['FACEBOOK_BT_USER_LOGIN']
fail "ERROR: Need FACEBOOK_BT_USER_LOGIN - hint FACEBOOK_BT_USER_LOGIN='1234'"
raise "ERROR: Need FACEBOOK_BT_USER_LOGIN - hint FACEBOOK_BT_USER_LOGIN='1234'"
end
user_login = ENV['FACEBOOK_BT_USER_LOGIN']
if !ENV['FACEBOOK_BT_USER_PW']
fail "ERROR: Need FACEBOOK_BT_USER_PW - hint FACEBOOK_BT_USER_PW='1234'"
raise "ERROR: Need FACEBOOK_BT_USER_PW - hint FACEBOOK_BT_USER_PW='1234'"
end
user_pw = ENV['FACEBOOK_BT_USER_PW']
if !ENV['FACEBOOK_BT_PAGE_ID']
fail "ERROR: Need FACEBOOK_BT_PAGE_ID - hint FACEBOOK_BT_PAGE_ID='1234'"
raise "ERROR: Need FACEBOOK_BT_PAGE_ID - hint FACEBOOK_BT_PAGE_ID='1234'"
end
page_id = ENV['FACEBOOK_BT_PAGE_ID']
if !ENV['FACEBOOK_BT_CUSTOMER']
fail "ERROR: Need FACEBOOK_BT_CUSTOMER - hint FACEBOOK_BT_CUSTOMER='name:1234:access_token'"
raise "ERROR: Need FACEBOOK_BT_CUSTOMER - hint FACEBOOK_BT_CUSTOMER='name:1234:access_token'"
end
customer_name = ENV['FACEBOOK_BT_CUSTOMER'].split(':')[0]
customer_id = ENV['FACEBOOK_BT_CUSTOMER'].split(':')[1]

View file

@ -16,21 +16,21 @@ class FacebookTest < ActiveSupport::TestCase
# account config
if !ENV['FACEBOOK_USER']
fail "ERROR: Need FACEBOOK_USER - hint FACEBOOK_USER='name:1234:access_token'"
raise "ERROR: Need FACEBOOK_USER - hint FACEBOOK_USER='name:1234:access_token'"
end
user_name = ENV['FACEBOOK_USER'].split(':')[0]
user_id = ENV['FACEBOOK_USER'].split(':')[1]
user_access_token = ENV['FACEBOOK_USER'].split(':')[2]
if !ENV['FACEBOOK_PAGE']
fail "ERROR: Need FACEBOOK_PAGE - hint FACEBOOK_PAGE='name:1234:access_token'"
raise "ERROR: Need FACEBOOK_PAGE - hint FACEBOOK_PAGE='name:1234:access_token'"
end
page_name = ENV['FACEBOOK_PAGE'].split(':')[0]
page_id = ENV['FACEBOOK_PAGE'].split(':')[1]
page_access_token = ENV['FACEBOOK_PAGE'].split(':')[2]
if !ENV['FACEBOOK_CUSTOMER']
fail "ERROR: Need FACEBOOK_CUSTOMER - hint FACEBOOK_CUSTOMER='name:1234:access_token'"
raise "ERROR: Need FACEBOOK_CUSTOMER - hint FACEBOOK_CUSTOMER='name:1234:access_token'"
end
customer_name = ENV['FACEBOOK_CUSTOMER'].split(':')[0]
customer_id = ENV['FACEBOOK_CUSTOMER'].split(':')[1]

View file

@ -5,10 +5,10 @@ class OtrsImportBrowserTest < TestCase
def test_import
if !ENV['IMPORT_BT_OTRS_ENDPOINT']
fail "ERROR: Need IMPORT_BT_OTRS_ENDPOINT - hint IMPORT_BT_OTRS_ENDPOINT='http://vz305.demo.znuny.com/otrs/public.pl?Action=ZammadMigrator'"
raise "ERROR: Need IMPORT_BT_OTRS_ENDPOINT - hint IMPORT_BT_OTRS_ENDPOINT='http://vz305.demo.znuny.com/otrs/public.pl?Action=ZammadMigrator'"
end
if !ENV['IMPORT_BT_OTRS_ENDPOINT_KEY']
fail "ERROR: Need IMPORT_BT_OTRS_ENDPOINT_KEY - hint IMPORT_BT_OTRS_ENDPOINT_KEY='01234567899876543210'"
raise "ERROR: Need IMPORT_BT_OTRS_ENDPOINT_KEY - hint IMPORT_BT_OTRS_ENDPOINT_KEY='01234567899876543210'"
end
@browser = browser_instance

View file

@ -4,10 +4,10 @@ require 'integration_test_helper'
class OtrsImportTest < ActiveSupport::TestCase
if !ENV['IMPORT_OTRS_ENDPOINT']
fail "ERROR: Need IMPORT_OTRS_ENDPOINT - hint IMPORT_OTRS_ENDPOINT='http://vz305.demo.znuny.com/otrs/public.pl?Action=ZammadMigrator'"
raise "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']
fail "ERROR: Need IMPORT_OTRS_ENDPOINT_KEY - hint IMPORT_OTRS_ENDPOINT_KEY='01234567899876543210'"
raise "ERROR: Need IMPORT_OTRS_ENDPOINT_KEY - hint IMPORT_OTRS_ENDPOINT_KEY='01234567899876543210'"
end
Setting.set('import_otrs_endpoint', ENV['IMPORT_OTRS_ENDPOINT'])

View file

@ -5,11 +5,11 @@ class ReportTest < ActiveSupport::TestCase
# set config
if !ENV['ES_URL']
fail "ERROR: Need ES_URL - hint ES_URL='http://172.0.0.1:9200'"
raise "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'] && !ENV['ES_INDEX_RAND']
fail "ERROR: Need ES_INDEX - hint ES_INDEX='estest.local_zammad'"
raise "ERROR: Need ES_INDEX - hint ES_INDEX='estest.local_zammad'"
end
if ENV['ES_INDEX_RAND']
ENV['ES_INDEX'] = "es_index_#{rand(999_999_999)}"

View file

@ -6,31 +6,31 @@ class TwitterBrowserTest < TestCase
# app config
if !ENV['TWITTER_BT_CONSUMER_KEY']
fail "ERROR: Need TWITTER_BT_CONSUMER_KEY - hint TWITTER_BT_CONSUMER_KEY='1234'"
raise "ERROR: Need TWITTER_BT_CONSUMER_KEY - hint TWITTER_BT_CONSUMER_KEY='1234'"
end
consumer_key = ENV['TWITTER_BT_CONSUMER_KEY']
if !ENV['TWITTER_BT_CONSUMER_SECRET']
fail "ERROR: Need TWITTER_BT_CONSUMER_SECRET - hint TWITTER_BT_CONSUMER_SECRET='1234'"
raise "ERROR: Need TWITTER_BT_CONSUMER_SECRET - hint TWITTER_BT_CONSUMER_SECRET='1234'"
end
consumer_secret = ENV['TWITTER_BT_CONSUMER_SECRET']
if !ENV['TWITTER_BT_USER_LOGIN']
fail "ERROR: Need TWITTER_BT_USER_LOGIN - hint TWITTER_BT_USER_LOGIN='1234'"
raise "ERROR: Need TWITTER_BT_USER_LOGIN - hint TWITTER_BT_USER_LOGIN='1234'"
end
twitter_user_login = ENV['TWITTER_BT_USER_LOGIN']
if !ENV['TWITTER_BT_USER_PW']
fail "ERROR: Need TWITTER_BT_USER_PW - hint TWITTER_BT_USER_PW='1234'"
raise "ERROR: Need TWITTER_BT_USER_PW - hint TWITTER_BT_USER_PW='1234'"
end
twitter_user_pw = ENV['TWITTER_BT_USER_PW']
if !ENV['TWITTER_BT_CUSTOMER_TOKEN']
fail "ERROR: Need TWITTER_BT_CUSTOMER_TOKEN - hint TWITTER_BT_CUSTOMER_TOKEN='1234'"
raise "ERROR: Need TWITTER_BT_CUSTOMER_TOKEN - hint TWITTER_BT_CUSTOMER_TOKEN='1234'"
end
twitter_customer_token = ENV['TWITTER_BT_CUSTOMER_TOKEN']
if !ENV['TWITTER_BT_CUSTOMER_TOKEN_SECRET']
fail "ERROR: Need TWITTER_BT_CUSTOMER_TOKEN_SECRET - hint TWITTER_BT_CUSTOMER_TOKEN_SECRET='1234'"
raise "ERROR: Need TWITTER_BT_CUSTOMER_TOKEN_SECRET - hint TWITTER_BT_CUSTOMER_TOKEN_SECRET='1234'"
end
twitter_customer_token_secret = ENV['TWITTER_BT_CUSTOMER_TOKEN_SECRET']

View file

@ -17,23 +17,23 @@ class TwitterTest < ActiveSupport::TestCase
# app config
if !ENV['TWITTER_CONSUMER_KEY']
fail "ERROR: Need TWITTER_CONSUMER_KEY - hint TWITTER_CONSUMER_KEY='1234'"
raise "ERROR: Need TWITTER_CONSUMER_KEY - hint TWITTER_CONSUMER_KEY='1234'"
end
if !ENV['TWITTER_CONSUMER_SECRET']
fail "ERROR: Need TWITTER_CONSUMER_SECRET - hint TWITTER_CONSUMER_SECRET='1234'"
raise "ERROR: Need TWITTER_CONSUMER_SECRET - hint TWITTER_CONSUMER_SECRET='1234'"
end
consumer_key = ENV['TWITTER_CONSUMER_KEY']
consumer_secret = ENV['TWITTER_CONSUMER_SECRET']
# armin_theo (is system and is following marion_bauer)
if !ENV['TWITTER_SYSTEM_LOGIN']
fail "ERROR: Need TWITTER_SYSTEM_LOGIN - hint TWITTER_SYSTEM_LOGIN='@system'"
raise "ERROR: Need TWITTER_SYSTEM_LOGIN - hint TWITTER_SYSTEM_LOGIN='@system'"
end
if !ENV['TWITTER_SYSTEM_TOKEN']
fail "ERROR: Need TWITTER_SYSTEM_TOKEN - hint TWITTER_SYSTEM_TOKEN='1234'"
raise "ERROR: Need TWITTER_SYSTEM_TOKEN - hint TWITTER_SYSTEM_TOKEN='1234'"
end
if !ENV['TWITTER_SYSTEM_TOKEN_SECRET']
fail "ERROR: Need TWITTER_SYSTEM_TOKEN_SECRET - hint TWITTER_SYSTEM_TOKEN_SECRET='1234'"
raise "ERROR: Need TWITTER_SYSTEM_TOKEN_SECRET - hint TWITTER_SYSTEM_TOKEN_SECRET='1234'"
end
system_login = ENV['TWITTER_SYSTEM_LOGIN']
system_login_without_at = system_login[1, system_login.length]
@ -42,13 +42,13 @@ class TwitterTest < ActiveSupport::TestCase
# me_bauer (is customer and is following armin_theo)
if !ENV['TWITTER_CUSTOMER_LOGIN']
fail "ERROR: Need CUSTOMER_LOGIN - hint TWITTER_CUSTOMER_LOGIN='@customer'"
raise "ERROR: Need CUSTOMER_LOGIN - hint TWITTER_CUSTOMER_LOGIN='@customer'"
end
if !ENV['TWITTER_CUSTOMER_TOKEN']
fail "ERROR: Need CUSTOMER_TOKEN - hint TWITTER_CUSTOMER_TOKEN='1234'"
raise "ERROR: Need CUSTOMER_TOKEN - hint TWITTER_CUSTOMER_TOKEN='1234'"
end
if !ENV['TWITTER_CUSTOMER_TOKEN_SECRET']
fail "ERROR: Need CUSTOMER_TOKEN_SECRET - hint TWITTER_CUSTOMER_TOKEN_SECRET='1234'"
raise "ERROR: Need CUSTOMER_TOKEN_SECRET - hint TWITTER_CUSTOMER_TOKEN_SECRET='1234'"
end
customer_login = ENV['TWITTER_CUSTOMER_LOGIN']
customer_token = ENV['TWITTER_CUSTOMER_TOKEN']

View file

@ -5,13 +5,13 @@ class ZendeskImportBrowserTest < TestCase
def test_import
if !ENV['IMPORT_BT_ZENDESK_ENDPOINT']
fail "ERROR: Need IMPORT_BT_ZENDESK_ENDPOINT - hint IMPORT_BT_ZENDESK_ENDPOINT='https://example.zendesk.com/' (including trailing slash!)"
raise "ERROR: Need IMPORT_BT_ZENDESK_ENDPOINT - hint IMPORT_BT_ZENDESK_ENDPOINT='https://example.zendesk.com/' (including trailing slash!)"
end
if !ENV['IMPORT_BT_ZENDESK_ENDPOINT_USERNAME']
fail "ERROR: Need IMPORT_BT_ZENDESK_ENDPOINT_USERNAME - hint IMPORT_BT_ZENDESK_ENDPOINT_USERNAME='your@email.com'"
raise "ERROR: Need IMPORT_BT_ZENDESK_ENDPOINT_USERNAME - hint IMPORT_BT_ZENDESK_ENDPOINT_USERNAME='your@email.com'"
end
if !ENV['IMPORT_BT_ZENDESK_ENDPOINT_KEY']
fail "ERROR: Need IMPORT_BT_ZENDESK_ENDPOINT_KEY - hint IMPORT_BT_ZENDESK_ENDPOINT_KEY='XYZ3133723421111'"
raise "ERROR: Need IMPORT_BT_ZENDESK_ENDPOINT_KEY - hint IMPORT_BT_ZENDESK_ENDPOINT_KEY='XYZ3133723421111'"
end
@browser = browser_instance

View file

@ -4,13 +4,13 @@ require 'integration_test_helper'
class ZendeskImportTest < ActiveSupport::TestCase
if !ENV['IMPORT_ZENDESK_ENDPOINT']
fail "ERROR: Need IMPORT_ZENDESK_ENDPOINT - hint IMPORT_ZENDESK_ENDPOINT='https://example.zendesk.com/api/v2'"
raise "ERROR: Need IMPORT_ZENDESK_ENDPOINT - hint IMPORT_ZENDESK_ENDPOINT='https://example.zendesk.com/api/v2'"
end
if !ENV['IMPORT_ZENDESK_ENDPOINT_KEY']
fail "ERROR: Need IMPORT_ZENDESK_ENDPOINT_KEY - hint IMPORT_ZENDESK_ENDPOINT_KEY='01234567899876543210'"
raise "ERROR: Need IMPORT_ZENDESK_ENDPOINT_KEY - hint IMPORT_ZENDESK_ENDPOINT_KEY='01234567899876543210'"
end
if !ENV['IMPORT_ZENDESK_ENDPOINT_USERNAME']
fail "ERROR: Need IMPORT_ZENDESK_ENDPOINT_USERNAME - hint IMPORT_ZENDESK_ENDPOINT_USERNAME='bob.ross@happylittletrees.com'"
raise "ERROR: Need IMPORT_ZENDESK_ENDPOINT_USERNAME - hint IMPORT_ZENDESK_ENDPOINT_USERNAME='bob.ross@happylittletrees.com'"
end
Setting.set('import_zendesk_endpoint', ENV['IMPORT_ZENDESK_ENDPOINT'])