Applied rubocop IndentationConsistency.
This commit is contained in:
parent
16ddef38e9
commit
dfc39cc95c
8 changed files with 186 additions and 186 deletions
|
@ -111,7 +111,7 @@ curl http://localhost/api/v1/online_notifications/mark_all_as_read -v -u #{login
|
||||||
OnlineNotification.seen( id: notification['id'] )
|
OnlineNotification.seen( id: notification['id'] )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
render json: {}, status: :ok
|
render json: {}, status: :ok
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -87,8 +87,8 @@ class Authorization < ApplicationModel
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def delete_user_cache
|
def delete_user_cache
|
||||||
self.user.cache_delete
|
self.user.cache_delete
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -340,35 +340,35 @@ returns:
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def self.set_default_items(object_id, o_id, avatar_id)
|
def self.set_default_items(object_id, o_id, avatar_id)
|
||||||
avatars = Avatar.where(
|
avatars = Avatar.where(
|
||||||
object_lookup_id: object_id,
|
object_lookup_id: object_id,
|
||||||
o_id: o_id,
|
o_id: o_id,
|
||||||
).order( 'created_at ASC, id DESC' )
|
).order( 'created_at ASC, id DESC' )
|
||||||
avatars.each do |avatar|
|
avatars.each do |avatar|
|
||||||
next if avatar.id == avatar_id
|
next if avatar.id == avatar_id
|
||||||
avatar.default = false
|
avatar.default = false
|
||||||
avatar.save!
|
avatar.save!
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def self.add_init_avatar(object_id, o_id)
|
def self.add_init_avatar(object_id, o_id)
|
||||||
|
|
||||||
count = Avatar.where(
|
count = Avatar.where(
|
||||||
object_lookup_id: object_id,
|
object_lookup_id: object_id,
|
||||||
o_id: o_id,
|
o_id: o_id,
|
||||||
).count
|
).count
|
||||||
return if count > 0
|
return if count > 0
|
||||||
|
|
||||||
Avatar.create(
|
Avatar.create(
|
||||||
o_id: o_id,
|
o_id: o_id,
|
||||||
object_lookup_id: object_id,
|
object_lookup_id: object_id,
|
||||||
default: true,
|
default: true,
|
||||||
source: 'init',
|
source: 'init',
|
||||||
initial: true,
|
initial: true,
|
||||||
deletable: false,
|
deletable: false,
|
||||||
updated_by_id: 1,
|
updated_by_id: 1,
|
||||||
created_by_id: 1,
|
created_by_id: 1,
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -241,150 +241,150 @@ returns
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def self.get_http(uri, options)
|
def self.get_http(uri, options)
|
||||||
http = Net::HTTP.new(uri.host, uri.port)
|
http = Net::HTTP.new(uri.host, uri.port)
|
||||||
|
|
||||||
http.open_timeout = options[:open_timeout] || 4
|
http.open_timeout = options[:open_timeout] || 4
|
||||||
http.read_timeout = options[:read_timeout] || 10
|
http.read_timeout = options[:read_timeout] || 10
|
||||||
|
|
||||||
if uri.scheme =~ /https/i
|
if uri.scheme =~ /https/i
|
||||||
http.use_ssl = true
|
http.use_ssl = true
|
||||||
# @TODO verify_mode should be configurable
|
# @TODO verify_mode should be configurable
|
||||||
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
||||||
end
|
|
||||||
|
|
||||||
http
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.set_basic_auth(request, options)
|
http
|
||||||
|
end
|
||||||
|
|
||||||
# http basic auth (if needed)
|
def self.set_basic_auth(request, options)
|
||||||
if options[:user] && options[:user] != '' && options[:password] && options[:password] != ''
|
|
||||||
request.basic_auth options[:user], options[:password]
|
# http basic auth (if needed)
|
||||||
end
|
if options[:user] && options[:user] != '' && options[:password] && options[:password] != ''
|
||||||
request
|
request.basic_auth options[:user], options[:password]
|
||||||
end
|
end
|
||||||
|
request
|
||||||
|
end
|
||||||
|
|
||||||
def self.set_params(request, params, options)
|
def self.set_params(request, params, options)
|
||||||
if options[:json]
|
if options[:json]
|
||||||
request.add_field('Content-Type', 'application/json')
|
request.add_field('Content-Type', 'application/json')
|
||||||
if !params.empty?
|
if !params.empty?
|
||||||
request.body = params.to_json
|
request.body = params.to_json
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if !params.empty?
|
if !params.empty?
|
||||||
request.set_form_data( params )
|
request.set_form_data( params )
|
||||||
end
|
|
||||||
end
|
end
|
||||||
request
|
|
||||||
end
|
end
|
||||||
|
request
|
||||||
|
end
|
||||||
|
|
||||||
def self.process(response, uri, count, params, options)
|
def self.process(response, uri, count, params, options)
|
||||||
if !response
|
if !response
|
||||||
return Result.new(
|
return Result.new(
|
||||||
error: "Can't connect to #{uri.to_s}, got no response!",
|
error: "Can't connect to #{uri.to_s}, got no response!",
|
||||||
success: false,
|
success: false,
|
||||||
code: 0,
|
code: 0,
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
case response
|
|
||||||
when Net::HTTPNotFound
|
|
||||||
return Result.new(
|
|
||||||
error: "No such file #{uri.to_s}, 404!",
|
|
||||||
success: false,
|
|
||||||
code: response.code,
|
|
||||||
)
|
|
||||||
when Net::HTTPClientError
|
|
||||||
return Result.new(
|
|
||||||
error: "Client Error: #{response.inspect}!",
|
|
||||||
success: false,
|
|
||||||
code: response.code,
|
|
||||||
)
|
|
||||||
when Net::HTTPInternalServerError
|
|
||||||
return Result.new(
|
|
||||||
error: "Server Error: #{response.inspect}!",
|
|
||||||
success: false,
|
|
||||||
code: response.code,
|
|
||||||
)
|
|
||||||
when Net::HTTPRedirection
|
|
||||||
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
|
|
||||||
data = nil
|
|
||||||
if options[:json] && !options[:jsonParseDisable] && response.body
|
|
||||||
data = JSON.parse( response.body )
|
|
||||||
end
|
|
||||||
return Result.new(
|
|
||||||
data: data,
|
|
||||||
body: response.body,
|
|
||||||
content_type: response['Content-Type'],
|
|
||||||
success: true,
|
|
||||||
code: response.code,
|
|
||||||
)
|
|
||||||
when Net::HTTPCreated
|
|
||||||
data = nil
|
|
||||||
if options[:json] && !options[:jsonParseDisable] && response.body
|
|
||||||
data = JSON.parse( response.body )
|
|
||||||
end
|
|
||||||
return Result.new(
|
|
||||||
data: data,
|
|
||||||
body: response.body,
|
|
||||||
content_type: response['Content-Type'],
|
|
||||||
success: true,
|
|
||||||
code: response.code,
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
raise "Unable to process http call '#{response.inspect}'"
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.ftp(uri, options)
|
|
||||||
host = uri.host
|
|
||||||
filename = File.basename(uri.path)
|
|
||||||
remote_dir = File.dirname(uri.path)
|
|
||||||
|
|
||||||
temp_file = Tempfile.new("download-#{filename}")
|
|
||||||
temp_file.binmode
|
|
||||||
|
|
||||||
begin
|
|
||||||
Net::FTP.open(host) do |ftp|
|
|
||||||
ftp.passive = true
|
|
||||||
if options[:user] && options[:password]
|
|
||||||
ftp.login( options[:user], options[:password] )
|
|
||||||
else
|
|
||||||
ftp.login
|
|
||||||
end
|
|
||||||
ftp.chdir(remote_dir) unless remote_dir == '.'
|
|
||||||
|
|
||||||
begin
|
|
||||||
ftp.getbinaryfile( filename, temp_file )
|
|
||||||
rescue => e
|
|
||||||
return Result.new(
|
|
||||||
error: e.inspect,
|
|
||||||
success: false,
|
|
||||||
code: '550',
|
|
||||||
)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
rescue => e
|
|
||||||
return Result.new(
|
|
||||||
error: e.inspect,
|
|
||||||
success: false,
|
|
||||||
code: 0,
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
contents = temp_file.read
|
|
||||||
temp_file.close
|
|
||||||
Result.new(
|
|
||||||
body: contents,
|
|
||||||
success: true,
|
|
||||||
code: '200',
|
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
case response
|
||||||
|
when Net::HTTPNotFound
|
||||||
|
return Result.new(
|
||||||
|
error: "No such file #{uri.to_s}, 404!",
|
||||||
|
success: false,
|
||||||
|
code: response.code,
|
||||||
|
)
|
||||||
|
when Net::HTTPClientError
|
||||||
|
return Result.new(
|
||||||
|
error: "Client Error: #{response.inspect}!",
|
||||||
|
success: false,
|
||||||
|
code: response.code,
|
||||||
|
)
|
||||||
|
when Net::HTTPInternalServerError
|
||||||
|
return Result.new(
|
||||||
|
error: "Server Error: #{response.inspect}!",
|
||||||
|
success: false,
|
||||||
|
code: response.code,
|
||||||
|
)
|
||||||
|
when Net::HTTPRedirection
|
||||||
|
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
|
||||||
|
data = nil
|
||||||
|
if options[:json] && !options[:jsonParseDisable] && response.body
|
||||||
|
data = JSON.parse( response.body )
|
||||||
|
end
|
||||||
|
return Result.new(
|
||||||
|
data: data,
|
||||||
|
body: response.body,
|
||||||
|
content_type: response['Content-Type'],
|
||||||
|
success: true,
|
||||||
|
code: response.code,
|
||||||
|
)
|
||||||
|
when Net::HTTPCreated
|
||||||
|
data = nil
|
||||||
|
if options[:json] && !options[:jsonParseDisable] && response.body
|
||||||
|
data = JSON.parse( response.body )
|
||||||
|
end
|
||||||
|
return Result.new(
|
||||||
|
data: data,
|
||||||
|
body: response.body,
|
||||||
|
content_type: response['Content-Type'],
|
||||||
|
success: true,
|
||||||
|
code: response.code,
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
raise "Unable to process http call '#{response.inspect}'"
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.ftp(uri, options)
|
||||||
|
host = uri.host
|
||||||
|
filename = File.basename(uri.path)
|
||||||
|
remote_dir = File.dirname(uri.path)
|
||||||
|
|
||||||
|
temp_file = Tempfile.new("download-#{filename}")
|
||||||
|
temp_file.binmode
|
||||||
|
|
||||||
|
begin
|
||||||
|
Net::FTP.open(host) do |ftp|
|
||||||
|
ftp.passive = true
|
||||||
|
if options[:user] && options[:password]
|
||||||
|
ftp.login( options[:user], options[:password] )
|
||||||
|
else
|
||||||
|
ftp.login
|
||||||
|
end
|
||||||
|
ftp.chdir(remote_dir) unless remote_dir == '.'
|
||||||
|
|
||||||
|
begin
|
||||||
|
ftp.getbinaryfile( filename, temp_file )
|
||||||
|
rescue => e
|
||||||
|
return Result.new(
|
||||||
|
error: e.inspect,
|
||||||
|
success: false,
|
||||||
|
code: '550',
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
rescue => e
|
||||||
|
return Result.new(
|
||||||
|
error: e.inspect,
|
||||||
|
success: false,
|
||||||
|
code: 0,
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
contents = temp_file.read
|
||||||
|
temp_file.close
|
||||||
|
Result.new(
|
||||||
|
body: contents,
|
||||||
|
success: true,
|
||||||
|
code: '200',
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
class Result
|
class Result
|
||||||
def initialize(options)
|
def initialize(options)
|
||||||
@success = options[:success]
|
@success = options[:success]
|
||||||
|
|
|
@ -625,7 +625,7 @@ class TestCase < Test::Unit::TestCase
|
||||||
raise "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}"
|
||||||
# verify modified
|
# verify modified
|
||||||
if data.has_key?(:modified)
|
if data.has_key?(:modified)
|
||||||
exists = instance.find_elements( { css: '.tasks .active .icon' } )[0]
|
exists = instance.find_elements( { css: '.tasks .active .icon' } )[0]
|
||||||
|
|
|
@ -18,7 +18,7 @@ class ExampleTest < Test::Unit::TestCase
|
||||||
|
|
||||||
def test_first_page
|
def test_first_page
|
||||||
browser.get 'http://portal.znuny.com/'
|
browser.get 'http://portal.znuny.com/'
|
||||||
assert_equal browser.current_url, 'https://portal.znuny.com/#login'
|
assert_equal browser.current_url, 'https://portal.znuny.com/#login'
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_login_failed
|
def test_login_failed
|
||||||
|
|
|
@ -2169,7 +2169,7 @@ Some Text',
|
||||||
elsif !file[:success]
|
elsif !file[:success]
|
||||||
if result && result.class == Array && result[1]
|
if result && result.class == Array && result[1]
|
||||||
puts result.inspect
|
puts result.inspect
|
||||||
assert( false, 'ticket should not be created but is created' )
|
assert( false, 'ticket should not be created but is created' )
|
||||||
else
|
else
|
||||||
assert( true, 'ticket not created - nice' )
|
assert( true, 'ticket not created - nice' )
|
||||||
end
|
end
|
||||||
|
|
|
@ -719,14 +719,14 @@ class TicketSlaTest < ActiveSupport::TestCase
|
||||||
)
|
)
|
||||||
ticket = Ticket.find(ticket.id)
|
ticket = Ticket.find(ticket.id)
|
||||||
|
|
||||||
assert_equal( ticket.escalation_time.gmtime.to_s, '2013-06-04 13:30:00 UTC', 'ticket.escalation_time verify 1' )
|
assert_equal( ticket.escalation_time.gmtime.to_s, '2013-06-04 13:30:00 UTC', 'ticket.escalation_time verify 1' )
|
||||||
assert_equal( ticket.first_response_escal_date.gmtime.to_s, '2013-06-04 13:30:00 UTC', 'ticket.first_response_escal_date verify 1' )
|
assert_equal( ticket.first_response_escal_date.gmtime.to_s, '2013-06-04 13:30:00 UTC', 'ticket.first_response_escal_date verify 1' )
|
||||||
assert_equal( ticket.first_response_in_min, nil, 'ticket.first_response_in_min verify 3' )
|
assert_equal( ticket.first_response_in_min, nil, 'ticket.first_response_in_min verify 3' )
|
||||||
assert_equal( ticket.first_response_diff_in_min, nil, 'ticket.first_response_diff_in_min verify 3' )
|
assert_equal( ticket.first_response_diff_in_min, nil, 'ticket.first_response_diff_in_min verify 3' )
|
||||||
assert_equal( ticket.update_time_escal_date.gmtime.to_s, '2013-06-04 14:30:00 UTC', 'ticket.update_time_escal_date verify 1' )
|
assert_equal( ticket.update_time_escal_date.gmtime.to_s, '2013-06-04 14:30:00 UTC', 'ticket.update_time_escal_date verify 1' )
|
||||||
assert_equal( ticket.close_time_escal_date.gmtime.to_s, '2013-06-04 15:30:00 UTC', 'ticket.close_time_escal_date verify 1' )
|
assert_equal( ticket.close_time_escal_date.gmtime.to_s, '2013-06-04 15:30:00 UTC', 'ticket.close_time_escal_date verify 1' )
|
||||||
assert_equal( ticket.close_time_in_min, 30, 'ticket.close_time_in_min verify 3' )
|
assert_equal( ticket.close_time_in_min, 30, 'ticket.close_time_in_min verify 3' )
|
||||||
assert_equal( ticket.close_time_diff_in_min, 210, 'ticket.close_time_diff_in_min# verify 3' )
|
assert_equal( ticket.close_time_diff_in_min, 210, 'ticket.close_time_diff_in_min# verify 3' )
|
||||||
|
|
||||||
delete = sla.destroy
|
delete = sla.destroy
|
||||||
assert( delete, 'sla destroy' )
|
assert( delete, 'sla destroy' )
|
||||||
|
@ -750,19 +750,19 @@ class TicketSlaTest < ActiveSupport::TestCase
|
||||||
assert( ticket, 'ticket created' )
|
assert( ticket, 'ticket created' )
|
||||||
|
|
||||||
# state change to open from pending
|
# state change to open from pending
|
||||||
History.add(
|
History.add(
|
||||||
history_type: 'updated',
|
history_type: 'updated',
|
||||||
history_object: 'Ticket',
|
history_object: 'Ticket',
|
||||||
history_attribute: 'state',
|
history_attribute: 'state',
|
||||||
o_id: ticket.id,
|
o_id: ticket.id,
|
||||||
id_to: 2,
|
id_to: 2,
|
||||||
id_from: 3,
|
id_from: 3,
|
||||||
value_from: 'pending reminder',
|
value_from: 'pending reminder',
|
||||||
value_to: 'open',
|
value_to: 'open',
|
||||||
created_by_id: 1,
|
created_by_id: 1,
|
||||||
created_at: '2013-06-04 10:30:00 UTC',
|
created_at: '2013-06-04 10:30:00 UTC',
|
||||||
updated_at: '2013-06-04 10:30:00 UTC',
|
updated_at: '2013-06-04 10:30:00 UTC',
|
||||||
)
|
)
|
||||||
|
|
||||||
# state change to pending from open 11:00
|
# state change to pending from open 11:00
|
||||||
History.add(
|
History.add(
|
||||||
|
|
Loading…
Reference in a new issue