external_data_source_policy_spec.rb 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. describe ExternalDataSourcePolicy do
  4. subject { described_class.new(user, record) }
  5. context 'when attribute type is Group' do
  6. let(:record) { 'Group' }
  7. context 'when user is admin' do
  8. let(:user) { create(:admin) }
  9. it { is_expected.to permit_action(:fetch) }
  10. end
  11. context 'when user is agent' do
  12. let(:user) { create(:agent) }
  13. it { is_expected.to forbid_action(:fetch) }
  14. end
  15. context 'when user is customer' do
  16. let(:user) { create(:customer) }
  17. it { is_expected.to forbid_action(:fetch) }
  18. end
  19. end
  20. context 'when attribute type is Organization' do
  21. let(:record) { 'Organization' }
  22. context 'when user is admin' do
  23. let(:user) { create(:admin) }
  24. it { is_expected.to permit_action(:fetch) }
  25. end
  26. context 'when user is agent' do
  27. let(:user) { create(:agent) }
  28. it { is_expected.to permit_action(:fetch) }
  29. end
  30. context 'when user is customer' do
  31. let(:user) { create(:customer) }
  32. it { is_expected.to forbid_action(:fetch) }
  33. end
  34. end
  35. context 'when attribute type is User' do
  36. let(:record) { 'User' }
  37. context 'when user is admin' do
  38. let(:user) { create(:admin) }
  39. it { is_expected.to permit_action(:fetch) }
  40. end
  41. context 'when user is agent' do
  42. let(:user) { create(:agent) }
  43. it { is_expected.to permit_action(:fetch) }
  44. end
  45. context 'when user is customer' do
  46. let(:user) { create(:customer) }
  47. it { is_expected.to forbid_action(:fetch) }
  48. end
  49. end
  50. context 'when attribute type is Ticket' do
  51. let(:record) { 'Ticket' }
  52. context 'when user is admin' do
  53. let(:user) { create(:admin) }
  54. it { is_expected.to permit_action(:fetch) }
  55. end
  56. context 'when user is agent' do
  57. let(:user) { create(:agent) }
  58. it { is_expected.to permit_action(:fetch) }
  59. end
  60. context 'when user is customer' do
  61. let(:user) { create(:customer) }
  62. it { is_expected.to permit_action(:fetch) }
  63. end
  64. end
  65. end