From 6c3dc608abde580f5382cfd36f90aee14c9c0e56 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Tue, 26 Apr 2016 14:42:55 +0200 Subject: [PATCH] Code cleanup. --- lib/search_index_backend.rb | 24 ++++++++++++------------ test/fixtures/seeds.rb | 4 ++-- test/integration/report_test.rb | 2 +- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/search_index_backend.rb b/lib/search_index_backend.rb index 6d96538ca..2e2106755 100644 --- a/lib/search_index_backend.rb +++ b/lib/search_index_backend.rb @@ -36,11 +36,11 @@ create/update/delete index def self.index(data) - url = build_url( data[:name] ) + url = build_url(data[:name]) return if !url if data[:action] && data[:action] == 'delete' - return SearchIndexBackend.remove( data[:name] ) + return SearchIndexBackend.remove(data[:name]) end Rails.logger.info "# curl -X PUT \"#{url}\" \\" @@ -66,13 +66,13 @@ create/update/delete index add new object to search index - SearchIndexBackend.add( 'Ticket', some_data_object ) + SearchIndexBackend.add('Ticket', some_data_object) =end def self.add(type, data) - url = build_url( type, data['id'] ) + url = build_url(type, data['id']) return if !url Rails.logger.info "# curl -X POST \"#{url}\" \\" @@ -98,14 +98,14 @@ add new object to search index remove whole data from index - SearchIndexBackend.remove( 'Ticket', 123 ) + SearchIndexBackend.remove('Ticket', 123) - SearchIndexBackend.remove( 'Ticket' ) + SearchIndexBackend.remove('Ticket') =end - def self.remove( type, o_id = nil ) - url = build_url( type, o_id ) + def self.remove(type, o_id = nil) + url = build_url(type, o_id) return if !url Rails.logger.info "# curl -X DELETE \"#{url}\"" @@ -129,9 +129,9 @@ remove whole data from index return search result - result = SearchIndexBackend.search( 'search query', limit, ['User', 'Organization'] ) + result = SearchIndexBackend.search('search query', limit, ['User', 'Organization']) - result = SearchIndexBackend.search( 'search query', limit, 'User' ) + result = SearchIndexBackend.search('search query', limit, 'User') result = [ { @@ -150,7 +150,7 @@ return search result =end - def self.search( query, limit = 10, index = nil, query_extention = {} ) + def self.search(query, limit = 10, index = nil, query_extention = {}) return [] if !query url = build_url() @@ -445,7 +445,7 @@ return true if backend is configured true end - def self.build_url( type = nil, o_id = nil ) + def self.build_url(type = nil, o_id = nil) return if !SearchIndexBackend.enabled? index = Setting.get('es_index').to_s + "_#{Rails.env}" url = Setting.get('es_url') diff --git a/test/fixtures/seeds.rb b/test/fixtures/seeds.rb index b9a8e5a51..5ef8d7f9f 100644 --- a/test/fixtures/seeds.rb +++ b/test/fixtures/seeds.rb @@ -5,10 +5,10 @@ channel_id = nil channel = Channel.find_by(area: 'Email::Notification', active: true) if channel - channel_id = channel + channel_id = channel.id end -email_address = EmailAddress.create_if_not_exists( +email_address = EmailAddress.create_or_update( realname: 'Zammad', email: 'zammad@localhost', channel_id: channel_id, diff --git a/test/integration/report_test.rb b/test/integration/report_test.rb index 7a5a469bb..5e020d978 100644 --- a/test/integration/report_test.rb +++ b/test/integration/report_test.rb @@ -20,7 +20,7 @@ class ReportTest < ActiveSupport::TestCase # Setting.set('es_index', 'estest.local_zammad') # Setting.set('es_user', 'elasticsearch') # Setting.set('es_password', 'zammad') - # Setting.set('es_attachment_max_size_in_mb', 1 ) + # Setting.set('es_attachment_max_size_in_mb', 1) # clear cache Cache.clear