history_spec.rb 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. require 'rails_helper'
  2. RSpec.describe 'Ticket history', type: :system, authenticated_as: true, time_zone: 'Europe/London' do
  3. let(:group) { Group.find_by(name: 'Users') }
  4. let(:ticket) { create(:ticket, group: group) }
  5. let!(:session_user) { User.find_by(login: 'master@example.com') }
  6. before do
  7. freeze_time
  8. travel_to DateTime.parse('2021-01-22 13:40:00 UTC')
  9. current_time = Time.current
  10. ticket.update(title: 'New Ticket Title')
  11. ticket_article = create(:ticket_article, ticket: ticket, internal: true)
  12. ticket.update! state: Ticket::State.lookup(name: 'open')
  13. ticket.update! last_owner_update_at: current_time
  14. ticket.update! priority: Ticket::Priority.lookup(name: '1 low')
  15. ticket.update! last_contact_at: current_time
  16. ticket.update! last_contact_customer_at: current_time
  17. ticket.update! last_contact_agent_at: current_time
  18. ticket_article.update! internal: false
  19. travel_to DateTime.parse('2021-04-06 23:30:00 UTC')
  20. current_time = Time.current
  21. ticket.update! state: Ticket::State.lookup(name: 'pending close')
  22. ticket.update! priority: Ticket::Priority.lookup(name: '3 high')
  23. ticket_article.update! internal: true
  24. ticket.update! last_contact_at: current_time
  25. ticket.update! last_contact_customer_at: current_time
  26. ticket.update! last_contact_agent_at: current_time
  27. ticket.update! pending_time: current_time
  28. ticket.update! first_response_escalation_at: current_time
  29. travel_back
  30. session_user.preferences[:locale] = 'de-de'
  31. session_user.save!
  32. refresh
  33. visit "#ticket/zoom/#{ticket.id}"
  34. find('[data-tab="ticket"] .js-actions').click
  35. click('[data-type="ticket-history"]')
  36. end
  37. it "translates timestamp when attribute's tag is datetime" do
  38. expect(page).to have_css('li', text: /22.01.2021 13:40/)
  39. end
  40. it 'does not include time with UTC format' do
  41. expect(page).to have_no_text(/ UTC/)
  42. end
  43. it 'translates value when attribute is state' do
  44. expect(page).to have_css('li', text: /Ticket Status von 'neu'/)
  45. end
  46. it 'translates value when attribute is priority' do
  47. expect(page).to have_css('li', text: /Ticket Priorität von '1 niedrig'/)
  48. end
  49. it 'translates value when attribute is internal' do
  50. expect(page).to have_css('li', text: /Artikel intern von 'true'/)
  51. end
  52. it 'translates last_contact_at display attribute' do
  53. expect(page).to have_css('li', text: /Ticket Letzter Kontakt von '22.01.2021 13:40' → '07.04.2021 00:30'/)
  54. end
  55. it 'translates last_contact_customer_at display attribute' do
  56. expect(page).to have_css('li', text: /Ticket Letzter Kontakt \(Kunde\) von '22.01.2021 13:40' → '07.04.2021 00:30'/)
  57. end
  58. it 'translates last_contact_agent_at display attribute' do
  59. expect(page).to have_css('li', text: /Ticket Letzter Kontakt \(Agent\) von '22.01.2021 13:40' → '07.04.2021 00:30'/)
  60. end
  61. it 'translates pending_time display attribute' do
  62. expect(page).to have_css('li', text: /Ticket Warten bis '07.04.2021 00:30'/)
  63. end
  64. end