trabajo-afectivo/spec/policies/organization_policy_spec.rb
2022-01-01 14:38:12 +01:00

40 lines
1,005 B
Ruby

# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
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.to forbid_actions(%i[update]) }
end
context 'when customer without organization' do
let(:user) { create(:customer) }
it { is_expected.to forbid_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