signature_policy_spec.rb 912 B

12345678910111213141516171819202122232425262728293031323334
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. describe SignaturePolicy do
  4. subject { described_class.new(user, record) }
  5. let(:record) { create(:signature) }
  6. context 'when user is admin' do
  7. let(:user) { create(:admin) }
  8. it { is_expected.to permit_actions(:show, :create, :update, :destroy) }
  9. end
  10. context 'when user is agent' do
  11. let(:user) { create(:agent) }
  12. it { is_expected.to permit_actions(:show) }
  13. it { is_expected.to forbid_actions(:create, :update, :destroy) }
  14. context 'when signature is inactive' do
  15. let(:record) { create(:signature, active: false) }
  16. it { is_expected.to forbid_actions(:show, :create, :update, :destroy) }
  17. end
  18. end
  19. context 'when user is customer' do
  20. let(:user) { create(:customer) }
  21. it { is_expected.to forbid_actions(:show, :create, :update, :destroy) }
  22. end
  23. end