|
93 | 93 | end |
94 | 94 | end |
95 | 95 |
|
96 | | - shared_examples 'grants access to everyone but the author' do |
97 | | - it 'grants access to everyone but the author' do |
98 | | - %i[external_user teacher admin].each do |factory_name| |
99 | | - expect(policy).to permit(create(factory_name, consumer: viewer_consumer, study_groups: viewer_study_groups), rfc) |
| 96 | + shared_examples 'grants report permissions to everyone but the author' do |
| 97 | + permissions(:report?) do |
| 98 | + let(:reports_enabled) { true } |
| 99 | + |
| 100 | + it 'grants access to everyone but the author' do |
| 101 | + %i[external_user teacher admin].each do |factory_name| |
| 102 | + expect(policy).to permit(create(factory_name, consumer: viewer_consumer, study_groups: viewer_study_groups), rfc) |
| 103 | + end |
| 104 | + expect(policy).not_to permit(rfc.author, rfc) |
100 | 105 | end |
101 | | - expect(policy).not_to permit(rfc.author, rfc) |
102 | | - end |
103 | 106 |
|
104 | | - it 'grant access to other authors of the programming group' do |
105 | | - rfc.submission.update(contributor: programming_group) |
106 | | - expect(policy).to permit(viewer_other_group_member, rfc) |
| 107 | + it 'grant access to other authors of the programming group' do |
| 108 | + rfc.submission.update(contributor: programming_group) |
| 109 | + expect(policy).to permit(viewer_other_group_member, rfc) |
| 110 | + end |
107 | 111 | end |
108 | 112 | end |
109 | 113 |
|
|
128 | 132 | end |
129 | 133 | end |
130 | 134 |
|
131 | | - shared_examples 'grants access to admins and other authors only' do |
132 | | - it 'grants access to admins' do |
133 | | - expect(policy).to permit(create(:admin, consumer: viewer_consumer, study_groups: viewer_study_groups), rfc) |
134 | | - end |
| 135 | + shared_examples 'grants report permissions to admins and other authors only' do |
| 136 | + permissions(:report?) do |
| 137 | + let(:reports_enabled) { true } |
| 138 | + it 'grants access to admins' do |
| 139 | + expect(policy).to permit(create(:admin, consumer: viewer_consumer, study_groups: viewer_study_groups), rfc) |
| 140 | + end |
135 | 141 |
|
136 | | - it 'does not grant access to authors' do |
137 | | - expect(policy).not_to permit(rfc.author, rfc) |
138 | | - end |
| 142 | + it 'does not grant access to authors' do |
| 143 | + expect(policy).not_to permit(rfc.author, rfc) |
| 144 | + end |
139 | 145 |
|
140 | | - it 'grant access to other authors of the programming group' do |
141 | | - rfc.submission.update(contributor: programming_group) |
142 | | - expect(policy).to permit(viewer_other_group_member, rfc) |
143 | | - end |
| 146 | + it 'grant access to other authors of the programming group' do |
| 147 | + rfc.submission.update(contributor: programming_group) |
| 148 | + expect(policy).to permit(viewer_other_group_member, rfc) |
| 149 | + end |
144 | 150 |
|
145 | | - it 'does not grant access to all other users' do |
146 | | - %i[external_user teacher].each do |factory_name| |
147 | | - expect(policy).not_to permit(create(factory_name, consumer: viewer_consumer, study_groups: viewer_study_groups), rfc) |
| 151 | + it 'does not grant access to all other users' do |
| 152 | + %i[external_user teacher].each do |factory_name| |
| 153 | + expect(policy).not_to permit(create(factory_name, consumer: viewer_consumer, study_groups: viewer_study_groups), rfc) |
| 154 | + end |
148 | 155 | end |
149 | 156 | end |
150 | 157 | end |
|
174 | 181 | end |
175 | 182 | end |
176 | 183 |
|
177 | | - permissions(:report?) do |
178 | | - let(:reports_enabled) { true } |
179 | | - |
180 | | - it_behaves_like 'grants access to everyone but the author' |
181 | | - end |
| 184 | + it_behaves_like 'grants report permissions to everyone but the author' |
182 | 185 | end |
183 | 186 |
|
184 | 187 | context "when the viewer's rfc_visibility is set to consumer" do |
|
191 | 194 | end |
192 | 195 | end |
193 | 196 |
|
194 | | - permissions(:report?) do |
195 | | - let(:reports_enabled) { true } |
196 | | - |
197 | | - it_behaves_like 'grants access to admins and other authors only' |
198 | | - end |
| 197 | + it_behaves_like 'grants report permissions to admins and other authors only' |
199 | 198 | end |
200 | 199 |
|
201 | 200 | context "when the viewer's rfc_visibility is set to study_group" do |
|
208 | 207 | end |
209 | 208 | end |
210 | 209 |
|
211 | | - permissions(:report?) do |
212 | | - let(:reports_enabled) { true } |
213 | | - |
214 | | - it_behaves_like 'grants access to admins and other authors only' |
215 | | - end |
| 210 | + it_behaves_like 'grants report permissions to admins and other authors only' |
216 | 211 | end |
217 | 212 | end |
218 | 213 |
|
|
232 | 227 | end |
233 | 228 | end |
234 | 229 |
|
235 | | - permissions(:report?) do |
236 | | - let(:reports_enabled) { true } |
237 | | - |
238 | | - it_behaves_like 'grants access to everyone but the author' |
239 | | - end |
| 230 | + it_behaves_like 'grants report permissions to everyone but the author' |
240 | 231 | end |
241 | 232 |
|
242 | 233 | context 'when the viewer is from the same study group' do |
|
252 | 243 | end |
253 | 244 | end |
254 | 245 |
|
255 | | - permissions(:report?) do |
256 | | - let(:reports_enabled) { true } |
257 | | - |
258 | | - it_behaves_like 'grants access to everyone but the author' |
259 | | - end |
| 246 | + it_behaves_like 'grants report permissions to everyone but the author' |
260 | 247 | end |
261 | 248 | end |
262 | 249 | end |
|
275 | 262 | end |
276 | 263 | end |
277 | 264 |
|
278 | | - permissions(:report?) do |
279 | | - let(:reports_enabled) { true } |
280 | | - |
281 | | - it_behaves_like 'grants access to admins and other authors only' |
282 | | - end |
| 265 | + it_behaves_like 'grants report permissions to admins and other authors only' |
283 | 266 | end |
284 | 267 |
|
285 | 268 | context "when the viewer's rfc_visibility is set to consumer" do |
|
292 | 275 | end |
293 | 276 | end |
294 | 277 |
|
295 | | - permissions(:report?) do |
296 | | - let(:reports_enabled) { true } |
297 | | - |
298 | | - it_behaves_like 'grants access to admins and other authors only' |
299 | | - end |
| 278 | + it_behaves_like 'grants report permissions to admins and other authors only' |
300 | 279 | end |
301 | 280 |
|
302 | 281 | context "when the viewer's rfc_visibility is set to study_group" do |
|
309 | 288 | end |
310 | 289 | end |
311 | 290 |
|
312 | | - permissions(:report?) do |
313 | | - let(:reports_enabled) { true } |
314 | | - |
315 | | - it_behaves_like 'grants access to admins and other authors only' |
316 | | - end |
| 291 | + it_behaves_like 'grants report permissions to admins and other authors only' |
317 | 292 | end |
318 | 293 | end |
319 | 294 |
|
|
333 | 308 | end |
334 | 309 | end |
335 | 310 |
|
336 | | - permissions(:report?) do |
337 | | - let(:reports_enabled) { true } |
338 | | - |
339 | | - it_behaves_like 'grants access to everyone but the author' |
340 | | - end |
| 311 | + it_behaves_like 'grants report permissions to everyone but the author' |
341 | 312 | end |
342 | 313 |
|
343 | 314 | context 'when the viewer is from the same study group' do |
|
353 | 324 | end |
354 | 325 | end |
355 | 326 |
|
356 | | - permissions(:report?) do |
357 | | - let(:reports_enabled) { true } |
358 | | - |
359 | | - it_behaves_like 'grants access to everyone but the author' |
360 | | - end |
| 327 | + it_behaves_like 'grants report permissions to everyone but the author' |
361 | 328 | end |
362 | 329 | end |
363 | 330 | end |
|
376 | 343 | end |
377 | 344 | end |
378 | 345 |
|
379 | | - permissions(:report?) do |
380 | | - let(:reports_enabled) { true } |
381 | | - |
382 | | - it_behaves_like 'grants access to admins and other authors only' |
383 | | - end |
| 346 | + it_behaves_like 'grants report permissions to admins and other authors only' |
384 | 347 | end |
385 | 348 |
|
386 | 349 | context "when the viewer's rfc_visibility is set to consumer" do |
|
393 | 356 | end |
394 | 357 | end |
395 | 358 |
|
396 | | - permissions(:report?) do |
397 | | - let(:reports_enabled) { true } |
398 | | - |
399 | | - it_behaves_like 'grants access to admins and other authors only' |
400 | | - end |
| 359 | + it_behaves_like 'grants report permissions to admins and other authors only' |
401 | 360 | end |
402 | 361 |
|
403 | 362 | context "when the viewer's rfc_visibility is set to study_group" do |
|
410 | 369 | end |
411 | 370 | end |
412 | 371 |
|
413 | | - permissions(:report?) do |
414 | | - let(:reports_enabled) { true } |
415 | | - |
416 | | - it_behaves_like 'grants access to admins and other authors only' |
417 | | - end |
| 372 | + it_behaves_like 'grants report permissions to admins and other authors only' |
418 | 373 | end |
419 | 374 | end |
420 | 375 |
|
|
430 | 385 | end |
431 | 386 | end |
432 | 387 |
|
433 | | - permissions(:report?) do |
434 | | - let(:reports_enabled) { true } |
435 | | - |
436 | | - it_behaves_like 'grants access to admins and other authors only' |
437 | | - end |
| 388 | + it_behaves_like 'grants report permissions to admins and other authors only' |
438 | 389 | end |
439 | 390 |
|
440 | 391 | context 'when the viewer is from the same study group' do |
|
450 | 401 | end |
451 | 402 | end |
452 | 403 |
|
453 | | - permissions(:report?) do |
454 | | - let(:reports_enabled) { true } |
455 | | - |
456 | | - it_behaves_like 'grants access to everyone but the author' |
457 | | - end |
| 404 | + it_behaves_like 'grants report permissions to everyone but the author' |
458 | 405 | end |
459 | 406 | end |
460 | 407 | end |
|
0 commit comments