history_spec.rb 2.8 KB

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