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 def stats
if !params[:user_id] && !params[:organization_id] 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 end
# permission check # permission 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
fail "No such Role #{data[:role]}" raise "No such Role #{data[:role]}"
end end
role_id = role.id role_id = role.id
end end

View file

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

View file

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

View file

@ -29,7 +29,7 @@ class Channel::Driver::Facebook
access_token = page['access_token'] access_token = page['access_token']
} }
if !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 end
client = Facebook.new(access_token) client = Facebook.new(access_token)
client.from_article(article) client.from_article(article)

View file

@ -184,7 +184,7 @@ returns
def stream def stream
sync = @channel.options['sync'] 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 = {} filter = {}
if sync['search'] if sync['search']
@ -315,7 +315,7 @@ returns
def check_external_credential(options) def check_external_credential(options)
if options[:auth] && options[:auth][:external_credential_id] if options[:auth] && options[:auth][:external_credential_id]
external_credential = ExternalCredential.find_by(id: 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_key] = external_credential.credentials['consumer_key']
options[:auth][:consumer_secret] = external_credential.credentials['consumer_secret'] options[:auth][:consumer_secret] = external_credential.credentials['consumer_secret']
end end

View file

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

View file

@ -12,9 +12,9 @@ class Observer::Ticket::Article::CommunicateEmail::BackgroundJob
# send email # send email
if !ticket.group.email_address_id 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 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 end
channel = ticket.group.email_address.channel channel = ticket.group.email_address.channel

View file

@ -20,15 +20,15 @@ class Observer::Ticket::Article::CommunicateFacebook < ActiveRecord::Observer
return if type['name'] !~ /\Afacebook/ return if type['name'] !~ /\Afacebook/
ticket = Ticket.lookup(id: record.ticket_id) ticket = Ticket.lookup(id: record.ticket_id)
fail "Can't find ticket.preferences for Ticket.find(#{record.ticket_id})" if !ticket.preferences raise "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['channel_id'] for Ticket.find(#{record.ticket_id})" if !ticket.preferences['channel_id']
channel = Channel.lookup(id: 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 # check source object id
ticket = record.ticket ticket = record.ticket
if !ticket.preferences['channel_fb_object_id'] 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 end
# fill in_reply_to # fill in_reply_to

View file

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

View file

@ -38,7 +38,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
fail "No email address found for group '#{ticket.group.name}'" raise "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

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

View file

@ -162,7 +162,7 @@ class Observer::Ticket::Notification::BackgroundJob
elsif @p[:type] == 'escalation_warning' elsif @p[:type] == 'escalation_warning'
template = 'ticket_escalation_warning' template = 'ticket_escalation_warning'
else else
fail "unknown type for notification #{@p[:type]}" raise "unknown type for notification #{@p[:type]}"
end end
NotificationFactory.notification( 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') package = entry.sub(%r{^.*/(.+?)\.szpm$}, '\1')
end end
if package == false 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 end
logger.debug package.inspect logger.debug package.inspect
package 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)) 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)
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 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)
@ -243,10 +243,10 @@ returns
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])
fail "Package '#{meta[:name]}-#{meta[:version]}' already installed!" raise "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])
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
end end
@ -306,7 +306,7 @@ returns
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
fail "No such package '#{package_name}'" raise "No such package '#{package_name}'"
end end
file = _get_bin(package.name, package.version) file = _get_bin(package.name, package.version)
install(string: file, reinstall: true) install(string: file, reinstall: true)
@ -367,7 +367,7 @@ returns
version: version, version: version,
) )
if !package if !package
fail "No such package '#{name}' version '#{version}'" raise "No such package '#{name}' version '#{version}'"
end end
list = Store.list( list = Store.list(
object: 'Package', object: 'Package',
@ -376,10 +376,10 @@ returns
# find file # find file
if !list || !list.first if !list || !list.first
fail "No such file in storage list #{name} #{version}" raise "No such file in storage list #{name} #{version}"
end end
if !list.first.content if !list.first.content
fail "No such file in storage #{name} #{version}" raise "No such file in storage #{name} #{version}"
end end
list.first.content list.first.content
end end
@ -497,7 +497,7 @@ returns
name = $2 name = $2
end end
if !version || !name if !version || !name
fail "Invalid package migration '#{migration}'" raise "Invalid package migration '#{migration}'"
end end
# down # down

View file

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

View file

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

View file

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

View file

@ -18,7 +18,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
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 end
true true
@ -29,7 +29,7 @@ class Store::Provider::File
location = get_location(sha) location = get_location(sha)
Rails.logger.debug "read from fs #{location}" Rails.logger.debug "read from fs #{location}"
if !File.exist?(location) if !File.exist?(location)
fail "ERROR: No such file #{location}" raise "ERROR: No such file #{location}"
end end
data = File.open(location, 'rb') data = File.open(location, '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
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 end
content content
end end

View file

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

View file

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

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
} }
fail "Can't generate new ticket number!" raise "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
fail 'Missing ticket_number setting option' raise 'Missing ticket_number setting option'
end end
adapter = load_adapter(adapter_name) adapter = load_adapter(adapter_name)
if !adapter if !adapter
fail "Can't load ticket_number adapter '#{adapter_name}'" raise "Can't load ticket_number adapter '#{adapter_name}'"
end end
adapter adapter
end end

View file

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

View file

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

View file

@ -44,7 +44,7 @@ dedicated:
read_timeout: 16, 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 translations = Translation.where(locale: locale).all
ActiveRecord::Base.transaction do ActiveRecord::Base.transaction do
@ -120,7 +120,7 @@ push translations to online
read_timeout: 16, 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 # set new translator_key if given
if result.data['translator_key'] if result.data['translator_key']

View file

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

View file

@ -32,7 +32,7 @@ returns
def self.data def self.data
auto_wizard_file_location = file_location 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) ) JSON.parse( File.read(auto_wizard_file_location) )
end end

