blob: 4433e18b86bbc1c8c437aba8db968e667a6231c2 (
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
|
RSpec.describe ApplicationPolicy, type: :policy do
let( :user_context ) { create_user_context(user: user, referential: referential) }
let( :referentail ) { create :referential }
let( :user ) { create :user }
subject { described_class }
permissions :organisation_match? do
it "denies a user with a different organisation" do
expect_it.not_to permit(user_context, referential)
end
it "allows a user with a different organisation" do
user.update_attribute :organisation, referential.organisation
expect_it.to permit(user_context, referential)
end
end
permissions :boiv_read_offer? do
context "user of a different organisation → " do
it "denies a user with a different organisation" do
expect_it.not_to permit(user_context, referential)
end
it "even if she has the permisson" do
add_permissions('boiv:read-offer', for_user: user)
expect_it.not_to permit(user_context, referential)
end
end
context "user of the same organisation → " do
before do
user.update_attribute :organisation, referential.organisation
end
it "denies if permission absent" do
expect_it.not_to permit(user_context, referential)
end
it "allows if permission present" do
add_permissions('boiv:read-offer', for_user: user)
expect_it.to permit(user_context, referential)
end
end
end
end
|