chat_spec.rb 932 B

1234567891011121314151617181920212223242526272829303132333435
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. require 'models/concerns/has_xss_sanitized_note_examples'
  4. RSpec.describe Chat, type: :model do
  5. it_behaves_like 'HasXssSanitizedNote', model_factory: :chat
  6. describe 'website allowing' do
  7. let(:chat) { create(:chat, allowed_websites: 'zammad.org') }
  8. it 'detects allowed website' do
  9. result = chat.website_allowed?('https://www.zammad.org')
  10. expect(result).to be true
  11. end
  12. it 'detects non-allowed website' do
  13. result = chat.website_allowed?('https://www.zammad.com')
  14. expect(result).to be false
  15. end
  16. end
  17. describe '#destroy' do
  18. let(:chat) { create(:chat) }
  19. let(:session) { create(:'chat/session', chat: chat) }
  20. before do
  21. session
  22. end
  23. it 'does delete chats properly if they have sessions' do
  24. expect { chat.destroy! }.not_to raise_error
  25. end
  26. end
  27. end