Skip to content

Commit cb746af

Browse files
committed
View test with rendering in before block
1 parent dc1f263 commit cb746af

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

spec/views/request_for_comments/report.html.silm_spec.rb

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,23 @@
77

88
before do
99
assign(:current_user, build_stubbed(:external_user))
10-
end
11-
12-
it 'displays the report button when the request is authorized' do
13-
report_policy = instance_double(RequestForCommentPolicy, report?: true)
1410
allow(view).to receive(:policy).with(rfc).and_return(report_policy)
15-
1611
render('request_for_comments/report', request_for_comment: rfc)
17-
18-
expect(rendered).to have_button
1912
end
2013

21-
it 'dose not display 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)
14+
context 'when reporting is allowed' do
15+
let(:report_policy) { instance_double(RequestForCommentPolicy, report?: true) }
2416

25-
render('request_for_comments/report', request_for_comment: rfc)
17+
it 'displays the report button when the request is authorized' do
18+
expect(rendered).to have_button
19+
end
20+
end
21+
22+
context 'when reporting is prohibbeted' do
23+
let(:report_policy) { instance_double(RequestForCommentPolicy, report?: false) }
2624

27-
expect(rendered).to have_no_button
25+
it 'dose not display report button when reporting is not authorized' do
26+
expect(rendered).to have_no_button
27+
end
2828
end
2929
end

0 commit comments

Comments
 (0)