Skip to content

Commit 716be1b

Browse files
committed
Move view test to new partial
1 parent e78a1eb commit 716be1b

File tree

3 files changed

+30
-28
lines changed

3 files changed

+30
-28
lines changed

app/views/request_for_comments/_report.html.slim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
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')},

spec/views/reports/button.html.silm_spec.rb

Lines changed: 0 additions & 27 deletions
This file was deleted.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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

0 commit comments

Comments
 (0)