diff --git a/.rubocop.yml b/.rubocop.yml index 7867f0f89..7c544b31b 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -8,6 +8,11 @@ AllCops: # 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: Description: >- Favor unless over if for negative conditions @@ -196,4 +201,4 @@ Metrics/AbcSize: Description: >- A calculated magnitude based on number of assignments, branches, and conditions. - Enabled: false \ No newline at end of file + Enabled: false diff --git a/test/unit/activity_stream_test.rb b/test/unit/activity_stream_test.rb index 0f2efd033..2845209d8 100644 --- a/test/unit/activity_stream_test.rb +++ b/test/unit/activity_stream_test.rb @@ -36,12 +36,12 @@ class ActivityStreamTest < ActiveSupport::TestCase }, article: { updated_by_id: current_user.id, - created_by_id: current_user.id, - type_id: Ticket::Article::Type.lookup( name: 'phone' ).id, - sender_id: Ticket::Article::Sender.lookup( name: 'Customer' ).id, - from: 'Unit Test ', - body: 'Unit Test 123', - internal: false + created_by_id: current_user.id, + type_id: Ticket::Article::Type.lookup( name: 'phone' ).id, + sender_id: Ticket::Article::Sender.lookup( name: 'Customer' ).id, + from: 'Unit Test ', + body: 'Unit Test 123', + internal: false, }, }, update: { @@ -60,8 +60,8 @@ class ActivityStreamTest < ActiveSupport::TestCase check: [ { result: true, - object: 'Ticket', - type: 'updated', + object: 'Ticket', + type: 'updated', }, { result: true, @@ -85,9 +85,6 @@ class ActivityStreamTest < ActiveSupport::TestCase tickets = [] tests.each { |test| - ticket = nil - article = nil - ticket = Ticket.create( test[:create][:ticket] ) test[:check][0][:o_id] = ticket.id test[:check][2][:o_id] = ticket.id @@ -378,7 +375,7 @@ class ActivityStreamTest < ActiveSupport::TestCase activity_stream_list.each { |item| check_list += 1 next if check_list != check_count -# next if match + #next if match #puts '--------' #puts item.inspect #puts check_item.inspect diff --git a/test/unit/auth_test.rb b/test/unit/auth_test.rb index 8b8517cb9..0227e8fb6 100644 --- a/test/unit/auth_test.rb +++ b/test/unit/auth_test.rb @@ -34,7 +34,7 @@ if user active: true, ) else - user = User.create_if_not_exists( + User.create_if_not_exists( login: 'nicole.braun@zammad.org', firstname: 'Nicole', lastname: 'Braun', diff --git a/test/unit/email_parser_test.rb b/test/unit/email_parser_test.rb index bdda9d888..3487043f9 100644 --- a/test/unit/email_parser_test.rb +++ b/test/unit/email_parser_test.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# rubocop:disable all require 'test_helper' class EmailParserTest < ActiveSupport::TestCase diff --git a/test/unit/email_process_test.rb b/test/unit/email_process_test.rb index 828d9864c..1312b1597 100644 --- a/test/unit/email_process_test.rb +++ b/test/unit/email_process_test.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# rubocop:disable all require 'test_helper' class EmailProcessTest < ActiveSupport::TestCase diff --git a/test/unit/history_test.rb b/test/unit/history_test.rb index a00bbad78..777b7875b 100644 --- a/test/unit/history_test.rb +++ b/test/unit/history_test.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# rubocop:disable PerceivedComplexity, CyclomaticComplexity require 'test_helper' class HistoryTest < ActiveSupport::TestCase @@ -22,12 +23,12 @@ class HistoryTest < ActiveSupport::TestCase }, article: { updated_by_id: current_user.id, - created_by_id: current_user.id, - type_id: Ticket::Article::Type.lookup( name: 'phone' ).id, - sender_id: Ticket::Article::Sender.lookup( name: 'Customer' ).id, - from: 'Unit Test ', - body: 'Unit Test 123', - internal: false + created_by_id: current_user.id, + type_id: Ticket::Article::Type.lookup( name: 'phone' ).id, + sender_id: Ticket::Article::Sender.lookup( name: 'Customer' ).id, + from: 'Unit Test ', + body: 'Unit Test 123', + internal: false, }, }, ticket_update: { @@ -89,12 +90,12 @@ class HistoryTest < ActiveSupport::TestCase }, article: { created_by_id: current_user.id, - updated_by_id: current_user.id, - type_id: Ticket::Article::Type.lookup(name: 'phone' ).id, - sender_id: Ticket::Article::Sender.lookup(name: 'Customer' ).id, - from: 'Unit Test ', - body: 'Unit Test 123', - internal: false + updated_by_id: current_user.id, + type_id: Ticket::Article::Type.lookup(name: 'phone' ).id, + sender_id: Ticket::Article::Sender.lookup(name: 'Customer' ).id, + from: 'Unit Test ', + body: 'Unit Test 123', + internal: false, }, }, ticket_update: { @@ -213,8 +214,9 @@ class HistoryTest < ActiveSupport::TestCase user: { firstname: 'Bob', lastname: 'Master', - email: 'master@example.com', }, + email: 'master@example.com', active: false, + }, }, history_check: [ { @@ -354,16 +356,10 @@ class HistoryTest < ActiveSupport::TestCase end def history_check( history_list, history_check ) -# puts history_list.inspect history_check.each { |check_item| -# puts '+++++++++++' -# puts check_item.inspect match = false history_list.each { |history_item| 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['type'] != check_item[:history_type] if check_item[:history_attribute] diff --git a/test/unit/online_notifiaction_test.rb b/test/unit/online_notifiaction_test.rb index c07863b28..f1d7fd73e 100644 --- a/test/unit/online_notifiaction_test.rb +++ b/test/unit/online_notifiaction_test.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# rubocop:disable Next, UselessAssignment, BlockNesting require 'test_helper' class OnlineNotificationTest < ActiveSupport::TestCase @@ -73,14 +74,14 @@ class OnlineNotificationTest < ActiveSupport::TestCase check: [ { type: 'create', - object: 'Ticket', - created_by_id: agent_user1.id, + object: 'Ticket', + created_by_id: agent_user1.id, }, - { - type: 'update', + { + type: 'update', object: 'Ticket', created_by_id: customer_user.id, - }, + }, ], }, @@ -124,14 +125,14 @@ class OnlineNotificationTest < ActiveSupport::TestCase check: [ { type: 'create', - object: 'Ticket', - created_by_id: agent_user1.id, + object: 'Ticket', + created_by_id: agent_user1.id, }, - { - type: 'update', + { + type: 'update', object: 'Ticket', created_by_id: customer_user.id, - }, + }, ], }, @@ -175,14 +176,14 @@ class OnlineNotificationTest < ActiveSupport::TestCase check: [ { type: 'create', - object: 'Ticket', - created_by_id: agent_user1.id, + object: 'Ticket', + created_by_id: agent_user1.id, }, - { - type: 'update', + { + type: 'update', object: 'Ticket', created_by_id: customer_user.id, - }, + }, ], }, @@ -226,14 +227,14 @@ class OnlineNotificationTest < ActiveSupport::TestCase check: [ { type: 'create', - object: 'Ticket', - created_by_id: agent_user1.id, + object: 'Ticket', + created_by_id: agent_user1.id, }, - { - type: 'update', + { + type: 'update', object: 'Ticket', created_by_id: customer_user.id, - }, + }, ], }, ] diff --git a/test/unit/package_test.rb b/test/unit/package_test.rb index c26419984..8d58c6d17 100644 --- a/test/unit/package_test.rb +++ b/test/unit/package_test.rb @@ -1,6 +1,7 @@ # encoding: utf-8 +# rubocop:disable Next, UselessAssignment require 'test_helper' - + class PackageTest < ActiveSupport::TestCase test 'packages' do tests = [ @@ -264,7 +265,7 @@ X3RhYmxlIDpzYW1wbGVfdGFibGVzDQogIGVuZA0KZW5k end location = Rails.root.to_s + '/auto_install/unittest.zpm' file = File.new( location, 'wb' ) - file.write( test[:zpm] ) + file.write( test[:zpm] ) file.close end begin diff --git a/test/unit/rest_test.rb b/test/unit/rest_test.rb index 5812414a2..eb64ae390 100644 --- a/test/unit/rest_test.rb +++ b/test/unit/rest_test.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# rubocop:disable UselessAssignment require 'test_helper' class RestTest < ActiveSupport::TestCase @@ -239,6 +240,6 @@ class RestTest < ActiveSupport::TestCase #puts 'URL: ' + url #puts response.code.to_s #puts response.body.to_s - return { data: response.data, response: response } + { data: response.data, response: response } end end diff --git a/test/unit/session_basic_test.rb b/test/unit/session_basic_test.rb index 7cc27ff6b..ff4a4bddd 100644 --- a/test/unit/session_basic_test.rb +++ b/test/unit/session_basic_test.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# rubocop:disable UselessAssignment require 'test_helper' class SessionBasicTest < ActiveSupport::TestCase diff --git a/test/unit/session_basic_ticket_test.rb b/test/unit/session_basic_ticket_test.rb index 1acbd3a33..4ba1cf6df 100644 --- a/test/unit/session_basic_ticket_test.rb +++ b/test/unit/session_basic_ticket_test.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# rubocop:disable UselessAssignment require 'test_helper' class SessionBasicTicketTest < ActiveSupport::TestCase diff --git a/test/unit/session_collections_test.rb b/test/unit/session_collections_test.rb index 9db5a2976..639f84dd9 100644 --- a/test/unit/session_collections_test.rb +++ b/test/unit/session_collections_test.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# rubocop:disable Next, CyclomaticComplexity require 'test_helper' class SessionCollectionsTest < ActiveSupport::TestCase diff --git a/test/unit/session_enhanced_test.rb b/test/unit/session_enhanced_test.rb index ae4279bf0..0585e38fb 100644 --- a/test/unit/session_enhanced_test.rb +++ b/test/unit/session_enhanced_test.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# rubocop:disable Next, UselessAssignment require 'test_helper' class SessionEnhancedTest < ActiveSupport::TestCase diff --git a/test/unit/token_test.rb b/test/unit/token_test.rb index 404b38ee5..3e83355e1 100644 --- a/test/unit/token_test.rb +++ b/test/unit/token_test.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# rubocop:disable Next require 'test_helper' class TokenTest < ActiveSupport::TestCase