From dfc39cc95c72dbcfd856aa2bf1c527ee4d75dad8 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Mon, 27 Apr 2015 16:56:32 +0200 Subject: [PATCH] Applied rubocop IndentationConsistency. --- .../online_notifications_controller.rb | 2 +- app/models/authorization.rb | 6 +- app/models/avatar.rb | 54 ++-- lib/user_agent.rb | 262 +++++++++--------- test/browser_test_helper.rb | 2 +- test/ui_test.rb | 2 +- test/unit/email_process_test.rb | 2 +- test/unit/ticket_sla_test.rb | 42 +-- 8 files changed, 186 insertions(+), 186 deletions(-) diff --git a/app/controllers/online_notifications_controller.rb b/app/controllers/online_notifications_controller.rb index e1655f387..f3e4b273a 100644 --- a/app/controllers/online_notifications_controller.rb +++ b/app/controllers/online_notifications_controller.rb @@ -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 diff --git a/app/models/authorization.rb b/app/models/authorization.rb index 31c9345d5..95bcfde84 100644 --- a/app/models/authorization.rb +++ b/app/models/authorization.rb @@ -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 diff --git a/app/models/avatar.rb b/app/models/avatar.rb index 7ddaf6111..4e8d8cb96 100644 --- a/app/models/avatar.rb +++ b/app/models/avatar.rb @@ -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 diff --git a/lib/user_agent.rb b/lib/user_agent.rb index a92fed14f..6f3b54b90 100644 --- a/lib/user_agent.rb +++ b/lib/user_agent.rb @@ -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] diff --git a/test/browser_test_helper.rb b/test/browser_test_helper.rb index c9126d3f8..b8d29ccf2 100644 --- a/test/browser_test_helper.rb +++ b/test/browser_test_helper.rb @@ -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] diff --git a/test/ui_test.rb b/test/ui_test.rb index 3f9920c8d..3c0ada201 100644 --- a/test/ui_test.rb +++ b/test/ui_test.rb @@ -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 diff --git a/test/unit/email_process_test.rb b/test/unit/email_process_test.rb index 248f73e51..828d9864c 100644 --- a/test/unit/email_process_test.rb +++ b/test/unit/email_process_test.rb @@ -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 diff --git a/test/unit/ticket_sla_test.rb b/test/unit/ticket_sla_test.rb index 5d39b33dd..76ae0fb0b 100644 --- a/test/unit/ticket_sla_test.rb +++ b/test/unit/ticket_sla_test.rb @@ -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(