calendars_spec.rb 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. # Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe 'Manage > Calendars', type: :system do
  4. context 'Date' do
  5. let(:calendar_title) { "test calendar #{SecureRandom.uuid}" }
  6. it 'show festivity dates correctly far away from UTC', time_zone: 'America/Sao_Paulo' do
  7. visit '/#manage/calendars'
  8. click '.js-new'
  9. modal_ready
  10. within '.modal-dialog' do
  11. fill_in 'name', with: calendar_title
  12. click '.dropdown-toggle'
  13. click '.dropdown-menu [data-value="America/Sao_Paulo"]'
  14. find('.ical_feed select').select 'Brazil'
  15. click '.js-submit'
  16. end
  17. modal_disappear
  18. within :active_content do
  19. within '.action', text: calendar_title do
  20. find('.js-edit').click
  21. end
  22. end
  23. # Check that holidays were imported by looking at the first entry.
  24. expect(find('.modal-dialog .holiday_selector tbody tr:first-child td:nth-child(2)').text).to match(%r{^\d{4}-\d{2}-\d{2}$})
  25. expect(find('.modal-dialog .holiday_selector tbody tr:first-child td input.js-summary').value).to be_present
  26. end
  27. end
  28. # https://github.com/zammad/zammad/issues/2528
  29. context 'ical feed - subscribe to public holidays in another country' do
  30. it 'shows countries dropdown in sorted order' do
  31. allow(Calendar).to receive(:ical_feeds).and_return({
  32. 'https://argentinien.de': 'Argentinien',
  33. 'https://australien.de': 'Australien',
  34. 'https://osterreich.de': 'Österreich',
  35. 'https://weibrussland.de': 'Weißrussland',
  36. 'https://kanada.de': 'Kanada',
  37. 'https://chile.de': 'Chile',
  38. })
  39. visit '/#manage/calendars'
  40. click '.js-new'
  41. in_modal disappears: false do
  42. expect(all('.ical_feed select option').map(&:text)).to eq ['-', 'Argentinien', 'Australien', 'Chile', 'Kanada', 'Österreich', 'Weißrussland']
  43. end
  44. end
  45. end
  46. end