push
github
7 of 7 new or added lines in 3 files covered. (100.0%)
4098 of 4846 relevant lines covered (84.56%)
44.65 hits per line
1 |
# frozen_string_literal: true
|
|
2 |
|
|
3 |
class OptimizationPolicy < ApplicationPolicy |
1✔ |
4 |
class Scope < Scope |
1✔ |
5 |
def resolve |
1✔ |
|
if user.admin?
|
1✔ |
|
scope.all |
× |
8 |
else
|
|
|
scope.with_role(:owner, user)
|
1✔ |
10 |
end
|
|
11 |
end
|
|
12 |
end
|
|
13 |
|
|
14 |
def create? |
1✔ |
15 |
true
|
28✔ |
16 |
end
|
|
17 |
|
|
18 |
def index? |
1✔ |
19 |
show? |
× |
20 |
end
|
|
21 |
|
|
22 |
def show? |
1✔ |
23 |
(@user.admin? || @user.has_role?(:owner, @record)) |
7✔ |
24 |
end
|
|
25 |
|
|
26 |
def update? |
1✔ |
|
@user.has_role?(:owner, @record) |
2✔ |
28 |
end
|
|
29 |
|
|
30 |
def destroy? |
1✔ |
|
show? |
2✔ |
32 |
end
|
|
33 |
|
|
34 |
def select? |
1✔ |
35 |
show? |
4✔ |
36 |
end
|
|
37 |
|
|
38 |
def compare? |
1✔ |
39 |
show? |
× |
40 |
end
|
|
41 |
|
|
42 |
def download? |
1✔ |
43 |
show? |
× |
44 |
end
|
|
45 |
end
|