history_spec.rb 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. # Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe 'Ticket history', time_zone: 'Europe/London', type: :system do
  4. let(:group) { Group.find_by(name: 'Users') }
  5. let(:customer) { create(:customer, organization: organization) }
  6. let!(:session_user) { User.find_by(login: 'admin@example.com') }
  7. let(:organization) { create(:organization) }
  8. let(:org_name_1) { 'organization test 1' }
  9. let(:org_name_2) { 'organization test 2' }
  10. let(:org_1) { create(:organization, name: org_name_1) }
  11. let(:org_2) { create(:organization, name: org_name_2) }
  12. let(:locale) { 'de-de' }
  13. before do
  14. freeze_time
  15. travel_to Time.zone.parse('2021-01-22 13:40:00')
  16. current_time = Time.current
  17. customer.update! firstname: 'Customer'
  18. customer.update! email: 'test@example.com'
  19. customer.update! country: 'Germany'
  20. customer.update! out_of_office_start_at: current_time
  21. customer.update! last_login: current_time
  22. customer.organizations << [org_1, org_2]
  23. travel_to Time.zone.parse('2021-04-06 23:30:00')
  24. current_time = Time.current
  25. customer.update! lastname: 'Example'
  26. customer.update! mobile: '5757473827'
  27. customer.update! out_of_office_end_at: current_time
  28. customer.update! last_login: current_time
  29. customer.organizations.delete(org_2)
  30. travel_back
  31. session_user.preferences[:locale] = locale
  32. session_user.save!
  33. visit '/'
  34. # Suppress the modal dialog that invites to contributions for translations that are < 90% as this breaks the tests for de-de.
  35. page.evaluate_script "App.LocalStorage.set('translation_support_no', true, App.Session.get('id'))"
  36. refresh
  37. visit "#user/profile/#{customer.id}"
  38. find_by_id('userAction').click
  39. click('[data-type="history"]')
  40. end
  41. it "translates timestamp when attribute's tag is datetime" do
  42. expect(page).to have_css('li', text: %r{'22.01.2021 00:00'})
  43. end
  44. it 'does not include time with UTC format' do
  45. expect(page).to have_no_text(%r{ UTC})
  46. end
  47. it 'translates out_of_office_start_at value to time stamp' do
  48. expect(page).to have_css('li', text: %r{Benutzer out_of_office_start_at '22.01.2021 00:00'})
  49. end
  50. it 'translates out_of_office_end_at value to time stamp' do
  51. expect(page).to have_css('li', text: %r{Benutzer out_of_office_end_at '06.04.2021 01:00'})
  52. end
  53. context 'when language is in english' do
  54. let(:locale) { 'en' }
  55. it 'shows added and removed secondary organizations' do
  56. in_modal do
  57. expect(page).to have_css('li', text: %r{added User Secondary organizations 'organization test 1'})
  58. expect(page).to have_css('li', text: %r{removed User Secondary organizations 'organization test 2'})
  59. end
  60. end
  61. end
  62. end