View file

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

View file

@ -27,7 +27,7 @@ class ExternalCredential::Twitter
end end
def self.link_account(request_token, params) 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') external_credential = ExternalCredential.find_by(name: 'twitter')
access_token = request_token.get_access_token(oauth_verifier: params[:oauth_verifier]) access_token = request_token.get_access_token(oauth_verifier: params[:oauth_verifier])
client = Twitter::REST::Client.new( client = Twitter::REST::Client.new(

View file

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

View file

@ -23,14 +23,14 @@ module Import::OTRS
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
fail "Can't connect to Zammad Migrator" raise "Can't connect to Zammad Migrator"
end end
if !response.success? if !response.success?
fail "Can't connect to Zammad Migrator" raise "Can't connect to Zammad Migrator"
end end
result = json(response) result = json(response)
if !result if !result
fail 'Invalid response' raise 'Invalid response'
end end
if data_only if data_only
result['Result'] result['Result']
@ -303,12 +303,12 @@ 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')
fail 'System is not in import mode!' raise 'System is not in import mode!'
end end
result = request_json({}) result = request_json({})
if !result['Success'] if !result['Success']
fail 'API key not valid!' raise 'API key not valid!'
end end
# set settings # set settings
@ -495,7 +495,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')
fail 'System is not in import mode!' raise 'System is not in import mode!'
end end
# create states # create states

View file

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

View file

@ -215,7 +215,7 @@ returns
if force if force
total = references_total(object_name, object_id_to_merge) total = references_total(object_name, object_id_to_merge)
if total > 1000 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
end end

View file

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

View file

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

View file

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

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?
fail "Can't fetch '#{url}', http code: #{response.code}" raise "Can't fetch '#{url}', http code: #{response.code}"
end end
rss = SimpleRSS.parse response.body rss = SimpleRSS.parse response.body
items = [] items = []

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?
fail response.inspect raise 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?
fail response.inspect raise response.inspect
end end
=begin =begin
@ -270,7 +270,7 @@ get count of tickets and tickets which match on selector
=end =end
def self.selectors(index = nil, selectors = nil, limit = 10, current_user = nil, aggs_interval = nil) 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() url = build_url()
return if !url return if !url
@ -303,7 +303,7 @@ get count of tickets and tickets which match on selector
Rails.logger.info "# #{response.code}" Rails.logger.info "# #{response.code}"
if !response.success? if !response.success?
fail "ERROR: #{response.inspect}" raise "ERROR: #{response.inspect}"
end end
Rails.logger.debug response.data.to_json 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' elsif data['operator'] == 'contains not'
query_must_not.push t query_must_not.push t
else else
fail "unknown operator '#{data['operator']}'" raise "unknown operator '#{data['operator']}'"
end end
} }
end end

View file

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

View file

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

View file

@ -1,6 +1,6 @@
class Sessions::Backend::ActivityStream 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 @user = user
@client = client @client = client
@client_id = client_id @client_id = client_id
@ -11,7 +11,7 @@ class Sessions::Backend::ActivityStream
def load def load
# get whole collection # get whole collection
activity_stream = @user.activity_stream( 25 ) activity_stream = @user.activity_stream(25)
if activity_stream && !activity_stream.first if activity_stream && !activity_stream.first
return return
end end
@ -25,7 +25,7 @@ class Sessions::Backend::ActivityStream
@last_change = activity_stream.first['created_at'] @last_change = activity_stream.first['created_at']
end end
@user.activity_stream( 25, true ) @user.activity_stream(25, true)
end end
def client_key def client_key
@ -35,11 +35,11 @@ class Sessions::Backend::ActivityStream
def push def push
# check timeout # check timeout
timeout = Sessions::CacheIn.get( client_key ) timeout = Sessions::CacheIn.get(client_key)
return if timeout return if timeout
# set new 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 data = load

