blob: 37c3e68fd5f466e92f242edd7d3e86357bfb4703 (
plain)
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
62
63
64
65
66
67
68
69
70
71
72
73
|
# frozen_string_literal: true
RSpec.shared_examples 'resource with exportable associations' do
before do
stub_licensed_features(stubbed_features) if stubbed_features.any?
end
describe '#exportable_association?' do
let(:association) { single_association }
subject { resource.exportable_association?(association, current_user: user) }
it { is_expected.to be_falsey }
context 'when user can read resource' do
before do
group.add_developer(user)
end
it { is_expected.to be_falsey }
context "when user can read resource's association" do
before do
other_group.add_developer(user)
end
it { is_expected.to be_truthy }
context 'for an unknown association' do
let(:association) { :foo }
it { is_expected.to be_falsey }
end
context 'for an unauthenticated user' do
let(:user) { nil }
it { is_expected.to be_falsey }
end
end
end
end
describe '#readable_records' do
subject { resource.readable_records(association, current_user: user) }
before do
group.add_developer(user)
end
context 'when association not supported' do
let(:association) { :foo }
it { is_expected.to be_nil }
end
context 'when association is `:notes`' do
let(:association) { :notes }
it { is_expected.to match_array([readable_note]) }
context 'when user have access' do
before do
other_group.add_developer(user)
end
it 'returns all records' do
is_expected.to match_array([readable_note, restricted_note])
end
end
end
end
end
|