1234567891011121314151617181920212223242526272829303132333435363738 |
- require 'rails_helper'
- describe OrganizationPolicy do
- subject { described_class.new(user, record) }
- let(:record) { create(:organization) }
- context 'when customer' do
- let(:user) { create(:customer, organization: record) }
- it { is_expected.to permit_actions(%i[show]) }
- it { is_expected.not_to permit_actions(%i[update]) }
- end
- context 'when customer without organization' do
- let(:user) { create(:customer) }
- it { is_expected.not_to permit_actions(%i[show update]) }
- end
- context 'when agent and customer' do
- let(:user) { create(:agent_and_customer, organization: record) }
- it { is_expected.to permit_actions(%i[show update]) }
- end
- context 'when agent' do
- let(:user) { create(:agent) }
- it { is_expected.to permit_actions(%i[show update]) }
- end
- context 'when admin' do
- let(:user) { create(:admin) }
- it { is_expected.to permit_actions(%i[show update]) }
- end
- end
|