From 4e8bc9564ec596247381ff358d3ac715da240fc4 Mon Sep 17 00:00:00 2001 From: Thorsten Eckel Date: Sun, 1 Oct 2017 14:31:29 +0200 Subject: [PATCH] Follow up: Applied RuboCop Style/BlockDelimiters to improve readability. --- ...0001_fixed_twitter_ticket_article_preferences4.rb | 12 ++++++------ lib/tasks/search_index_es.rake | 4 ++-- lib/tasks/test_browser.rake | 4 ++-- spec/lib/ldap_spec.rb | 4 ++-- test/unit/ticket_article_dos_test.rb | 4 ++-- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/db/migrate/20170908000001_fixed_twitter_ticket_article_preferences4.rb b/db/migrate/20170908000001_fixed_twitter_ticket_article_preferences4.rb index 9b97fb7cd..76e07c07d 100644 --- a/db/migrate/20170908000001_fixed_twitter_ticket_article_preferences4.rb +++ b/db/migrate/20170908000001_fixed_twitter_ticket_article_preferences4.rb @@ -7,13 +7,13 @@ class FixedTwitterTicketArticlePreferences4 < ActiveRecord::Migration[5.0] # find article preferences with Twitter::NullObject and replace it with nill to prevent elasticsearch index issue article_type_ids = Ticket::Article::Type.where(name: ['twitter status', 'twitter direct-message']).pluck(:id) article_ids = Ticket::Article.where(type_id: article_type_ids).pluck(:id) - article_ids.each { |article_id| + article_ids.each do |article_id| article = Ticket::Article.find(article_id) next if !article.preferences changed = false - article.preferences.each { |_key, value| + article.preferences.each do |_key, value| next if value.class != ActiveSupport::HashWithIndifferentAccess - value.each { |sub_key, sub_level| + value.each do |sub_key, sub_level| if sub_level.class == NilClass value[sub_key] = nil next @@ -26,11 +26,11 @@ class FixedTwitterTicketArticlePreferences4 < ActiveRecord::Migration[5.0] next if sub_level.class != Twitter::NullObject value[sub_key] = nil changed = true - } - } + end + end next if !changed article.save! - } + end end end diff --git a/lib/tasks/search_index_es.rake b/lib/tasks/search_index_es.rake index 5a1b47e5a..c24416669 100644 --- a/lib/tasks/search_index_es.rake +++ b/lib/tasks/search_index_es.rake @@ -43,14 +43,14 @@ namespace :searchindex do task :reload, [:opts] => :environment do |_t, _args| puts 'reload data...' - Models.searchable.each { |model_class| + Models.searchable.each do |model_class| puts " reload #{model_class}" started_at = Time.zone.now puts " - started at #{started_at}" model_class.search_index_reload took = Time.zone.now - started_at puts " - took #{took.to_i} seconds" - } + end end diff --git a/lib/tasks/test_browser.rake b/lib/tasks/test_browser.rake index 2bc8d1a87..d6c280484 100644 --- a/lib/tasks/test_browser.rake +++ b/lib/tasks/test_browser.rake @@ -9,11 +9,11 @@ namespace :test do if !args.opts args.opts = '' end - Dir.glob('test/browser/*_test.rb').sort.each { |r| + Dir.glob('test/browser/*_test.rb').sort.each do |r| sh "#{args.opts} ruby -Itest #{r}" do |ok, res| raise 'Failed test. ' + res.inspect if !ok end - } + end puts 'All browser tests, elapsed: ' + (Time.zone.now - start).to_s + ' seconds' end diff --git a/spec/lib/ldap_spec.rb b/spec/lib/ldap_spec.rb index bd43e70d3..a7d719804 100644 --- a/spec/lib/ldap_spec.rb +++ b/spec/lib/ldap_spec.rb @@ -206,13 +206,13 @@ RSpec.describe Ldap do # expectations and reuse it in 'let' instance # as return param of Net::LDAP.new let(:mocked_ldap) { double(bind: true) } - let(:instance) { + let(:instance) do expect(Net::LDAP).to receive(:new).and_return(mocked_ldap) described_class.new( host: 'localhost', port: 1337, ) - } + end context '#preferences' do diff --git a/test/unit/ticket_article_dos_test.rb b/test/unit/ticket_article_dos_test.rb index cd75dd747..1891bcb5b 100644 --- a/test/unit/ticket_article_dos_test.rb +++ b/test/unit/ticket_article_dos_test.rb @@ -72,7 +72,7 @@ class TicketArticleDos < ActiveSupport::TestCase created_by_id: 1, ) - assert_raises(Exceptions::UnprocessableEntity) { + assert_raises(Exceptions::UnprocessableEntity) do article3 = Ticket::Article.create!( ticket_id: ticket3.id, type_id: Ticket::Article::Type.find_by(name: 'phone').id, @@ -83,7 +83,7 @@ class TicketArticleDos < ActiveSupport::TestCase updated_by_id: 1, created_by_id: 1, ) - } + end end