From 34c14a22b5c6430da865a9ec66517a67363857a8 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Thu, 14 Dec 2017 21:05:59 +0100 Subject: [PATCH] Push users.preferences to elasticsearch to enable searches for certain features. --- app/models/user.rb | 3 +-- app/models/user/search_index.rb | 5 ----- test/integration/elasticsearch_test.rb | 3 +++ 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 42c6bbc31..90609c1ad 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -72,8 +72,7 @@ class User < ApplicationModel :image, :image_source, :source, - :login_failed, - :preferences + :login_failed def ignore_search_indexing?(_action) # ignore internal user diff --git a/app/models/user/search_index.rb b/app/models/user/search_index.rb index c28485f17..80376e7f4 100644 --- a/app/models/user/search_index.rb +++ b/app/models/user/search_index.rb @@ -50,11 +50,6 @@ returns def search_index_data attributes = {} self.attributes.each do |key, value| - next if key == 'created_at' - next if key == 'updated_at' - next if key == 'created_by_id' - next if key == 'updated_by_id' - next if key == 'preferences' next if key == 'password' next if !value next if value.respond_to?('blank?') && value.blank? diff --git a/test/integration/elasticsearch_test.rb b/test/integration/elasticsearch_test.rb index e0b6ff4e0..94d4991bc 100644 --- a/test/integration/elasticsearch_test.rb +++ b/test/integration/elasticsearch_test.rb @@ -114,6 +114,7 @@ class ElasticsearchTest < ActiveSupport::TestCase assert_equal('E', attributes['firstname']) assert_equal('S', attributes['lastname']) assert_equal('es-agent@example.com', attributes['email']) + assert(attributes['preferences']) assert_not(attributes['password']) assert_not(attributes['organization']) @@ -121,6 +122,7 @@ class ElasticsearchTest < ActiveSupport::TestCase assert_equal('E', attributes['firstname']) assert_equal('S', attributes['lastname']) assert_equal('es-agent@example.com', attributes['email']) + assert(attributes['preferences']) assert_not(attributes['password']) assert_not(attributes['organization']) @@ -128,6 +130,7 @@ class ElasticsearchTest < ActiveSupport::TestCase assert_equal('ES', attributes['firstname']) assert_equal('Customer1', attributes['lastname']) assert_equal('es-customer1@example.com', attributes['email']) + assert(attributes['preferences']) assert_not(attributes['password']) assert_equal('Customer Organization Update', attributes['organization'])