Applied rubocop cop 'Style/Next' and 'Style/UselessAssignment' and 'Style/BlockNesting'.

This commit is contained in:
Thorsten Eckel 2015-07-03 19:40:58 +02:00
parent aaf19fa52b
commit 81e14dd961

View file

@ -1,5 +1,4 @@
# 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
@ -283,14 +282,14 @@ class OnlineNotificationTest < ActiveSupport::TestCase
notification_check( OnlineNotification.list(agent_user2, 10), test[:check] ) notification_check( OnlineNotification.list(agent_user2, 10), test[:check] )
# check online notifications # check online notifications
if test[:update][:online_notification] next if !test[:update][:online_notification]
if test[:update][:online_notification][:seen_only_exists]
notifications = OnlineNotification.list_by_object( 'Ticket', ticket.id ) if test[:update][:online_notification][:seen_only_exists]
assert( notification_seen_only_exists_exists( notifications ), 'not seen notifications for ticket available') notifications = OnlineNotification.list_by_object( 'Ticket', ticket.id )
else assert( notification_seen_only_exists_exists( notifications ), 'not seen notifications for ticket available')
notifications = OnlineNotification.list_by_object( 'Ticket', ticket.id ) else
assert( !notification_seen_only_exists_exists( notifications ), 'seen notifications for ticket available') notifications = OnlineNotification.list_by_object( 'Ticket', ticket.id )
end assert( !notification_seen_only_exists_exists( notifications ), 'seen notifications for ticket available')
end end
} }
@ -322,27 +321,27 @@ class OnlineNotificationTest < ActiveSupport::TestCase
} }
end end
def notification_check( onine_notifications, checks ) def notification_check( online_notifications, checks )
checks.each { |check_item| checks.each { |check_item|
hit = false hit = false
onine_notifications.each {|onine_notification| online_notifications.each {|onine_notification|
if onine_notification['o_id'] == check_item[:o_id]
if onine_notification['object'] == check_item[:object] next if onine_notification['o_id'] != check_item[:o_id]
if onine_notification['type'] == check_item[:type] next if onine_notification['object'] != check_item[:object]
if onine_notification['created_by_id'] == check_item[:created_by_id] next if onine_notification['type'] != check_item[:type]
hit = true next if onine_notification['created_by_id'] != check_item[:created_by_id]
end
end hit = true
end
end break
} }
#puts "--- #{onine_notifications.inspect}" #puts "--- #{online_notifications.inspect}"
assert( hit, "online notification exists not #{check_item.inspect}" ) assert( hit, "online notification exists not #{check_item.inspect}" )
} }
end end
def notification_seen_only_exists_exists( onine_notifications ) def notification_seen_only_exists_exists( online_notifications )
onine_notifications.each {|onine_notification| online_notifications.each {|onine_notification|
return false if !onine_notification['seen'] return false if !onine_notification['seen']
} }
true true