checklist_template_policy_spec.rb 962 B

123456789101112131415161718192021222324252627282930313233343536
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. describe ChecklistTemplatePolicy do
  4. subject(:policy) { described_class.new(user, record) }
  5. let(:record) { build(:checklist_template) }
  6. context 'when user is an agent' do
  7. let(:user) { create(:agent) }
  8. it { is_expected.to permit_actions(:show) }
  9. it { is_expected.to forbid_actions(:create, :update, :destroy) }
  10. end
  11. context 'when user is an admin' do
  12. let(:user) { create(:admin) }
  13. it { is_expected.to permit_actions(:show, :create, :update, :destroy) }
  14. context 'when checklist feature is disabled' do
  15. before do
  16. Setting.set('checklist', false)
  17. end
  18. it { is_expected.to forbid_actions(:show, :create, :update, :destroy) }
  19. end
  20. end
  21. context 'when user is a customer' do
  22. let(:user) { create(:customer) }
  23. it { is_expected.to forbid_actions(:show, :create, :update, :destroy) }
  24. end
  25. end