View file

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

View file

@ -1,7 +1,7 @@
class Sessions::Backend::Collections::Base class Sessions::Backend::Collections::Base
class << self; attr_accessor :model, :roles, :not_roles end 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 @user = user
@client = client @client = client
@client_id = client_id @client_id = client_id
@ -42,11 +42,11 @@ class Sessions::Backend::Collections::Base
end end
# check timeout # check timeout
timeout = Sessions::CacheIn.get( client_key ) timeout = Sessions::CacheIn.get(client_key)
return if timeout return if timeout
# set new 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 # check if update has been done
last_change = self.class.model.constantize.latest_change 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') if !@user.role?('Customer')
all = Organization.all all = Organization.all
elsif @user.organization_id elsif @user.organization_id
all = Organization.where( id: @user.organization_id ) all = Organization.where(id: @user.organization_id)
end end
all all

View file

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

View file

@ -1,5 +1,5 @@
class Sessions::Backend::TicketCreate 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 @user = user
@client = client @client = client
@client_id = client_id @client_id = client_id
@ -33,11 +33,11 @@ class Sessions::Backend::TicketCreate
def push def push
# check timeout # check timeout
timeout = Sessions::CacheIn.get( client_key ) timeout = Sessions::CacheIn.get(client_key)
return if timeout return if timeout
# set new 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 data = load

View file

@ -1,5 +1,5 @@
class Sessions::Backend::TicketOverviewIndex 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 @user = user
@client = client @client = client
@client_id = client_id @client_id = client_id
@ -34,10 +34,10 @@ class Sessions::Backend::TicketOverviewIndex
def push def push
# check check interval # check check interval
return if Sessions::CacheIn.get( client_key ) return if Sessions::CacheIn.get(client_key)
# reset check interval # 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 # check if min one ticket has changed
last_ticket_change = Ticket.latest_change last_ticket_change = Ticket.latest_change

View file

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

View file

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

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|
fail 'Failed test. ' + res.inspect if !ok raise 'Failed test. ' + res.inspect if !ok
end end
} }
puts 'All browser tests, elapsed: ' + (Time.zone.now - start).to_s + ' seconds' 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 Rails.logger.debug tweet.user.inspect
return tweet.user return tweet.user
else else
fail "Unknown tweet type '#{tweet.class}'" raise "Unknown tweet type '#{tweet.class}'"
end end
end end
@ -100,6 +100,7 @@ class TweetBase
end end
def to_ticket(tweet, user, group_id, channel) def to_ticket(tweet, user, group_id, channel)
UserInfo.current_user_id = user.id
Rails.logger.debug 'Create ticket from tweet...' Rails.logger.debug 'Create ticket from tweet...'
Rails.logger.debug tweet.inspect Rails.logger.debug tweet.inspect
@ -119,8 +120,6 @@ class TweetBase
return ticket if ticket return ticket if ticket
end end
UserInfo.current_user_id = user.id
# prepare title # prepare title
title = tweet.text title = tweet.text
if title.length > 80 if title.length > 80
@ -177,7 +176,7 @@ class TweetBase
end end
in_reply_to = tweet.in_reply_to_status_id in_reply_to = tweet.in_reply_to_status_id
else else
fail "Unknown tweet type '#{tweet.class}'" raise "Unknown tweet type '#{tweet.class}'"
end end
UserInfo.current_user_id = user.id UserInfo.current_user_id = user.id
@ -233,7 +232,7 @@ class TweetBase
end end
to_article(tweet, user, ticket) to_article(tweet, user, ticket)
else else
fail "Unknown tweet type '#{tweet.class}'" raise "Unknown tweet type '#{tweet.class}'"
end end
# execute ticket events # execute ticket events
@ -269,7 +268,7 @@ class TweetBase
} }
) )
else else
fail "Can't handle unknown twitter article type '#{article[:type]}'." raise "Can't handle unknown twitter article type '#{article[:type]}'."
end end
Rails.logger.debug tweet.inspect Rails.logger.debug tweet.inspect

View file

