2022-01-01 13:38:12 +00:00
|
|
|
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
|
2021-06-01 12:20:20 +00:00
|
|
|
|
2020-08-20 07:10:08 +00:00
|
|
|
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]) }
|
2021-07-23 13:07:16 +00:00
|
|
|
it { is_expected.to forbid_actions(%i[update]) }
|
2020-08-20 07:10:08 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'when customer without organization' do
|
|
|
|
let(:user) { create(:customer) }
|
|
|
|
|
2021-07-23 13:07:16 +00:00
|
|
|
it { is_expected.to forbid_actions(%i[show update]) }
|
2020-08-20 07:10:08 +00:00
|
|
|
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
|