history_spec.rb 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe 'Ticket zoom > History', authenticated_as: :authenticate, time_zone: 'Europe/London', type: :system do
  4. describe 'Log Trigger and Scheduler in Ticket History #4604' do
  5. let(:ticket) { create(:ticket, group: Group.find_by(name: 'Users')) }
  6. let(:trigger) { create(:trigger, condition: { 'ticket.action' => { 'operator' => 'is', 'value' => 'create' } }, perform: { 'ticket.title'=>{ 'value'=>'triggered' } }, activator: 'action', execution_condition_mode: 'selective') }
  7. def authenticate
  8. ticket && trigger
  9. TransactionDispatcher.commit
  10. true
  11. end
  12. before do
  13. visit "#ticket/zoom/#{ticket.id}"
  14. end
  15. it 'does show the changes of the trigger in the history' do
  16. click '.sidebar-header-headline'
  17. click 'li[data-type=ticket-history]'
  18. expect(page).to have_text("Trigger: #{trigger.name}")
  19. expect(page).to have_text('triggered')
  20. end
  21. end
  22. describe 'Ticket history shows html when updating articles #5168' do
  23. let(:old_body) { SecureRandom.uuid }
  24. let(:new_body) { SecureRandom.uuid }
  25. let(:ticket) { create(:ticket, group: Group.first) }
  26. let(:article) { create(:ticket_article, ticket: ticket, body: "<div><b>#{old_body}</b></div>", content_type: 'text/html') }
  27. def authenticate
  28. article.update(body: "<div><b>#{new_body}</b></div>")
  29. true
  30. end
  31. before do
  32. visit "#ticket/zoom/#{ticket.id}"
  33. end
  34. it 'does not show html in the ticket history', :aggregate_failures do
  35. click '.sidebar-header-headline'
  36. click 'li[data-type=ticket-history]'
  37. expect(page).to have_text(old_body)
  38. expect(page).to have_text(new_body)
  39. expect(page).to have_no_text('<div>')
  40. expect(page).to have_no_text('</div>')
  41. end
  42. end
  43. end