Some new rubocop checks.

This commit is contained in:
Martin Edenhofer 2015-04-27 21:24:14 +02:00
parent 7ff5568b37
commit 03b47edd43
14 changed files with 64 additions and 56 deletions

View file

@ -8,6 +8,11 @@ AllCops:
# https://github.com/bbatsov/rubocop#includingexcluding-files # https://github.com/bbatsov/rubocop#includingexcluding-files
Metrics/LineLength:
Description: 'Limit lines to 80 characters.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#80-character-limits'
Enabled: false
Style/NegatedIf: Style/NegatedIf:
Description: >- Description: >-
Favor unless over if for negative conditions Favor unless over if for negative conditions

View file

@ -36,12 +36,12 @@ class ActivityStreamTest < ActiveSupport::TestCase
}, },
article: { article: {
updated_by_id: current_user.id, updated_by_id: current_user.id,
created_by_id: current_user.id, created_by_id: current_user.id,
type_id: Ticket::Article::Type.lookup( name: 'phone' ).id, type_id: Ticket::Article::Type.lookup( name: 'phone' ).id,
sender_id: Ticket::Article::Sender.lookup( name: 'Customer' ).id, sender_id: Ticket::Article::Sender.lookup( name: 'Customer' ).id,
from: 'Unit Test <unittest@example.com>', from: 'Unit Test <unittest@example.com>',
body: 'Unit Test 123', body: 'Unit Test 123',
internal: false internal: false,
}, },
}, },
update: { update: {
@ -60,8 +60,8 @@ class ActivityStreamTest < ActiveSupport::TestCase
check: [ check: [
{ {
result: true, result: true,
object: 'Ticket', object: 'Ticket',
type: 'updated', type: 'updated',
}, },
{ {
result: true, result: true,
@ -85,9 +85,6 @@ class ActivityStreamTest < ActiveSupport::TestCase
tickets = [] tickets = []
tests.each { |test| tests.each { |test|
ticket = nil
article = nil
ticket = Ticket.create( test[:create][:ticket] ) ticket = Ticket.create( test[:create][:ticket] )
test[:check][0][:o_id] = ticket.id test[:check][0][:o_id] = ticket.id
test[:check][2][:o_id] = ticket.id test[:check][2][:o_id] = ticket.id
@ -378,7 +375,7 @@ class ActivityStreamTest < ActiveSupport::TestCase
activity_stream_list.each { |item| activity_stream_list.each { |item|
check_list += 1 check_list += 1
next if check_list != check_count next if check_list != check_count
# next if match #next if match
#puts '--------' #puts '--------'
#puts item.inspect #puts item.inspect
#puts check_item.inspect #puts check_item.inspect

View file

@ -34,7 +34,7 @@ if user
active: true, active: true,
) )
else else
user = User.create_if_not_exists( User.create_if_not_exists(
login: 'nicole.braun@zammad.org', login: 'nicole.braun@zammad.org',
firstname: 'Nicole', firstname: 'Nicole',
lastname: 'Braun', lastname: 'Braun',

View file

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

View file

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

View file

@ -1,4 +1,5 @@
# encoding: utf-8 # encoding: utf-8
# rubocop:disable PerceivedComplexity, CyclomaticComplexity
require 'test_helper' require 'test_helper'
class HistoryTest < ActiveSupport::TestCase class HistoryTest < ActiveSupport::TestCase
@ -22,12 +23,12 @@ class HistoryTest < ActiveSupport::TestCase
}, },
article: { article: {
updated_by_id: current_user.id, updated_by_id: current_user.id,
created_by_id: current_user.id, created_by_id: current_user.id,
type_id: Ticket::Article::Type.lookup( name: 'phone' ).id, type_id: Ticket::Article::Type.lookup( name: 'phone' ).id,
sender_id: Ticket::Article::Sender.lookup( name: 'Customer' ).id, sender_id: Ticket::Article::Sender.lookup( name: 'Customer' ).id,
from: 'Unit Test <unittest@example.com>', from: 'Unit Test <unittest@example.com>',
body: 'Unit Test 123', body: 'Unit Test 123',
internal: false internal: false,
}, },
}, },
ticket_update: { ticket_update: {
@ -89,12 +90,12 @@ class HistoryTest < ActiveSupport::TestCase
}, },
article: { article: {
created_by_id: current_user.id, created_by_id: current_user.id,
updated_by_id: current_user.id, updated_by_id: current_user.id,
type_id: Ticket::Article::Type.lookup(name: 'phone' ).id, type_id: Ticket::Article::Type.lookup(name: 'phone' ).id,
sender_id: Ticket::Article::Sender.lookup(name: 'Customer' ).id, sender_id: Ticket::Article::Sender.lookup(name: 'Customer' ).id,
from: 'Unit Test <unittest@example.com>', from: 'Unit Test <unittest@example.com>',
body: 'Unit Test 123', body: 'Unit Test 123',
internal: false internal: false,
}, },
}, },
ticket_update: { ticket_update: {
@ -213,8 +214,9 @@ class HistoryTest < ActiveSupport::TestCase
user: { user: {
firstname: 'Bob', firstname: 'Bob',
lastname: 'Master', lastname: 'Master',
email: 'master@example.com', }, email: 'master@example.com',
active: false, active: false,
},
}, },
history_check: [ history_check: [
{ {
@ -354,16 +356,10 @@ class HistoryTest < ActiveSupport::TestCase
end end
def history_check( history_list, history_check ) def history_check( history_list, history_check )
# puts history_list.inspect
history_check.each { |check_item| history_check.each { |check_item|
# puts '+++++++++++'
# puts check_item.inspect
match = false match = false
history_list.each { |history_item| history_list.each { |history_item|
next if match next if match
# puts '--------'
# puts history_item.inspect
# puts history_item.history_object.name
next if history_item['object'] != check_item[:history_object] next if history_item['object'] != check_item[:history_object]
next if history_item['type'] != check_item[:history_type] next if history_item['type'] != check_item[:history_type]
if check_item[:history_attribute] if check_item[:history_attribute]

View file

@ -1,4 +1,5 @@
# encoding: utf-8 # encoding: utf-8
# rubocop:disable Next, UselessAssignment, BlockNesting
require 'test_helper' require 'test_helper'
class OnlineNotificationTest < ActiveSupport::TestCase class OnlineNotificationTest < ActiveSupport::TestCase
@ -73,14 +74,14 @@ class OnlineNotificationTest < ActiveSupport::TestCase
check: [ check: [
{ {
type: 'create', type: 'create',
object: 'Ticket', object: 'Ticket',
created_by_id: agent_user1.id, created_by_id: agent_user1.id,
}, },
{ {
type: 'update', type: 'update',
object: 'Ticket', object: 'Ticket',
created_by_id: customer_user.id, created_by_id: customer_user.id,
}, },
], ],
}, },
@ -124,14 +125,14 @@ class OnlineNotificationTest < ActiveSupport::TestCase
check: [ check: [
{ {
type: 'create', type: 'create',
object: 'Ticket', object: 'Ticket',
created_by_id: agent_user1.id, created_by_id: agent_user1.id,
}, },
{ {
type: 'update', type: 'update',
object: 'Ticket', object: 'Ticket',
created_by_id: customer_user.id, created_by_id: customer_user.id,
}, },
], ],
}, },
@ -175,14 +176,14 @@ class OnlineNotificationTest < ActiveSupport::TestCase
check: [ check: [
{ {
type: 'create', type: 'create',
object: 'Ticket', object: 'Ticket',
created_by_id: agent_user1.id, created_by_id: agent_user1.id,
}, },
{ {
type: 'update', type: 'update',
object: 'Ticket', object: 'Ticket',
created_by_id: customer_user.id, created_by_id: customer_user.id,
}, },
], ],
}, },
@ -226,14 +227,14 @@ class OnlineNotificationTest < ActiveSupport::TestCase
check: [ check: [
{ {
type: 'create', type: 'create',
object: 'Ticket', object: 'Ticket',
created_by_id: agent_user1.id, created_by_id: agent_user1.id,
}, },
{ {
type: 'update', type: 'update',
object: 'Ticket', object: 'Ticket',
created_by_id: customer_user.id, created_by_id: customer_user.id,
}, },
], ],
}, },
] ]

View file

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

View file

@ -1,4 +1,5 @@
# encoding: utf-8 # encoding: utf-8
# rubocop:disable UselessAssignment
require 'test_helper' require 'test_helper'
class RestTest < ActiveSupport::TestCase class RestTest < ActiveSupport::TestCase
@ -239,6 +240,6 @@ class RestTest < ActiveSupport::TestCase
#puts 'URL: ' + url #puts 'URL: ' + url
#puts response.code.to_s #puts response.code.to_s
#puts response.body.to_s #puts response.body.to_s
return { data: response.data, response: response } { data: response.data, response: response }
end end
end end

View file

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

View file

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

View file

@ -1,4 +1,5 @@
# encoding: utf-8 # encoding: utf-8
# rubocop:disable Next, CyclomaticComplexity
require 'test_helper' require 'test_helper'
class SessionCollectionsTest < ActiveSupport::TestCase class SessionCollectionsTest < ActiveSupport::TestCase

View file

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

View file

@ -1,4 +1,5 @@
# encoding: utf-8 # encoding: utf-8
# rubocop:disable Next
require 'test_helper' require 'test_helper'
class TokenTest < ActiveSupport::TestCase class TokenTest < ActiveSupport::TestCase