session_spec.rb 877 B

12345678910111213141516171819202122232425262728293031
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe Chat::Session, type: :model do
  4. describe '.search_index_attribute_lookup' do
  5. subject(:chat_session) { create(:'chat/session', user: chat_user, chat: chat) }
  6. let(:chat_message) { create(:'chat/message', chat_session: chat_session) }
  7. let(:chat) { create(:chat) }
  8. let(:chat_user) { create(:agent) }
  9. before do
  10. chat_message
  11. end
  12. it 'verify message attribute' do
  13. expect(chat_session.search_index_attribute_lookup['messages']).not_to eq []
  14. end
  15. it 'verify user attribute' do
  16. expect(chat_session.search_index_attribute_lookup['user']['id']).to eq chat_user.id
  17. end
  18. it 'verify chat attribute' do
  19. expect(chat_session.search_index_attribute_lookup['chat']['name']).to eq chat.name
  20. end
  21. end
  22. end