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'] )
|
||||
end
|
||||
end
|
||||
render json: {}, status: :ok
|
||||
render json: {}, status: :ok
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -87,8 +87,8 @@ class Authorization < ApplicationModel
|
|||
|
||||
private
|
||||
|
||||
def delete_user_cache
|
||||
self.user.cache_delete
|
||||
end
|
||||
def delete_user_cache
|
||||
self.user.cache_delete
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -340,35 +340,35 @@ returns:
|
|||
|
||||
private
|
||||
|
||||
def self.set_default_items(object_id, o_id, avatar_id)
|
||||
avatars = Avatar.where(
|
||||
object_lookup_id: object_id,
|
||||
o_id: o_id,
|
||||
).order( 'created_at ASC, id DESC' )
|
||||
avatars.each do |avatar|
|
||||
next if avatar.id == avatar_id
|
||||
avatar.default = false
|
||||
avatar.save!
|
||||
end
|
||||
def self.set_default_items(object_id, o_id, avatar_id)
|
||||
avatars = Avatar.where(
|
||||
object_lookup_id: object_id,
|
||||
o_id: o_id,
|
||||
).order( 'created_at ASC, id DESC' )
|
||||
avatars.each do |avatar|
|
||||
next if avatar.id == avatar_id
|
||||
avatar.default = false
|
||||
avatar.save!
|
||||
end
|
||||
end
|
||||
|
||||
def self.add_init_avatar(object_id, o_id)
|
||||
def self.add_init_avatar(object_id, o_id)
|
||||
|
||||
count = Avatar.where(
|
||||
object_lookup_id: object_id,
|
||||
o_id: o_id,
|
||||
).count
|
||||
return if count > 0
|
||||
count = Avatar.where(
|
||||
object_lookup_id: object_id,
|
||||
o_id: o_id,
|
||||
).count
|
||||
return if count > 0
|
||||
|
||||
Avatar.create(
|
||||
o_id: o_id,
|
||||
object_lookup_id: object_id,
|
||||
default: true,
|
||||
source: 'init',
|
||||
initial: true,
|
||||
deletable: false,
|
||||
updated_by_id: 1,
|
||||
created_by_id: 1,
|
||||
)
|
||||
end
|
||||
Avatar.create(
|
||||
o_id: o_id,
|
||||
object_lookup_id: object_id,
|
||||
default: true,
|
||||
source: 'init',
|
||||
initial: true,
|
||||
deletable: false,
|
||||
updated_by_id: 1,
|
||||
created_by_id: 1,
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -241,150 +241,150 @@ returns
|
|||
end
|
||||
|
||||
private
|
||||
def self.get_http(uri, options)
|
||||
http = Net::HTTP.new(uri.host, uri.port)
|
||||
def self.get_http(uri, options)
|
||||
http = Net::HTTP.new(uri.host, uri.port)
|
||||
|
||||
http.open_timeout = options[:open_timeout] || 4
|
||||
http.read_timeout = options[:read_timeout] || 10
|
||||
http.open_timeout = options[:open_timeout] || 4
|
||||
http.read_timeout = options[:read_timeout] || 10
|
||||
|
||||
if uri.scheme =~ /https/i
|
||||
http.use_ssl = true
|
||||
# @TODO verify_mode should be configurable
|
||||
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
||||
end
|
||||
|
||||
http
|
||||
if uri.scheme =~ /https/i
|
||||
http.use_ssl = true
|
||||
# @TODO verify_mode should be configurable
|
||||
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
||||
end
|
||||
|
||||
def self.set_basic_auth(request, options)
|
||||
http
|
||||
end
|
||||
|
||||
# http basic auth (if needed)
|
||||
if options[:user] && options[:user] != '' && options[:password] && options[:password] != ''
|
||||
request.basic_auth options[:user], options[:password]
|
||||
end
|
||||
request
|
||||
def self.set_basic_auth(request, options)
|
||||
|
||||
# http basic auth (if needed)
|
||||
if options[:user] && options[:user] != '' && options[:password] && options[:password] != ''
|
||||
request.basic_auth options[:user], options[:password]
|
||||
end
|
||||
request
|
||||
end
|
||||
|
||||
def self.set_params(request, params, options)
|
||||
if options[:json]
|
||||
request.add_field('Content-Type', 'application/json')
|
||||
if !params.empty?
|
||||
request.body = params.to_json
|
||||
end
|
||||
else
|
||||
if !params.empty?
|
||||
request.set_form_data( params )
|
||||
end
|
||||
def self.set_params(request, params, options)
|
||||
if options[:json]
|
||||
request.add_field('Content-Type', 'application/json')
|
||||
if !params.empty?
|
||||
request.body = params.to_json
|
||||
end
|
||||
else
|
||||
if !params.empty?
|
||||
request.set_form_data( params )
|
||||
end
|
||||
request
|
||||
end
|
||||
request
|
||||
end
|
||||
|
||||
def self.process(response, uri, count, params, options)
|
||||
if !response
|
||||
return Result.new(
|
||||
error: "Can't connect to #{uri.to_s}, got no response!",
|
||||
success: false,
|
||||
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',
|
||||
def self.process(response, uri, count, params, options)
|
||||
if !response
|
||||
return Result.new(
|
||||
error: "Can't connect to #{uri.to_s}, got no response!",
|
||||
success: false,
|
||||
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
|
||||
|
||||
class Result
|
||||
def initialize(options)
|
||||
@success = options[:success]
|
||||
|
|
|
@ -625,7 +625,7 @@ class TestCase < Test::Unit::TestCase
|
|||
raise "not matching '#{data[:title]}' in title '#{title}'"
|
||||
end
|
||||
end
|
||||
puts "tv #{params.inspect}"
|
||||
puts "tv #{params.inspect}"
|
||||
# verify modified
|
||||
if data.has_key?(:modified)
|
||||
exists = instance.find_elements( { css: '.tasks .active .icon' } )[0]
|
||||
|
|
|
@ -18,7 +18,7 @@ class ExampleTest < Test::Unit::TestCase
|
|||
|
||||
def test_first_page
|
||||
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
|
||||
|
||||
def test_login_failed
|
||||
|
|
|
@ -2169,7 +2169,7 @@ Some Text',
|
|||
elsif !file[:success]
|
||||
if result && result.class == Array && result[1]
|
||||
puts result.inspect
|
||||
assert( false, 'ticket should not be created but is created' )
|
||||
assert( false, 'ticket should not be created but is created' )
|
||||
else
|
||||
assert( true, 'ticket not created - nice' )
|
||||
end
|
||||
|
|
|
@ -719,14 +719,14 @@ class TicketSlaTest < ActiveSupport::TestCase
|
|||
)
|
||||
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.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_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.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_diff_in_min, 210, 'ticket.close_time_diff_in_min# verify 3' )
|
||||
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_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.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_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' )
|
||||
|
||||
delete = sla.destroy
|
||||
assert( delete, 'sla destroy' )
|
||||
|
@ -750,19 +750,19 @@ class TicketSlaTest < ActiveSupport::TestCase
|
|||
assert( ticket, 'ticket created' )
|
||||
|
||||
# state change to open from pending
|
||||
History.add(
|
||||
history_type: 'updated',
|
||||
history_object: 'Ticket',
|
||||
history_attribute: 'state',
|
||||
o_id: ticket.id,
|
||||
id_to: 2,
|
||||
id_from: 3,
|
||||
value_from: 'pending reminder',
|
||||
value_to: 'open',
|
||||
created_by_id: 1,
|
||||
created_at: '2013-06-04 10:30:00 UTC',
|
||||
updated_at: '2013-06-04 10:30:00 UTC',
|
||||
)
|
||||
History.add(
|
||||
history_type: 'updated',
|
||||
history_object: 'Ticket',
|
||||
history_attribute: 'state',
|
||||
o_id: ticket.id,
|
||||
id_to: 2,
|
||||
id_from: 3,
|
||||
value_from: 'pending reminder',
|
||||
value_to: 'open',
|
||||
created_by_id: 1,
|
||||
created_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
|
||||
History.add(
|
||||
|
|
Loading…
Reference in a new issue