calendar_subscriptions_spec.rb 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. # Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe 'iCal endpoints', type: :request do
  4. context 'with no existing session' do
  5. it 'gives HTTP Basic auth prompt (#3064)' do
  6. get '/ical/tickets'
  7. expect(response.body).to eq("HTTP Basic: Access denied.\n")
  8. end
  9. end
  10. describe 'time zone', authenticated_as: :user do
  11. let(:group) { create(:group) }
  12. let(:user) { create(:agent) }
  13. before do
  14. user.groups << group
  15. create(:ticket, group: group, owner: user, state_name: 'open', pending_time: 1.day.ago)
  16. end
  17. it 'returns zero offset time if no time zone set' do
  18. get '/ical/tickets'
  19. expect(response.body).to match %r{DTSTART:\d{8}T0{6}Z}
  20. end
  21. it 'returns selected time zone' do
  22. Setting.set 'timezone_default', 'Europe/Vilnius'
  23. get '/ical/tickets'
  24. expect(response.body).to match %r{DTSTART;TZID=Europe/Vilnius:\d{8}T0{6}}
  25. end
  26. end
  27. # https://github.com/zammad/zammad/issues/3962
  28. context 'with request method PROPFIND', authenticated_as: :user do
  29. let(:user) { create(:agent) }
  30. it 'contains correct request method' do
  31. get '/ical/tickets', headers: { 'REQUEST_METHOD' => 'PROPFIND' }
  32. expect(response.request.request_method).to eq('PROPFIND')
  33. end
  34. it 'returns the desired calendar file' do
  35. get '/ical/tickets', headers: { 'REQUEST_METHOD' => 'PROPFIND' }
  36. expect(response.body).to match(%r{BEGIN:VCALENDAR})
  37. end
  38. end
  39. end