Follow up: Applied RuboCop Style/BlockDelimiters to improve readability.
This commit is contained in:
parent
757f0ac9bd
commit
4e8bc9564e
5 changed files with 14 additions and 14 deletions
|
@ -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
|
# 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_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 = 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)
|
article = Ticket::Article.find(article_id)
|
||||||
next if !article.preferences
|
next if !article.preferences
|
||||||
changed = false
|
changed = false
|
||||||
article.preferences.each { |_key, value|
|
article.preferences.each do |_key, value|
|
||||||
next if value.class != ActiveSupport::HashWithIndifferentAccess
|
next if value.class != ActiveSupport::HashWithIndifferentAccess
|
||||||
value.each { |sub_key, sub_level|
|
value.each do |sub_key, sub_level|
|
||||||
if sub_level.class == NilClass
|
if sub_level.class == NilClass
|
||||||
value[sub_key] = nil
|
value[sub_key] = nil
|
||||||
next
|
next
|
||||||
|
@ -26,11 +26,11 @@ class FixedTwitterTicketArticlePreferences4 < ActiveRecord::Migration[5.0]
|
||||||
next if sub_level.class != Twitter::NullObject
|
next if sub_level.class != Twitter::NullObject
|
||||||
value[sub_key] = nil
|
value[sub_key] = nil
|
||||||
changed = true
|
changed = true
|
||||||
}
|
end
|
||||||
}
|
end
|
||||||
next if !changed
|
next if !changed
|
||||||
article.save!
|
article.save!
|
||||||
}
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -43,14 +43,14 @@ namespace :searchindex do
|
||||||
task :reload, [:opts] => :environment do |_t, _args|
|
task :reload, [:opts] => :environment do |_t, _args|
|
||||||
|
|
||||||
puts 'reload data...'
|
puts 'reload data...'
|
||||||
Models.searchable.each { |model_class|
|
Models.searchable.each do |model_class|
|
||||||
puts " reload #{model_class}"
|
puts " reload #{model_class}"
|
||||||
started_at = Time.zone.now
|
started_at = Time.zone.now
|
||||||
puts " - started at #{started_at}"
|
puts " - started at #{started_at}"
|
||||||
model_class.search_index_reload
|
model_class.search_index_reload
|
||||||
took = Time.zone.now - started_at
|
took = Time.zone.now - started_at
|
||||||
puts " - took #{took.to_i} seconds"
|
puts " - took #{took.to_i} seconds"
|
||||||
}
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -9,11 +9,11 @@ namespace :test do
|
||||||
if !args.opts
|
if !args.opts
|
||||||
args.opts = ''
|
args.opts = ''
|
||||||
end
|
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|
|
sh "#{args.opts} ruby -Itest #{r}" do |ok, res|
|
||||||
raise 'Failed test. ' + res.inspect if !ok
|
raise 'Failed test. ' + res.inspect if !ok
|
||||||
end
|
end
|
||||||
}
|
end
|
||||||
puts 'All browser tests, elapsed: ' + (Time.zone.now - start).to_s + ' seconds'
|
puts 'All browser tests, elapsed: ' + (Time.zone.now - start).to_s + ' seconds'
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -206,13 +206,13 @@ RSpec.describe Ldap do
|
||||||
# expectations and reuse it in 'let' instance
|
# expectations and reuse it in 'let' instance
|
||||||
# as return param of Net::LDAP.new
|
# as return param of Net::LDAP.new
|
||||||
let(:mocked_ldap) { double(bind: true) }
|
let(:mocked_ldap) { double(bind: true) }
|
||||||
let(:instance) {
|
let(:instance) do
|
||||||
expect(Net::LDAP).to receive(:new).and_return(mocked_ldap)
|
expect(Net::LDAP).to receive(:new).and_return(mocked_ldap)
|
||||||
described_class.new(
|
described_class.new(
|
||||||
host: 'localhost',
|
host: 'localhost',
|
||||||
port: 1337,
|
port: 1337,
|
||||||
)
|
)
|
||||||
}
|
end
|
||||||
|
|
||||||
context '#preferences' do
|
context '#preferences' do
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,7 @@ class TicketArticleDos < ActiveSupport::TestCase
|
||||||
created_by_id: 1,
|
created_by_id: 1,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert_raises(Exceptions::UnprocessableEntity) {
|
assert_raises(Exceptions::UnprocessableEntity) do
|
||||||
article3 = Ticket::Article.create!(
|
article3 = Ticket::Article.create!(
|
||||||
ticket_id: ticket3.id,
|
ticket_id: ticket3.id,
|
||||||
type_id: Ticket::Article::Type.find_by(name: 'phone').id,
|
type_id: Ticket::Article::Type.find_by(name: 'phone').id,
|
||||||
|
@ -83,7 +83,7 @@ class TicketArticleDos < ActiveSupport::TestCase
|
||||||
updated_by_id: 1,
|
updated_by_id: 1,
|
||||||
created_by_id: 1,
|
created_by_id: 1,
|
||||||
)
|
)
|
||||||
}
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue