|
5 | 5 | RSpec.describe RequestForCommentPolicy do |
6 | 6 | subject(:policy) { described_class } |
7 | 7 |
|
8 | | - let(:report_emails) { [] } |
| 8 | + let(:reports_enabled) { false } |
9 | 9 |
|
10 | 10 | before do |
11 | | - codeocean_config = instance_double(CodeOcean::Config) |
12 | | - allow(CodeOcean::Config).to receive(:new).with(:code_ocean).and_return(codeocean_config) |
13 | | - allow(codeocean_config).to receive(:read).and_return({ |
14 | | - content_moderation: {report_emails:}, |
15 | | - }) |
| 11 | + stub_const('RequestForCommentPolicy::REPORT_RECEIVER_CONFIGURED', reports_enabled) |
16 | 12 | end |
17 | 13 |
|
18 | 14 | context 'when the RfC visibility is not considered' do |
|
59 | 55 |
|
60 | 56 | permissions(:report?) do |
61 | 57 | context 'when report emails are configured' do |
62 | | - let(:report_emails) { ['[email protected]'] } |
| 58 | + let(:reports_enabled) { true } |
63 | 59 |
|
64 | 60 | it 'allows anyone to report RfCs' do |
65 | 61 | %i[admin external_user teacher].each do |factory_name| |
|
69 | 65 | end |
70 | 66 |
|
71 | 67 | context 'when no report email is configured' do |
72 | | - let(:report_emails) { [] } |
73 | | - |
74 | 68 | it 'does not allow reports from anyone' do |
75 | 69 | %i[admin external_user teacher].each do |factory_name| |
76 | 70 | expect(policy).not_to permit(create(factory_name), RequestForComment.new) |
|
172 | 166 | end |
173 | 167 |
|
174 | 168 | permissions(:report?) do |
175 | | - let(:report_emails) { ['[email protected]'] } |
| 169 | + let(:reports_enabled) { true } |
176 | 170 |
|
177 | 171 | it_behaves_like 'grants access to everyone', {block_author: true} |
178 | 172 | end |
|
189 | 183 | end |
190 | 184 |
|
191 | 185 | permissions(:report?) do |
192 | | - let(:report_emails) { ['[email protected]'] } |
| 186 | + let(:reports_enabled) { true } |
193 | 187 |
|
194 | 188 | it_behaves_like 'grants access to admins only' |
195 | 189 | end |
|
206 | 200 | end |
207 | 201 |
|
208 | 202 | permissions(:report?) do |
209 | | - let(:report_emails) { ['[email protected]'] } |
| 203 | + let(:reports_enabled) { true } |
210 | 204 |
|
211 | 205 | it_behaves_like 'grants access to admins only' |
212 | 206 | end |
|
230 | 224 | end |
231 | 225 |
|
232 | 226 | permissions(:report?) do |
233 | | - let(:report_emails) { ['[email protected]'] } |
| 227 | + let(:reports_enabled) { true } |
234 | 228 |
|
235 | 229 | it_behaves_like 'grants access to everyone', {block_author: true} |
236 | 230 | end |
|
250 | 244 | end |
251 | 245 |
|
252 | 246 | permissions(:report?) do |
253 | | - let(:report_emails) { ['[email protected]'] } |
| 247 | + let(:reports_enabled) { true } |
254 | 248 |
|
255 | 249 | it_behaves_like 'grants access to everyone', {block_author: true} |
256 | 250 | end |
|
273 | 267 | end |
274 | 268 |
|
275 | 269 | permissions(:report?) do |
276 | | - let(:report_emails) { ['[email protected]'] } |
| 270 | + let(:reports_enabled) { true } |
277 | 271 |
|
278 | 272 | it_behaves_like 'grants access to admins only' |
279 | 273 | end |
|
290 | 284 | end |
291 | 285 |
|
292 | 286 | permissions(:report?) do |
293 | | - let(:report_emails) { ['[email protected]'] } |
| 287 | + let(:reports_enabled) { true } |
294 | 288 |
|
295 | 289 | it_behaves_like 'grants access to admins only' |
296 | 290 | end |
|
307 | 301 | end |
308 | 302 |
|
309 | 303 | permissions(:report?) do |
310 | | - let(:report_emails) { ['[email protected]'] } |
| 304 | + let(:reports_enabled) { true } |
311 | 305 |
|
312 | 306 | it_behaves_like 'grants access to admins only' |
313 | 307 | end |
|
331 | 325 | end |
332 | 326 |
|
333 | 327 | permissions(:report?) do |
334 | | - let(:report_emails) { ['[email protected]'] } |
| 328 | + let(:reports_enabled) { true } |
335 | 329 |
|
336 | 330 | it_behaves_like 'grants access to everyone', {block_author: true} |
337 | 331 | end |
|
351 | 345 | end |
352 | 346 |
|
353 | 347 | permissions(:report?) do |
354 | | - let(:report_emails) { ['[email protected]'] } |
| 348 | + let(:reports_enabled) { true } |
355 | 349 |
|
356 | 350 | it_behaves_like 'grants access to everyone', {block_author: true} |
357 | 351 | end |
|
374 | 368 | end |
375 | 369 |
|
376 | 370 | permissions(:report?) do |
377 | | - let(:report_emails) { ['[email protected]'] } |
| 371 | + let(:reports_enabled) { true } |
378 | 372 |
|
379 | 373 | it_behaves_like 'grants access to admins only' |
380 | 374 | end |
|
391 | 385 | end |
392 | 386 |
|
393 | 387 | permissions(:report?) do |
394 | | - let(:report_emails) { ['[email protected]'] } |
| 388 | + let(:reports_enabled) { true } |
395 | 389 |
|
396 | 390 | it_behaves_like 'grants access to admins only' |
397 | 391 | end |
|
408 | 402 | end |
409 | 403 |
|
410 | 404 | permissions(:report?) do |
411 | | - let(:report_emails) { ['[email protected]'] } |
| 405 | + let(:reports_enabled) { true } |
412 | 406 |
|
413 | 407 | it_behaves_like 'grants access to admins only' |
414 | 408 | end |
|
428 | 422 | end |
429 | 423 |
|
430 | 424 | permissions(:report?) do |
431 | | - let(:report_emails) { ['[email protected]'] } |
| 425 | + let(:reports_enabled) { true } |
432 | 426 |
|
433 | 427 | it_behaves_like 'grants access to admins only' |
434 | 428 | end |
|
448 | 442 | end |
449 | 443 |
|
450 | 444 | permissions(:report?) do |
451 | | - let(:report_emails) { ['[email protected]'] } |
| 445 | + let(:reports_enabled) { true } |
452 | 446 |
|
453 | 447 | it_behaves_like 'grants access to everyone', {block_author: true} |
454 | 448 | end |
|
0 commit comments