@ -322,7 +322,7 @@ returns
code: response.code, code: response.code,
) )
when Net::HTTPRedirection 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'] url = response['location']
return get(url, params, options, count - 1) return get(url, params, options, count - 1)
when Net::HTTPOK when Net::HTTPOK
@ -351,7 +351,7 @@ returns
) )
end end
fail "Unable to process http call '#{response.inspect}'" raise "Unable to process http call '#{response.inspect}'"
end end
def self.ftp(uri, options) 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_organization_profile_test.rb
rm test/browser/agent_ticket_*.rb rm test/browser/agent_ticket_*.rb
rm test/browser/chat_test.rb rm test/browser/chat_test.rb
rm test/browser/first_steps_test.rb
rm test/browser/keyboard_shortcuts_test.rb rm test/browser/keyboard_shortcuts_test.rb
rm test/browser/prefereces_test.rb rm test/browser/prefereces_test.rb
rm test/browser/setting_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/auth_test.rb
rm test/browser/chat_test.rb rm test/browser/chat_test.rb
rm test/browser/customer_ticket_create_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/form_test.rb
rm test/browser/keyboard_shortcuts_test.rb rm test/browser/keyboard_shortcuts_test.rb
rm test/browser/maintenance_*.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') login = instance.find_elements(css: '.user-menu .user a')[0].attribute('title')
if login != params[:username] if login != params[:username]
screenshot(browser: instance, comment: 'auto wizard login failed') screenshot(browser: instance, comment: 'auto wizard login failed')
fail 'auto wizard login failed' raise 'auto wizard login failed'
end end
assert(true, 'auto wizard login ok') assert(true, 'auto wizard login ok')
@ -165,7 +165,7 @@ class TestCase < Test::Unit::TestCase
return return
end end
screenshot(browser: instance, comment: 'login_failed') screenshot(browser: instance, comment: 'login_failed')
fail 'No login box found' raise 'No login box found'
end end
screenshot(browser: instance, comment: 'login') 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') 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')
fail 'login failed' raise 'login failed'
end end
clues_close( clues_close(
@ -226,7 +226,7 @@ class TestCase < Test::Unit::TestCase
return return
} }
screenshot(browser: instance, comment: 'logout_failed') 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 end
=begin =begin
@ -247,7 +247,7 @@ class TestCase < Test::Unit::TestCase
clues = instance.find_elements(css: '.js-modal--clue .js-close')[0] clues = instance.find_elements(css: '.js-modal--clue .js-close')[0]
if !params[:optional] && !clues if !params[:optional] && !clues
screenshot(browser: instance, comment: 'no_clues') screenshot(browser: instance, comment: 'no_clues')
fail 'Unable to closes clues, no clues found!' raise 'Unable to closes clues, no clues found!'
end end
return if !clues return if !clues
instance.execute_script("$('.js-modal--clue .js-close').click()") instance.execute_script("$('.js-modal--clue .js-close').click()")
@ -296,7 +296,7 @@ class TestCase < Test::Unit::TestCase
current_url = instance.current_url current_url = instance.current_url
if current_url !~ /#{Regexp.quote(params[:url])}/ if current_url !~ /#{Regexp.quote(params[:url])}/
screenshot(browser: instance, comment: 'location_check_failed') 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 end
assert(true, "url #{current_url} is matching #{params[:url]}") assert(true, "url #{current_url} is matching #{params[:url]}")
end end
@ -412,7 +412,7 @@ class TestCase < Test::Unit::TestCase
if params[:js] if params[:js]
return instance.execute_script(params[:js]) return instance.execute_script(params[:js])
end end
fail "Invalid execute params #{params.inspect}" raise "Invalid execute params #{params.inspect}"
end end
=begin =begin
@ -431,7 +431,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')
fail "#{params[:css]} dosn't exist, but should" raise "#{params[:css]} dosn't exist, but should"
end end
true true
end end
@ -452,7 +452,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')
fail "#{params[:css]} exists but should not" raise "#{params[:css]} exists but should not"
end end
true true
end end
@ -673,10 +673,10 @@ class TestCase < Test::Unit::TestCase
end end
if params[:should_not_match] if params[:should_not_match]
if success 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 end
elsif !success elsif !success
fail "not matching '#{params[:value]}' in select list" raise "not matching '#{params[:value]}' in select list"
end end
return true return true
@ -719,10 +719,10 @@ class TestCase < Test::Unit::TestCase
if match if match
if params[:should_not_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 end
elsif !params[:should_not_match] 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 end
sleep 0.8 sleep 0.8
match match
@ -769,7 +769,7 @@ class TestCase < Test::Unit::TestCase
instance.find_elements(css: ".content.active .js-secondaryActionLabel[data-type=#{params[:type]}]")[0].click instance.find_elements(css: ".content.active .js-secondaryActionLabel[data-type=#{params[:type]}]")[0].click
return return
end end
fail "Unknown params for task_type: #{params.inspect}" raise "Unknown params for task_type: #{params.inspect}"
end end
=begin =begin
@ -809,23 +809,23 @@ 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
fail "not matching value '#{params[:value]}' in cookie '#{cookie}'" raise "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
fail "not matching expires '#{params[:expires]}' in cookie '#{cookie}'" raise "not matching expires '#{params[:expires]}' in cookie '#{cookie}'"
end end
return if !params[:should_not_exist] 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] if params[:should_not_exist]
assert(true, "cookie with name '#{params[:name]}' is not existing") assert(true, "cookie with name '#{params[:name]}' is not existing")
return return
end end
fail "not matching name '#{params[:name]}' in cookie '#{cookies}'" raise "not matching name '#{params[:name]}' in cookie '#{cookies}'"
end end
=begin =begin
@ -847,7 +847,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
fail "not matching '#{params[:value]}' in title '#{title}'" raise "not matching '#{params[:value]}' in title '#{title}'"
end end
end end
@ -880,7 +880,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
fail "not matching '#{data[:title]}' in title '#{title}'" raise "not matching '#{data[:title]}' in title '#{title}'"
end end
end end
puts "tv #{params.inspect}" puts "tv #{params.inspect}"
@ -899,16 +899,16 @@ 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
fail "task '#{data[:title]}' not exists, should not modified" raise "task '#{data[:title]}' not exists, should not modified"
else else
fail "task '#{data[:title]}' is not modifed" raise "task '#{data[:title]}' is not modifed"
end end
elsif !is_modified elsif !is_modified
assert(true, "task '#{data[:title]}' is modifed") assert(true, "task '#{data[:title]}' is modifed")
elsif !exists elsif !exists
fail "task '#{data[:title]}' not exists, should be not modified" raise "task '#{data[:title]}' not exists, should be not modified"
else else
fail "task '#{data[:title]}' is modifed, but should not" raise "task '#{data[:title]}' is modifed, but should not"
end end
end end
rescue => e rescue => e
@ -943,7 +943,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')
fail "no task with title '#{data[:title]}' found" raise "no task with title '#{data[:title]}' found"
end end
element.click element.click
true true
@ -971,7 +971,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: 'close_task_failed') screenshot(browser: instance, comment: 'close_task_failed')
fail "no task with title '#{data[:title]}' found" raise "no task with title '#{data[:title]}' found"
end end
instance.mouse.move_to(element) instance.mouse.move_to(element)
@ -1058,7 +1058,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')
fail "'#{params[:value]}' found in '#{text}'" raise "'#{params[:value]}' found in '#{text}'"
end end
=begin =begin
@ -1116,7 +1116,7 @@ wait untill text in selector disabppears
sleep 1 sleep 1
} }
screenshot(browser: instance, comment: 'disappear_failed') screenshot(browser: instance, comment: 'disappear_failed')
fail "#{params[:css]}) still exsists" raise "#{params[:css]}) still exsists"
end end
=begin =begin
@ -1310,7 +1310,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')
fail 'overview creation failed' raise 'overview creation failed'
end end
=begin =begin
@ -1348,7 +1348,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')
fail 'no ticket create screen found!' raise 'no ticket create screen found!'
end end
sleep 1 sleep 1
@ -1448,7 +1448,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')
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 end
=begin =begin
@ -1604,7 +1604,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')
fail 'no discard message found' raise 'no discard message found'
end end
end end
@ -1633,7 +1633,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')
fail 'unable to update ticket' raise 'unable to update ticket'
end end
=begin =begin
@ -1662,7 +1662,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
fail "not matching '#{data[:title]}' in title '#{title}'" raise "not matching '#{data[:title]}' in title '#{title}'"
end end
end end
@ -1671,7 +1671,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
fail "not matching '#{data[:body]}' in body '#{body}'" raise "not matching '#{data[:body]}' in body '#{body}'"
end end
end end
true true
@ -1710,7 +1710,7 @@ wait untill text in selector disabppears
number = instance.find_elements(css: '.active .ticketZoom-header .ticket-number')[0].text number = instance.find_elements(css: '.active .ticketZoom-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')
fail "unable to search/find ticket #{params[:number]}!" raise "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")
@ -1744,7 +1744,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
fail '#global-search is not empty!' raise '#global-search is not empty!'
end end
# search by number again # 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 number = instance.find_elements(css: '.active .ticketZoom-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')
fail "unable to search/find ticket #{params[:number]}!" raise "unable to search/find ticket #{params[:number]}!"
end end
sleep 1 sleep 1
true true
@ -1794,7 +1794,7 @@ wait untill text in selector disabppears
title = instance.find_elements(css: '.active .ticketZoom-header .ticket-title-update')[0].text title = instance.find_elements(css: '.active .ticketZoom-header .ticket-title-update')[0].text
if title !~ /#{params[:title]}/ if title !~ /#{params[:title]}/
screenshot(browser: instance, comment: 'ticket_open_by_title_failed') 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 end
sleep 1 sleep 1
true true
@ -1872,7 +1872,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
fail '#global-search is not empty!' raise '#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
@ -1884,7 +1884,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')
fail "unable to search/find org #{params[:value]}!" raise "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
@ -1916,7 +1916,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')
fail "unable to search/find user #{params[:value]}!" raise "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
@ -2025,7 +2025,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')
fail 'sla creation failed' raise 'sla creation failed'
end end
=begin =begin
@ -2074,7 +2074,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')
fail 'text module creation failed' raise 'text module creation failed'
end end
=begin =begin
@ -2121,7 +2121,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')
fail 'signature creation failed' raise 'signature creation failed'
end end
=begin =begin
@ -2195,7 +2195,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')
fail 'group creation failed' raise 'group creation failed'
end end
def quote(string) def quote(string)

