Skip to content

Commit 6254781

Browse files
committed
added various let statements
1 parent 84725eb commit 6254781

File tree

2 files changed

+22
-16
lines changed

2 files changed

+22
-16
lines changed

spec/request/request_for_comments_spec.rb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,20 @@
33
require 'rails_helper'
44

55
RSpec.describe 'POST /request_for_comments/:rfc_id/report', type: :request do
6+
let(:user) { create(:learner) }
7+
let(:rfc) { create(:rfc) }
8+
let(:report_emails) { ['[email protected]'] }
9+
610
before do
7-
user = create(:learner)
811
allow_any_instance_of(ApplicationController).to receive(:current_user).and_return(user)
912
codeocean_config = instance_double(CodeOcean::Config)
1013
allow(CodeOcean::Config).to receive(:new).with(:code_ocean).and_return(codeocean_config)
1114
allow(codeocean_config).to receive(:read).and_return({
12-
content_moderation: {report_emails: ['[email protected]']},
15+
content_moderation: {report_emails:},
1316
})
1417
end
1518

1619
it 'sends an email to let admins know about the report' do
17-
rfc = create(:rfc)
18-
1920
expect { post(report_request_for_comment_path(rfc)) }
2021
.to have_enqueued_mail(ReportMailer, :report_content)
2122
.with(params: {reported_content: rfc}, args: [])

spec/system/request_for_comments_filter_system_spec.rb

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,15 @@
44

55
RSpec.describe 'Request_for_Comments' do
66
let(:user) { create(:teacher) }
7+
let(:report_emails) { [] }
78

89
before do
10+
codeocean_config = instance_double(CodeOcean::Config)
11+
allow(CodeOcean::Config).to receive(:new).with(:code_ocean).and_return(codeocean_config)
12+
allow(codeocean_config).to receive(:read).and_return({
13+
content_moderation: {report_emails:},
14+
})
15+
916
visit(sign_in_path)
1017
fill_in('email', with: user.email)
1118
fill_in('password', with: attributes_for(:teacher)[:password])
@@ -38,20 +45,18 @@
3845
expect(page).to have_css('ul.pagination')
3946
end
4047

41-
it 'allows reporting of RfCs', :js do
42-
codeocean_config = instance_double(CodeOcean::Config)
43-
allow(CodeOcean::Config).to receive(:new).with(:code_ocean).and_return(codeocean_config)
44-
allow(codeocean_config).to receive(:read).and_return({
45-
content_moderation: {report_emails: ['[email protected]']},
46-
})
48+
context 'when reporting is enabled' do
49+
let(:report_emails) { ['[email protected]'] }
4750

48-
request_for_comment = create(:rfc)
49-
visit(request_for_comment_path(request_for_comment))
51+
it 'allows reporting of RfCs', :js do
52+
request_for_comment = create(:rfc)
53+
visit(request_for_comment_path(request_for_comment))
5054

51-
accept_confirm do
52-
click_on I18n.t('request_for_comments.report.report')
53-
end
55+
accept_confirm do
56+
click_on I18n.t('request_for_comments.report.report')
57+
end
5458

55-
expect(page).to have_text(I18n.t('request_for_comments.report.reported'))
59+
expect(page).to have_text(I18n.t('request_for_comments.report.reported'))
60+
end
5661
end
5762
end

0 commit comments

Comments
 (0)