redirects_spec.rb 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe 'Unauthenticated redirect', authenticated_as: false, type: :system do
  4. it 'Sessions' do
  5. visit 'system/sessions'
  6. expect_current_route 'login'
  7. end
  8. it 'Profile' do
  9. visit 'profile/linked'
  10. expect_current_route 'login'
  11. end
  12. it 'Ticket' do
  13. visit 'ticket/zoom/1'
  14. expect_current_route 'login'
  15. end
  16. it 'Not existing route' do
  17. visit 'not_existing'
  18. expect_current_route 'not_existing'
  19. end
  20. context 'when public', authenticated_as: false do
  21. it 'does redirect to login if no access' do
  22. visit '#profile'
  23. expect_current_route 'login'
  24. end
  25. end
  26. context 'when customer', authenticated_as: :customer do
  27. let(:customer) { create(:customer) }
  28. it 'does redirect to ticket view if no access' do
  29. visit '#ticket/create'
  30. expect_current_route 'profile'
  31. end
  32. end
  33. context 'when agent', authenticated_as: :agent do
  34. let(:agent) { create(:agent) }
  35. it 'does redirect to ticket view if no access' do
  36. visit '#customer_ticket_new'
  37. expect_current_route 'profile'
  38. end
  39. end
  40. context 'when admin', authenticated_as: :admin do
  41. let(:admin) { create(:admin) }
  42. it 'does redirect to ticket view if no access' do
  43. visit '#customer_ticket_new'
  44. expect_current_route 'profile'
  45. end
  46. end
  47. end