View file

@ -5,11 +5,11 @@ class ElasticsearchTest < ActiveSupport::TestCase
# set config # set config
if !ENV['ES_URL'] 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 end
Setting.set('es_url', ENV['ES_URL']) Setting.set('es_url', ENV['ES_URL'])
if !ENV['ES_INDEX'] && !ENV['ES_INDEX_RAND'] 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 end
if ENV['ES_INDEX_RAND'] if ENV['ES_INDEX_RAND']
ENV['ES_INDEX'] = "es_index_#{rand(999_999_999)}" ENV['ES_INDEX'] = "es_index_#{rand(999_999_999)}"

View file

@ -249,7 +249,7 @@ class EmailHelperTest < ActiveSupport::TestCase
# realtest - test I # realtest - test I
if !ENV['EMAILHELPER_MAILBOX_1'] 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 end
mailbox_user = ENV['EMAILHELPER_MAILBOX_1'].split(':')[0] mailbox_user = ENV['EMAILHELPER_MAILBOX_1'].split(':')[0]
mailbox_password = ENV['EMAILHELPER_MAILBOX_1'].split(':')[1] mailbox_password = ENV['EMAILHELPER_MAILBOX_1'].split(':')[1]
@ -401,7 +401,7 @@ class EmailHelperTest < ActiveSupport::TestCase
# realtest - test I # realtest - test I
if !ENV['EMAILHELPER_MAILBOX_1'] 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 end
mailbox_user = ENV['EMAILHELPER_MAILBOX_1'].split(':')[0] mailbox_user = ENV['EMAILHELPER_MAILBOX_1'].split(':')[0]
mailbox_password = ENV['EMAILHELPER_MAILBOX_1'].split(':')[1] mailbox_password = ENV['EMAILHELPER_MAILBOX_1'].split(':')[1]
@ -433,7 +433,7 @@ class EmailHelperTest < ActiveSupport::TestCase
# realtest - test I, with imap # realtest - test I, with imap
if !ENV['EMAILHELPER_MAILBOX_1'] 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 end
mailbox_user = ENV['EMAILHELPER_MAILBOX_1'].split(':')[0] mailbox_user = ENV['EMAILHELPER_MAILBOX_1'].split(':')[0]
mailbox_password = ENV['EMAILHELPER_MAILBOX_1'].split(':')[1] mailbox_password = ENV['EMAILHELPER_MAILBOX_1'].split(':')[1]
@ -448,7 +448,7 @@ class EmailHelperTest < ActiveSupport::TestCase
# realtest - test II, gmail with only pop3 # realtest - test II, gmail with only pop3
if !ENV['EMAILHELPER_MAILBOX_2'] 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 end
mailbox_user = ENV['EMAILHELPER_MAILBOX_2'].split(':')[0] mailbox_user = ENV['EMAILHELPER_MAILBOX_2'].split(':')[0]
mailbox_password = ENV['EMAILHELPER_MAILBOX_2'].split(':')[1] mailbox_password = ENV['EMAILHELPER_MAILBOX_2'].split(':')[1]
@ -467,7 +467,7 @@ class EmailHelperTest < ActiveSupport::TestCase
# realtest - test I, with imap # realtest - test I, with imap
if !ENV['EMAILHELPER_MAILBOX_1'] 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 end
mailbox_user = ENV['EMAILHELPER_MAILBOX_1'].split(':')[0] mailbox_user = ENV['EMAILHELPER_MAILBOX_1'].split(':')[0]
mailbox_password = ENV['EMAILHELPER_MAILBOX_1'].split(':')[1] mailbox_password = ENV['EMAILHELPER_MAILBOX_1'].split(':')[1]
@ -499,7 +499,7 @@ class EmailHelperTest < ActiveSupport::TestCase
# realtest - test II, gmail with pop3 # realtest - test II, gmail with pop3
if !ENV['EMAILHELPER_MAILBOX_2'] 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 end
mailbox_user = ENV['EMAILHELPER_MAILBOX_2'].split(':')[0] mailbox_user = ENV['EMAILHELPER_MAILBOX_2'].split(':')[0]
mailbox_password = ENV['EMAILHELPER_MAILBOX_2'].split(':')[1] mailbox_password = ENV['EMAILHELPER_MAILBOX_2'].split(':')[1]

