/
content_policy_spec.rb
61 lines (42 loc) · 1.44 KB
/
content_policy_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
require 'rails_helper'
describe KnowledgeBase::Answer::Translation::ContentPolicy do
subject(:policy) { described_class.new(user, record) }
include_context 'basic Knowledge Base'
let(:record) { answer.translation.content }
context 'without user' do
let(:user) { nil }
context 'with a public answer' do
let(:answer) { published_answer }
it { is_expected.to permit_actions :show }
it { is_expected.to forbid_actions :destroy }
end
context 'with a non public answer' do
let(:answer) { internal_answer }
it { is_expected.to forbid_actions :show, :destroy }
end
end
context 'with kb editor' do
let(:user) { create(:admin) }
context 'with an internal answer' do
let(:answer) { internal_answer }
it { is_expected.to permit_actions :show, :destroy }
end
context 'with a draft answer' do
let(:answer) { draft_answer }
it { is_expected.to permit_actions :show, :destroy }
end
end
context 'with kb reader' do
let(:user) { create(:agent) }
context 'with an internal answer' do
let(:answer) { internal_answer }
it { is_expected.to permit_action :show }
it { is_expected.to forbid_action :destroy }
end
context 'with a draft answer' do
let(:answer) { draft_answer }
it { is_expected.to forbid_actions :show, :destroy }
end
end
end