excel_sheet_spec.rb 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe ExcelSheet do
  4. describe '.timestamp_in_localtime' do
  5. let(:document) { described_class.new(title: 'some title', header: [], records: [], timezone: 'Europe/Berlin', locale: 'de-de') }
  6. it 'does convert UTC timestamp to local system based timestamp' do
  7. expect(document.timestamp_in_localtime(Time.parse('2019-08-08T01:00:05Z').in_time_zone)).to eq('2019-08-08 03:00:05')
  8. end
  9. end
  10. describe 'Multiselect does not show values properly in reports #4186', db_strategy: :reset do
  11. let(:document) { described_class.new(title: 'some title', header: [], records: [], timezone: 'Europe/Berlin', locale: 'de-de') }
  12. let(:ticket) { create(:ticket, '4186_select': 'key_1', '4186_tree_select': 'Incident::Hardware', '4186_multiselect': %w[key_1 key_2], '4186_multi_tree_select': ['Incident', 'Incident::Hardware']) }
  13. before do
  14. create(:object_manager_attribute_select, name: '4186_select')
  15. create(:object_manager_attribute_tree_select, name: '4186_tree_select')
  16. create(:object_manager_attribute_multiselect, name: '4186_multiselect')
  17. create(:object_manager_attribute_multi_tree_select, name: '4186_multi_tree_select')
  18. ObjectManager::Attribute.migration_execute
  19. ticket
  20. end
  21. it 'does show select values formatted' do
  22. expect(document.value_lookup(ticket, '4186_select', ObjectManager::Attribute.find_by(name: '4186_select'), nil)).to eq('value_1')
  23. end
  24. it 'does show tree select values formatted' do
  25. expect(document.value_lookup(ticket, '4186_tree_select', ObjectManager::Attribute.find_by(name: '4186_tree_select'), nil)).to eq('Incident::Hardware')
  26. end
  27. it 'does show multiselect values formatted' do
  28. expect(document.value_lookup(ticket, '4186_multiselect', ObjectManager::Attribute.find_by(name: '4186_multiselect'), nil)).to eq('value_1,value_2')
  29. end
  30. it 'does show multi tree select values formatted' do
  31. expect(document.value_lookup(ticket, '4186_multi_tree_select', ObjectManager::Attribute.find_by(name: '4186_multi_tree_select'), nil)).to eq('Incident,Incident::Hardware')
  32. end
  33. end
  34. end