View file

@ -6,28 +6,28 @@ class FacebookBrowserTest < TestCase
# app config # app config
if !ENV['FACEBOOK_BT_APP_ID'] 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 end
app_id = ENV['FACEBOOK_BT_APP_ID'] app_id = ENV['FACEBOOK_BT_APP_ID']
if !ENV['FACEBOOK_BT_APP_SECRET'] 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 end
app_secret = ENV['FACEBOOK_BT_APP_SECRET'] app_secret = ENV['FACEBOOK_BT_APP_SECRET']
if !ENV['FACEBOOK_BT_USER_LOGIN'] 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 end
user_login = ENV['FACEBOOK_BT_USER_LOGIN'] user_login = ENV['FACEBOOK_BT_USER_LOGIN']
if !ENV['FACEBOOK_BT_USER_PW'] 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 end
user_pw = ENV['FACEBOOK_BT_USER_PW'] user_pw = ENV['FACEBOOK_BT_USER_PW']
if !ENV['FACEBOOK_BT_PAGE_ID'] 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 end
page_id = ENV['FACEBOOK_BT_PAGE_ID'] page_id = ENV['FACEBOOK_BT_PAGE_ID']
if !ENV['FACEBOOK_BT_CUSTOMER'] 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 end
customer_name = ENV['FACEBOOK_BT_CUSTOMER'].split(':')[0] customer_name = ENV['FACEBOOK_BT_CUSTOMER'].split(':')[0]
customer_id = ENV['FACEBOOK_BT_CUSTOMER'].split(':')[1] customer_id = ENV['FACEBOOK_BT_CUSTOMER'].split(':')[1]

