push
travis-ci
103 of 405 relevant lines covered (25.43%)
1.53 hits per line
1 |
class AnswerPolicy < ApplicationPolicy |
× |
2 |
def index? |
× |
3 |
true
|
× |
4 |
end
|
× |
5 |
|
|
6 |
def show? |
× |
7 |
case user.try(:role).try(:name) |
× |
8 |
when 'Administrator' |
× |
9 |
true
|
× |
10 |
when 'Librarian' |
× |
11 |
true
|
× |
12 |
when 'User' |
× |
13 |
if record.user == user
|
× |
14 |
true
|
× |
15 |
elsif record.question.shared?
|
× |
16 |
true
|
× |
17 |
else
|
× |
18 |
false
|
× |
19 |
end
|
× |
20 |
else
|
× |
21 |
true if record.question.shared? |
× |
22 |
end
|
× |
23 |
end
|
× |
24 |
|
|
25 |
def create? |
× |
26 |
user.try(:has_role?, 'User') |
× |
27 |
end
|
× |
28 |
|
|
29 |
def update? |
× |
30 |
case user.try(:role).try(:name) |
× |
31 |
when 'Administrator' |
× |
32 |
true
|
× |
33 |
when 'Librarian' |
× |
34 |
true
|
× |
35 |
when 'User' |
× |
36 |
true if record.user == user |
× |
37 |
end
|
× |
38 |
end
|
× |
39 |
|
|
40 |
def destroy? |
× |
41 |
update? |
× |
42 |
end
|
× |
43 |
end
|
× |