Browse Source

Some new rubocop checks.

Martin Edenhofer 10 years ago
parent
commit
6909430eac

+ 8 - 8
test/browser/aaa_getting_started_test.rb

@@ -167,9 +167,9 @@ class AaaGettingStartedTest < TestCase
     #return # TODO: temp disable
     accounts = []
     (1..10).each {|count|
-      next if !ENV["MAILBOX_AUTO#{count.to_s}"]
-      mailbox_user     = ENV["MAILBOX_AUTO#{count.to_s}"].split(':')[0]
-      mailbox_password = ENV["MAILBOX_AUTO#{count.to_s}"].split(':')[1]
+      next if !ENV["MAILBOX_AUTO#{count}"]
+      mailbox_user     = ENV["MAILBOX_AUTO#{count}"].split(':')[0]
+      mailbox_password = ENV["MAILBOX_AUTO#{count}"].split(':')[1]
       account = {
         realname: 'auto account',
         email: mailbox_user,
@@ -230,11 +230,11 @@ class AaaGettingStartedTest < TestCase
     #return # TODO: temp disable
     accounts = []
     (1..10).each {|count|
-      next if !ENV["MAILBOX_MANUAL#{count.to_s}"]
-      mailbox_user     = ENV["MAILBOX_MANUAL#{count.to_s}"].split(':')[0]
-      mailbox_password = ENV["MAILBOX_MANUAL#{count.to_s}"].split(':')[1]
-      mailbox_inbound  = ENV["MAILBOX_MANUAL#{count.to_s}"].split(':')[2]
-      mailbox_outbound = ENV["MAILBOX_MANUAL#{count.to_s}"].split(':')[3]
+      next if !ENV["MAILBOX_MANUAL#{count}"]
+      mailbox_user     = ENV["MAILBOX_MANUAL#{count}"].split(':')[0]
+      mailbox_password = ENV["MAILBOX_MANUAL#{count}"].split(':')[1]
+      mailbox_inbound  = ENV["MAILBOX_MANUAL#{count}"].split(':')[2]
+      mailbox_outbound = ENV["MAILBOX_MANUAL#{count}"].split(':')[3]
       account = {
         realname: 'manual account',
         email: mailbox_user,

+ 2 - 2
test/browser/agent_ticket_actions_level1_test.rb

@@ -34,7 +34,7 @@ class AgentTicketActionLevel1Test < TestCase
     tasks_close_all()
 
     # create second ticket to merge
-    ticket2 = ticket_create(
+    ticket_create(
       data: {
         customer: 'nico',
         group: 'Users',
@@ -103,7 +103,7 @@ class AgentTicketActionLevel1Test < TestCase
       },
     )
 
-    ticket4 = ticket_create(
+    ticket_create(
       data: {
         customer: 'nico',
         group: 'Users',

+ 0 - 1
test/browser/agent_ticket_actions_level2_test.rb

@@ -5,7 +5,6 @@ class AgentTicketActionsLevel2Test < TestCase
   def test_work_with_two_browser_on_same_ticket
 
     # work on one ticket with two browsers
-    message = 'message 1äöüß ' + rand(99_999_999_999_999_999).to_s
 
     browser1 = browser_instance
     login(

+ 1 - 1
test/browser/agent_ticket_actions_level4_test.rb

@@ -66,7 +66,7 @@ class AgentTicketActionLevel4Test < TestCase
     )
 
     ticket_id = nil
-    if @browser.current_url =~ /ticket\/zoom\/(.+?)$/i
+    if @browser.current_url =~ %r{ticket/zoom/(.+?)$}i
       ticket_id = $1
     end
 

+ 1 - 1
test/browser/agent_ticket_overview_level0_test.rb

@@ -2,7 +2,7 @@
 require 'browser_test_helper'
 
 class AgentTicketOverviewLevel0Test < TestCase
-  def test_I
+  def test_i
     @browser = browser_instance
     login(
       username: 'master@example.com',

+ 2 - 2
test/browser/agent_ticket_overview_level1_test.rb

@@ -2,7 +2,7 @@
 require 'browser_test_helper'
 
 class AgentTicketOverviewLevel1Test < TestCase
-  def test_I
+  def test_i
     name = 'name-' + rand(999_999).to_s
 
     browser1 = browser_instance
@@ -24,7 +24,7 @@ class AgentTicketOverviewLevel1Test < TestCase
     tasks_close_all( browser: browser2 )
 
     # create new overview
-    overview = overview_create(
+    overview_create(
       browser: browser1,
       data: {
         :name              => name,

+ 1 - 0
test/browser/chat_test.rb

@@ -1,4 +1,5 @@
 # encoding: utf-8
+# rubocop:disable all
 require 'browser_test_helper'
 
 class ChatTest < TestCase

+ 1 - 1
test/browser/prefereces_test.rb

@@ -23,7 +23,7 @@ class PreferencesTest < TestCase
     )
 
     # start ticket zoom
-    ticket = ticket_create(
+    ticket_create(
       data: {
         customer: 'nicole',
         group: 'Users',

+ 17 - 17
test/browser_test_helper.rb

@@ -1,4 +1,5 @@
 ENV['RAILS_ENV'] = 'test'
+# rubocop:disable Next, CyclomaticComplexity, PerceivedComplexity
 require File.expand_path('../../config/environment', __FILE__)
 require 'selenium-webdriver'
 
@@ -12,7 +13,7 @@ class TestCase < Test::Unit::TestCase
     if browser =~ /(internet_explorer|ie)/i
       return false
     end
-    return true
+    true
   end
 
   def browser_url
@@ -44,7 +45,7 @@ class TestCase < Test::Unit::TestCase
     )
     browser_instance_preferences(local_browser)
     @browsers[local_browser.hash] = local_browser
-    return local_browser
+    local_browser
   end
 
   def browser_instance_close(local_browser)
@@ -548,19 +549,19 @@ class TestCase < Test::Unit::TestCase
       #puts "CCC #{cookie.inspect}"
       # :name=>"_zammad_session_c25832f4de2", :value=>"adc31cd21615cb0a7ab269184ec8b76f", :path=>"/", :domain=>"localhost", :expires=>nil, :secure=>false}
       if cookie[:name] =~ /#{params[:name]}/i
-        if params.has_key?( :value ) && cookie[:value].to_s =~ /#{params[:value]}/i
-          assert( true, "matching value '#{params[:value]}' in cookie '#{cookie.to_s}'" )
+        if params.key?( :value ) && cookie[:value].to_s =~ /#{params[:value]}/i
+          assert( true, "matching value '#{params[:value]}' in cookie '#{cookie}'" )
         else
-          raise "not matching value '#{params[:value]}' in cookie '#{cookie.to_s}'"
+          raise "not matching value '#{params[:value]}' in cookie '#{cookie}'"
         end
-        if params.has_key?( :expires ) && cookie[:expires].to_s =~ /#{params[:expires]}/i
-          assert( true, "matching expires '#{params[:expires].inspect}' in cookie '#{cookie.to_s}'" )
+        if params.key?( :expires ) && cookie[:expires].to_s =~ /#{params[:expires]}/i
+          assert( true, "matching expires '#{params[:expires].inspect}' in cookie '#{cookie}'" )
         else
-          raise "not matching expires '#{params[:expires]}' in cookie '#{cookie.to_s}'"
+          raise "not matching expires '#{params[:expires]}' in cookie '#{cookie}'"
         end
 
         if params[:should_not_exist]
-          raise "cookie with name '#{params[:name]}' should not exist, but exists '#{cookies.to_s}'"
+          raise "cookie with name '#{params[:name]}' should not exist, but exists '#{cookies}'"
         end
         return
       end
@@ -569,7 +570,7 @@ class TestCase < Test::Unit::TestCase
       assert( true, "cookie with name '#{params[:name]}' is not existing" )
       return
     end
-    raise "not matching name '#{params[:name]}' in cookie '#{cookies.to_s}'"
+    raise "not matching name '#{params[:name]}' in cookie '#{cookies}'"
   end
 
 =begin
@@ -627,7 +628,7 @@ class TestCase < Test::Unit::TestCase
       end
       puts "tv #{params.inspect}"
       # verify modified
-      if data.has_key?(:modified)
+      if data.key?(:modified)
         exists      = instance.find_elements( { css: '.tasks .active .icon' } )[0]
         is_modified = instance.find_elements( { css: '.tasks .active .icon.modified' } )[0]
         puts "m #{data[:modified].inspect}"
@@ -1293,7 +1294,7 @@ wait untill text in selector disabppears
     sleep 1
     instance.find_elements( { css: ".content.active .sidebar a[href=\"#{params[:link]}\"]" } )[0].click
     sleep 1
-    element = instance.find_elements( { partial_link_text: params[:number] } )[0].click
+    instance.find_elements( { partial_link_text: params[:number] } )[0].click
     sleep 1
     number = instance.find_elements( { css: '.active .page-header .ticket-number' } )[0].text
     if number !~ /#{params[:number]}/
@@ -1341,7 +1342,7 @@ wait untill text in selector disabppears
     sleep 1
 
     # open ticket
-    element = instance.find_element( { partial_link_text: params[:number] } ).click
+    instance.find_element( { partial_link_text: params[:number] } ).click
     number = instance.find_elements( { css: '.active .page-header .ticket-number' } )[0].text
     if number !~ /#{params[:number]}/
       raise "unable to search/find ticket #{params[:number]}!"
@@ -1416,11 +1417,10 @@ wait untill text in selector disabppears
     element.clear
     element.send_keys( params[:value] )
     sleep 2
-    element = instance.find_element( { partial_link_text: params[:value] } ).click
+    instance.find_element( { partial_link_text: params[:value] } ).click
     name = instance.find_elements( { css: '.active h1' } )[0].text
     if name !~ /#{params[:value]}/
       raise "unable to search/find org #{params[:value]}!"
-      return
     end
     assert( true, "org #{params[:value]} found" )
     sleep 2
@@ -1446,7 +1446,7 @@ wait untill text in selector disabppears
     element.clear
     element.send_keys( params[:value] )
     sleep 3
-    element = instance.find_element( { partial_link_text: params[:value] } ).click
+    instance.find_element( { partial_link_text: params[:value] } ).click
     name = instance.find_elements( { css: '.active h1' } )[0].text
     if name !~ /#{params[:value]}/
       raise "unable to search/find user #{params[:value]}!"
@@ -1726,6 +1726,6 @@ wait untill text in selector disabppears
 
   def log(method, params)
     return if !@@debug
-    puts "#{Time.now.to_s}/#{method}: #{params.inspect}"
+    puts "#{Time.zone.now}/#{method}: #{params.inspect}"
   end
 end

+ 5 - 4
test/integration/elasticsearch_test.rb

@@ -1,4 +1,5 @@
 # encoding: utf-8
+# rubocop:disable UselessAssignment
 require 'integration_test_helper'
 
 class ElasticsearchTest < ActiveSupport::TestCase
@@ -121,7 +122,7 @@ class ElasticsearchTest < ActiveSupport::TestCase
     Store.add(
       object: 'Ticket::Article',
       o_id: article1.id,
-      data: File.open("#{Rails.root.to_s}/test/fixtures/es-normal.txt", 'rb') { |file| file.read },
+      data: File.open("#{Rails.root}/test/fixtures/es-normal.txt", 'rb') { |file| file.read },
       filename: 'es-normal.txt',
       preferences: {},
       created_by_id: 1,
@@ -132,7 +133,7 @@ class ElasticsearchTest < ActiveSupport::TestCase
     Store.add(
       object: 'Ticket::Article',
       o_id: article1.id,
-      data: File.open("#{Rails.root.to_s}/test/fixtures/es-pdf1.pdf", 'rb') { |file| file.read },
+      data: File.open("#{Rails.root}/test/fixtures/es-pdf1.pdf", 'rb') { |file| file.read },
       filename: 'es-pdf1.pdf',
       preferences: {},
       created_by_id: 1,
@@ -143,7 +144,7 @@ class ElasticsearchTest < ActiveSupport::TestCase
     Store.add(
       object: 'Ticket::Article',
       o_id: article1.id,
-      data: File.open("#{Rails.root.to_s}/test/fixtures/es-box1.box", 'rb') { |file| file.read },
+      data: File.open("#{Rails.root}/test/fixtures/es-box1.box", 'rb') { |file| file.read },
       filename: 'mail1.box',
       preferences: {},
       created_by_id: 1,
@@ -154,7 +155,7 @@ class ElasticsearchTest < ActiveSupport::TestCase
     Store.add(
       object: 'Ticket::Article',
       o_id: article1.id,
-      data: File.open("#{Rails.root.to_s}/test/fixtures/es-too-big.txt", 'rb') { |file| file.read },
+      data: File.open("#{Rails.root}/test/fixtures/es-too-big.txt", 'rb') { |file| file.read },
       filename: 'es-too-big.txt',
       preferences: {},
       created_by_id: 1,

Some files were not shown because too many files changed in this diff