View file

@ -16,21 +16,21 @@ class FacebookTest < ActiveSupport::TestCase
# account config # account config
if !ENV['FACEBOOK_USER'] 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 end
user_name = ENV['FACEBOOK_USER'].split(':')[0] user_name = ENV['FACEBOOK_USER'].split(':')[0]
user_id = ENV['FACEBOOK_USER'].split(':')[1] user_id = ENV['FACEBOOK_USER'].split(':')[1]
user_access_token = ENV['FACEBOOK_USER'].split(':')[2] user_access_token = ENV['FACEBOOK_USER'].split(':')[2]
if !ENV['FACEBOOK_PAGE'] 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 end
page_name = ENV['FACEBOOK_PAGE'].split(':')[0] page_name = ENV['FACEBOOK_PAGE'].split(':')[0]
page_id = ENV['FACEBOOK_PAGE'].split(':')[1] page_id = ENV['FACEBOOK_PAGE'].split(':')[1]
page_access_token = ENV['FACEBOOK_PAGE'].split(':')[2] page_access_token = ENV['FACEBOOK_PAGE'].split(':')[2]
if !ENV['FACEBOOK_CUSTOMER'] 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 end
customer_name = ENV['FACEBOOK_CUSTOMER'].split(':')[0] customer_name = ENV['FACEBOOK_CUSTOMER'].split(':')[0]
customer_id = ENV['FACEBOOK_CUSTOMER'].split(':')[1] customer_id = ENV['FACEBOOK_CUSTOMER'].split(':')[1]

View file

@ -5,10 +5,10 @@ class OtrsImportBrowserTest < TestCase
def test_import def test_import
if !ENV['IMPORT_BT_OTRS_ENDPOINT'] 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 end
if !ENV['IMPORT_BT_OTRS_ENDPOINT_KEY'] 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 end
@browser = browser_instance @browser = browser_instance

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']
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 end
if !ENV['IMPORT_OTRS_ENDPOINT_KEY'] 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 end
Setting.set('import_otrs_endpoint', ENV['IMPORT_OTRS_ENDPOINT']) Setting.set('import_otrs_endpoint', ENV['IMPORT_OTRS_ENDPOINT'])

View file

@ -5,11 +5,11 @@ class ReportTest < ActiveSupport::TestCase
# set config # set config
if !ENV['ES_URL'] 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 end
Setting.set('es_url', ENV['ES_URL']) Setting.set('es_url', ENV['ES_URL'])
if !ENV['ES_INDEX'] && !ENV['ES_INDEX_RAND'] 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 end
if ENV['ES_INDEX_RAND'] if ENV['ES_INDEX_RAND']
ENV['ES_INDEX'] = "es_index_#{rand(999_999_999)}" ENV['ES_INDEX'] = "es_index_#{rand(999_999_999)}"

