Some new rubocop checks.

This commit is contained in:
Martin Edenhofer 2015-04-27 21:56:07 +02:00
parent 1e6dcbee1f
commit 6909430eac
13 changed files with 59 additions and 104 deletions

View file

@ -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,

View file

@ -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',

View file

@ -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(

View file

@ -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

View file

@ -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',

View file

@ -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,

View file

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

View file

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

View file

@ -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

View file

@ -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,

View file

@ -20,7 +20,7 @@ class OtrsImportTest < ActiveSupport::TestCase
http = nil
system_id = nil
fqdn = nil
if ENV['IMPORT_OTRS_ENDPOINT'] =~ /^(http|https):\/\/((.+?)\..+?)\//
if ENV['IMPORT_OTRS_ENDPOINT'] =~ %r{^(http|https)://((.+?)\..+?)/}
http = $1
fqdn = $2
system_id = $3
@ -171,11 +171,11 @@ class OtrsImportTest < ActiveSupport::TestCase
assert_equal( 'agent-2', ticket.owner.login )
assert_equal( 'partner', ticket.customer.login )
assert_equal( 'Partner der betreut', ticket.organization.name )
assert_equal( Time.parse('2014-11-20 22:33:41 +0000').gmtime.to_s, ticket.created_at.to_s )
assert_equal( Time.zone.parse('2014-11-20 22:33:41 +0000').gmtime.to_s, ticket.created_at.to_s )
assert_equal( nil, ticket.close_time )
# check history
# create entry
# - create entry
# ticket is created with state closed
ticket = Ticket.find(729)
@ -186,11 +186,11 @@ class OtrsImportTest < ActiveSupport::TestCase
assert_equal( 'agent-2', ticket.owner.login )
assert_equal( 'jn2', ticket.customer.login )
assert_equal( 'Znuny GmbH', ticket.organization.name )
assert_equal( Time.parse('2014-11-20 23:24:20 +0000').gmtime.to_s, ticket.created_at.to_s )
assert_equal( Time.parse('2014-11-20 23:24:20 +0000').gmtime.to_s, ticket.close_time.to_s )
assert_equal( Time.zone.parse('2014-11-20 23:24:20 +0000').gmtime.to_s, ticket.created_at.to_s )
assert_equal( Time.zone.parse('2014-11-20 23:24:20 +0000').gmtime.to_s, ticket.close_time.to_s )
# check history
# create entry
# - create entry
# ticket is created open and now closed
ticket = Ticket.find(730)
@ -201,11 +201,11 @@ class OtrsImportTest < ActiveSupport::TestCase
assert_equal( 'agent-2', ticket.owner.login )
assert_equal( 'betreuterkunde2', ticket.customer.login )
assert_equal( 'Noch ein betreuter Kunde', ticket.organization.name )
assert_equal( Time.parse('2014-11-21 00:17:40 +0000').gmtime.to_s, ticket.created_at.to_s )
assert_equal( Time.parse('2014-11-21 00:21:08 +0000').gmtime.to_s, ticket.close_time.to_s )
assert_equal( Time.zone.parse('2014-11-21 00:17:40 +0000').gmtime.to_s, ticket.created_at.to_s )
assert_equal( Time.zone.parse('2014-11-21 00:21:08 +0000').gmtime.to_s, ticket.close_time.to_s )
# check history
# create entry
# state change entry
# - create entry
# - state change entry
end
end

View file

@ -1,4 +1,5 @@
# encoding: utf-8
# rubocop:disable UselessAssignment
require 'integration_test_helper'
class TwitterTest < ActiveSupport::TestCase

View file

@ -1,47 +0,0 @@
ENV['RAILS_ENV'] = 'test'
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
require 'test/unit'
require 'rubygems'
require 'selenium-webdriver'
class ExampleTest < Test::Unit::TestCase
attr_reader :browser
def setup
@browser = Selenium::WebDriver.for :chrome
end
def teardown
browser.quit
end
def test_first_page
browser.get 'http://portal.znuny.com/'
assert_equal browser.current_url, 'https://portal.znuny.com/#login'
end
def test_login_failed
browser.get 'http://portal.znuny.com/'
element_username = browser.find_element name: 'username'
element_username.send_keys 'roy@kaldung.de'
element_password = browser.find_element name: 'password'
element_password.send_keys '123456'
element_password.submit
wait = Selenium::WebDriver::Wait.new(timeout: 10) # seconds
wait.until { browser.find_element(id: 'app') }
assert_equal browser.current_url, 'https://portal.znuny.com/#login'
end
def test_login_passed
browser.get 'http://portal.znuny.com/'
element_username = browser.find_element name: 'username'
element_username.send_keys 'roy@kaldung.com'
element_password = browser.find_element name: 'password'
element_password.send_keys '090504'
element_password.submit
wait = Selenium::WebDriver::Wait.new(timeout: 10) # seconds
wait.until { browser.find_element(id: 'app') }
assert_equal browser.current_url, 'https://portal.znuny.com/#ticket_view/my_tickets'
end
end