Skip to content

Commit 7b81957

Browse files
committed
fix index policy
1 parent cf91cd6 commit 7b81957

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

app/policies/comment_policy.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def show?
1616
end
1717

1818
def index?
19-
show?
19+
everyone
2020
end
2121

2222
def report?

spec/policies/comment_policy_spec.rb

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,17 @@
55
RSpec.describe CommentPolicy do
66
let(:user_types) { %i[learner teacher admin] }
77

8-
permissions :create?, :show?, :index? do
8+
permissions :index? do
9+
let(:comment) { build_stubbed(:comment) }
10+
11+
it 'grants access to all user types' do
12+
user_types.each do |user_type|
13+
expect(described_class).to permit(build_stubbed(user_type), comment)
14+
end
15+
end
16+
end
17+
18+
permissions :create?, :show? do
919
let(:comment) { build_stubbed(:comment) }
1020

1121
it 'grants access to all user types' do

0 commit comments

Comments
 (0)