organization_policy_spec.rb 936 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. require 'rails_helper'
  2. describe OrganizationPolicy do
  3. subject { described_class.new(user, record) }
  4. let(:record) { create(:organization) }
  5. context 'when customer' do
  6. let(:user) { create(:customer, organization: record) }
  7. it { is_expected.to permit_actions(%i[show]) }
  8. it { is_expected.not_to permit_actions(%i[update]) }
  9. end
  10. context 'when customer without organization' do
  11. let(:user) { create(:customer) }
  12. it { is_expected.not_to permit_actions(%i[show update]) }
  13. end
  14. context 'when agent and customer' do
  15. let(:user) { create(:agent_and_customer, organization: record) }
  16. it { is_expected.to permit_actions(%i[show update]) }
  17. end
  18. context 'when agent' do
  19. let(:user) { create(:agent) }
  20. it { is_expected.to permit_actions(%i[show update]) }
  21. end
  22. context 'when admin' do
  23. let(:user) { create(:admin) }
  24. it { is_expected.to permit_actions(%i[show update]) }
  25. end
  26. end