|
79 | 79 | end |
80 | 80 |
|
81 | 81 | context 'when the RfC visibility is considered' do |
82 | | - shared_examples 'grants access to everyone' do |params| |
| 82 | + shared_examples 'grants access to everyone' do |
83 | 83 | it 'grants access to everyone' do |
84 | 84 | %i[external_user teacher admin].each do |factory_name| |
85 | 85 | expect(policy).to permit(create(factory_name, consumer: viewer_consumer, study_groups: viewer_study_groups), rfc) |
86 | 86 | end |
87 | 87 | end |
88 | 88 |
|
89 | | - if params && params[:block_author] |
90 | | - it 'does not grant access to authors' do |
91 | | - expect(policy).not_to permit(rfc.author, rfc) |
92 | | - end |
93 | | - else |
94 | | - it 'grants access to authors' do |
95 | | - expect(policy).to permit(rfc.author, rfc) |
| 89 | + it 'grants access to authors' do |
| 90 | + expect(policy).to permit(rfc.author, rfc) |
| 91 | + end |
| 92 | + |
| 93 | + it 'grant access to other authors of the programming group' do |
| 94 | + rfc.submission.update(contributor: programming_group) |
| 95 | + expect(policy).to permit(viewer_other_group_member, rfc) |
| 96 | + end |
| 97 | + end |
| 98 | + |
| 99 | + shared_examples 'grants access to everyone but the author' do |
| 100 | + it 'grants access to everyone' 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) |
96 | 103 | end |
97 | 104 | end |
98 | 105 |
|
| 106 | + it 'does not grant access to authors' do |
| 107 | + expect(policy).not_to permit(rfc.author, rfc) |
| 108 | + end |
| 109 | + |
99 | 110 | it 'grant access to other authors of the programming group' do |
100 | 111 | rfc.submission.update(contributor: programming_group) |
101 | 112 | expect(policy).to permit(viewer_other_group_member, rfc) |
|
172 | 183 | permissions(:report?) do |
173 | 184 | let(:reports_enabled) { true } |
174 | 185 |
|
175 | | - it_behaves_like 'grants access to everyone', {block_author: true} |
| 186 | + it_behaves_like 'grants access to everyone but the author' |
176 | 187 | end |
177 | 188 | end |
178 | 189 |
|
|
230 | 241 | permissions(:report?) do |
231 | 242 | let(:reports_enabled) { true } |
232 | 243 |
|
233 | | - it_behaves_like 'grants access to everyone', {block_author: true} |
| 244 | + it_behaves_like 'grants access to everyone but the author' |
234 | 245 | end |
235 | 246 | end |
236 | 247 |
|
|
250 | 261 | permissions(:report?) do |
251 | 262 | let(:reports_enabled) { true } |
252 | 263 |
|
253 | | - it_behaves_like 'grants access to everyone', {block_author: true} |
| 264 | + it_behaves_like 'grants access to everyone but the author' |
254 | 265 | end |
255 | 266 | end |
256 | 267 | end |
|
331 | 342 | permissions(:report?) do |
332 | 343 | let(:reports_enabled) { true } |
333 | 344 |
|
334 | | - it_behaves_like 'grants access to everyone', {block_author: true} |
| 345 | + it_behaves_like 'grants access to everyone but the author' |
335 | 346 | end |
336 | 347 | end |
337 | 348 |
|
|
351 | 362 | permissions(:report?) do |
352 | 363 | let(:reports_enabled) { true } |
353 | 364 |
|
354 | | - it_behaves_like 'grants access to everyone', {block_author: true} |
| 365 | + it_behaves_like 'grants access to everyone but the author' |
355 | 366 | end |
356 | 367 | end |
357 | 368 | end |
|
448 | 459 | permissions(:report?) do |
449 | 460 | let(:reports_enabled) { true } |
450 | 461 |
|
451 | | - it_behaves_like 'grants access to everyone', {block_author: true} |
| 462 | + it_behaves_like 'grants access to everyone but the author' |
452 | 463 | end |
453 | 464 | end |
454 | 465 | end |
|
0 commit comments