From 5af09d73c79a7e96fe7270d0c1f34d03d57e54ad Mon Sep 17 00:00:00 2001 From: Rolf Schmidt Date: Thu, 24 Jun 2021 13:58:16 +0100 Subject: [PATCH] Fixes #3633 - The rebuild of the index is failing. --- app/models/chat/session/search_index.rb | 2 +- spec/models/chat/session_spec.rb | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/models/chat/session/search_index.rb b/app/models/chat/session/search_index.rb index 9acdf6b9c..390ab7026 100644 --- a/app/models/chat/session/search_index.rb +++ b/app/models/chat/session/search_index.rb @@ -27,7 +27,7 @@ returns messages.each do |message| # lookup attributes of ref. objects (normally name and note) - message_attributes = message.search_index_attribute_lookup + message_attributes = message.search_index_attribute_lookup(include_references: false) attributes['messages'].push message_attributes end diff --git a/spec/models/chat/session_spec.rb b/spec/models/chat/session_spec.rb index ab1f849b9..3c22c300b 100644 --- a/spec/models/chat/session_spec.rb +++ b/spec/models/chat/session_spec.rb @@ -7,11 +7,17 @@ RSpec.describe Chat::Session, type: :model do describe '.search_index_attribute_lookup' do subject(:chat_session) { create(:'chat/session', user: chat_user, chat: chat) } + let(:chat_message) { create(:'chat/message', chat_session: chat_session) } + let(:chat) { create(:chat) } let(:chat_user) { create(:agent) } + before do + chat_message + end + it 'verify message attribute' do - expect(chat_session.search_index_attribute_lookup['messages']).to eq [] + expect(chat_session.search_index_attribute_lookup['messages']).not_to eq [] end it 'verify user attribute' do @@ -21,6 +27,5 @@ RSpec.describe Chat::Session, type: :model do it 'verify chat attribute' do expect(chat_session.search_index_attribute_lookup['chat']['name']).to eq chat.name end - end end