File tree Expand file tree Collapse file tree 3 files changed +30
-28
lines changed
Expand file tree Collapse file tree 3 files changed +30
-28
lines changed Original file line number Diff line number Diff line change 1- - if policy(@ request_for_comment ).report?
1+ - if policy(request_for_comment).report?
22 .text-end
33 = button_to t(' .report' ), report_request_for_comment_path(request_for_comment),
44 data: {confirm: t(' .confirm' )},
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ # frozen_string_literal: true
2+
3+ require 'rails_helper'
4+
5+ RSpec . describe 'request_for_comments/report.html.slim' do
6+ let ( :rfc ) { build_stubbed ( :rfc ) }
7+
8+ before do
9+ assign ( :current_user , build_stubbed ( :external_user ) )
10+ end
11+
12+ it 'displayes the report button when the request is authorized' do
13+ report_policy = instance_double ( RequestForCommentPolicy , report? : true )
14+ allow ( view ) . to receive ( :policy ) . with ( rfc ) . and_return ( report_policy )
15+
16+ render ( 'request_for_comments/report' , request_for_comment : rfc )
17+
18+ expect ( rendered ) . to have_button
19+ end
20+
21+ it 'has not report button when reporting is not authorized' do
22+ report_policy = instance_double ( RequestForCommentPolicy , report? : false )
23+ allow ( view ) . to receive ( :policy ) . with ( rfc ) . and_return ( report_policy )
24+
25+ render ( 'request_for_comments/report' , request_for_comment : rfc )
26+
27+ expect ( rendered ) . to have_no_button
28+ end
29+ end
You can’t perform that action at this time.
0 commit comments