Skip to content

Commit ca733d9

Browse files
committed
Spec improvments
1 parent f990f7e commit ca733d9

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

spec/mailers/user_content_report_mailer_spec.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,15 @@
1111
let(:human_model_name) { 'Reported model' }
1212
let(:course_url) { 'https://example.com/course/1' }
1313

14-
before do
15-
user_content_report = instance_double(UserContentReport,
14+
let(:user_content_report) do
15+
instance_double(UserContentReport,
1616
human_model_name:,
1717
reported_message:,
1818
related_request_for_comment: instance_double(RequestForComment),
1919
course_url:)
20+
end
21+
22+
before do
2023
allow(UserContentReport).to receive(:new).with(reported_content:).and_return(user_content_report)
2124
end
2225

spec/policies/comment_policy_spec.rb

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,19 @@
2424
end
2525
end
2626

27-
it 'does not grant access to users who have no access to the RfC' do
28-
learner = build_stubbed(:learner)
29-
rfc_policy = instance_double(RequestForCommentPolicy, show?: false)
30-
allow(RequestForCommentPolicy).to receive(:new).with(learner, comment.request_for_comment)
31-
.and_return(rfc_policy)
27+
context 'without access to the RfC' do
28+
let(:learner) { build_stubbed(:learner) }
29+
let(:rfc_policy) { instance_double(RequestForCommentPolicy, show?: false) }
3230

33-
expect(described_class).not_to permit(learner, comment)
31+
before do
32+
allow(RequestForCommentPolicy).to receive(:new)
33+
.with(learner, comment.request_for_comment)
34+
.and_return(rfc_policy)
35+
end
36+
37+
it 'does not grant access' do
38+
expect(described_class).not_to permit(learner, comment)
39+
end
3440
end
3541
end
3642

0 commit comments

Comments
 (0)