View file

@ -6,31 +6,31 @@ class TwitterBrowserTest < TestCase
# app config # app config
if !ENV['TWITTER_BT_CONSUMER_KEY'] 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 end
consumer_key = ENV['TWITTER_BT_CONSUMER_KEY'] consumer_key = ENV['TWITTER_BT_CONSUMER_KEY']
if !ENV['TWITTER_BT_CONSUMER_SECRET'] 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 end
consumer_secret = ENV['TWITTER_BT_CONSUMER_SECRET'] consumer_secret = ENV['TWITTER_BT_CONSUMER_SECRET']
if !ENV['TWITTER_BT_USER_LOGIN'] 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 end
twitter_user_login = ENV['TWITTER_BT_USER_LOGIN'] twitter_user_login = ENV['TWITTER_BT_USER_LOGIN']
if !ENV['TWITTER_BT_USER_PW'] 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 end
twitter_user_pw = ENV['TWITTER_BT_USER_PW'] twitter_user_pw = ENV['TWITTER_BT_USER_PW']
if !ENV['TWITTER_BT_CUSTOMER_TOKEN'] 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 end
twitter_customer_token = ENV['TWITTER_BT_CUSTOMER_TOKEN'] twitter_customer_token = ENV['TWITTER_BT_CUSTOMER_TOKEN']
if !ENV['TWITTER_BT_CUSTOMER_TOKEN_SECRET'] 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 end
twitter_customer_token_secret = ENV['TWITTER_BT_CUSTOMER_TOKEN_SECRET'] twitter_customer_token_secret = ENV['TWITTER_BT_CUSTOMER_TOKEN_SECRET']

View file

@ -17,23 +17,23 @@ class TwitterTest < ActiveSupport::TestCase
# app config # app config
if !ENV['TWITTER_CONSUMER_KEY'] 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 end
if !ENV['TWITTER_CONSUMER_SECRET'] 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 end
consumer_key = ENV['TWITTER_CONSUMER_KEY'] consumer_key = ENV['TWITTER_CONSUMER_KEY']
consumer_secret = ENV['TWITTER_CONSUMER_SECRET'] consumer_secret = ENV['TWITTER_CONSUMER_SECRET']
# armin_theo (is system and is following marion_bauer) # armin_theo (is system and is following marion_bauer)
if !ENV['TWITTER_SYSTEM_LOGIN'] 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 end
if !ENV['TWITTER_SYSTEM_TOKEN'] 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 end
if !ENV['TWITTER_SYSTEM_TOKEN_SECRET'] 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 end
system_login = ENV['TWITTER_SYSTEM_LOGIN'] system_login = ENV['TWITTER_SYSTEM_LOGIN']
system_login_without_at = system_login[1, system_login.length] 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) # me_bauer (is customer and is following armin_theo)
if !ENV['TWITTER_CUSTOMER_LOGIN'] 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 end
if !ENV['TWITTER_CUSTOMER_TOKEN'] 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 end
if !ENV['TWITTER_CUSTOMER_TOKEN_SECRET'] 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 end
customer_login = ENV['TWITTER_CUSTOMER_LOGIN'] customer_login = ENV['TWITTER_CUSTOMER_LOGIN']
customer_token = ENV['TWITTER_CUSTOMER_TOKEN'] customer_token = ENV['TWITTER_CUSTOMER_TOKEN']

View file

@ -5,13 +5,13 @@ class ZendeskImportBrowserTest < TestCase
def test_import def test_import
if !ENV['IMPORT_BT_ZENDESK_ENDPOINT'] 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 end
if !ENV['IMPORT_BT_ZENDESK_ENDPOINT_USERNAME'] 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 end
if !ENV['IMPORT_BT_ZENDESK_ENDPOINT_KEY'] 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 end
@browser = browser_instance @browser = browser_instance

View file

@ -4,13 +4,13 @@ require 'integration_test_helper'
class ZendeskImportTest < ActiveSupport::TestCase class ZendeskImportTest < ActiveSupport::TestCase
if !ENV['IMPORT_ZENDESK_ENDPOINT'] 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 end
if !ENV['IMPORT_ZENDESK_ENDPOINT_KEY'] 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 end
if !ENV['IMPORT_ZENDESK_ENDPOINT_USERNAME'] 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 end
Setting.set('import_zendesk_endpoint', ENV['IMPORT_ZENDESK_ENDPOINT']) Setting.set('import_zendesk_endpoint', ENV['IMPORT_ZENDESK_ENDPOINT'])