Skip to content

Commit 79b2465

Browse files
committed
only allow RfCs to be reported when the user is allowed to see them
1 parent c3e5d75 commit 79b2465

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

app/policies/request_for_comment_policy.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def rfcs_with_my_comments?
4242
end
4343

4444
def report?
45-
report_receiver_configured? && !author?
45+
report_receiver_configured? && show? && !author?
4646
end
4747

4848
private

spec/policies/request_for_comment_policy_spec.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,14 @@
317317
end
318318
end
319319

320+
it 'dose not allow reports when the RfC is not accessable' do
321+
allow(policy).to receive(:show?).and_return(false) # rubocop:disable RSpec/SubjectStub
322+
323+
%i[admin external_user teacher].each do |factory_name|
324+
expect(policy).not_to permit(create(factory_name), Comment.new)
325+
end
326+
end
327+
320328
it 'dose not allow reports when no report email is configured' do
321329
codeocean_config = instance_double(CodeOcean::Config)
322330
allow(CodeOcean::Config).to receive(:new).with(:code_ocean).and_return(codeocean_config)

0 commit comments

Comments
 (0)