organization_policy_spec.rb 1005 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. # Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. describe OrganizationPolicy do
  4. subject { described_class.new(user, record) }
  5. let(:record) { create(:organization) }
  6. context 'when customer' do
  7. let(:user) { create(:customer, organization: record) }
  8. it { is_expected.to permit_actions(%i[show]) }
  9. it { is_expected.to forbid_actions(%i[update]) }
  10. end
  11. context 'when customer without organization' do
  12. let(:user) { create(:customer) }
  13. it { is_expected.to forbid_actions(%i[show update]) }
  14. end
  15. context 'when agent and customer' do
  16. let(:user) { create(:agent_and_customer, organization: record) }
  17. it { is_expected.to permit_actions(%i[show update]) }
  18. end
  19. context 'when agent' do
  20. let(:user) { create(:agent) }
  21. it { is_expected.to permit_actions(%i[show update]) }
  22. end
  23. context 'when admin' do
  24. let(:user) { create(:admin) }
  25. it { is_expected.to permit_actions(%i[show update]) }
  26. end
  27. end