circleci
19265 of 21230 relevant lines covered (90.74%)
566.79 hits per line
1 |
class ApplicationPolicy |
7✔ |
2 |
attr_reader :user, :record |
7✔ |
3 |
|
|
4 |
def initialize(user, record, opts = {}) |
7✔ |
5 |
unless user || opts[:user_optional] |
2,013✔ |
6 |
raise Pundit::NotAuthorizedError, 'must be logged in' |
× |
7 |
end
|
|
8 |
raise Pundit::NotAuthorizedError, 'record does not exist' unless record |
2,013✔ |
9 |
@user = user
|
2,013✔ |
10 |
@record = record
|
2,013✔ |
11 |
end
|
|
12 |
|
|
13 |
def index? |
7✔ |
14 |
false
|
× |
15 |
end
|
|
16 |
|
|
17 |
def show? |
7✔ |
18 |
false
|
× |
19 |
end
|
|
20 |
|
|
21 |
def create? |
7✔ |
22 |
false
|
× |
23 |
end
|
|
24 |
|
|
25 |
def new? |
7✔ |
26 |
create? |
× |
27 |
end
|
|
28 |
|
|
29 |
def update? |
7✔ |
30 |
false
|
× |
31 |
end
|
|
32 |
|
|
33 |
def edit? |
7✔ |
34 |
update? |
20✔ |
35 |
end
|
|
36 |
|
|
37 |
def destroy? |
7✔ |
38 |
false
|
× |
39 |
end
|
|
40 |
|
|
41 |
def scope |
7✔ |
42 |
Pundit.policy_scope!(user, record.class)
|
× |
43 |
end
|
|
44 |
|
|
45 |
class Scope |
7✔ |
46 |
attr_reader :user, :scope |
7✔ |
47 |
|
|
48 |
def initialize(user, scope) |
7✔ |
49 |
@user = user
|
× |
50 |
@scope = scope
|
× |
51 |
end
|
|
52 |
|
|
53 |
def resolve |
7✔ |
54 |
scope |
× |
55 |
end
|
|
56 |
end
|
|
57 |
end
|