Skip to content

Commit e87e32b

Browse files
committed
Add seperate shared context for reports
1 parent 299d923 commit e87e32b

File tree

1 file changed

+25
-14
lines changed

1 file changed

+25
-14
lines changed

spec/policies/request_for_comment_policy_spec.rb

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -79,23 +79,34 @@
7979
end
8080

8181
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
8383
it 'grants access to everyone' do
8484
%i[external_user teacher admin].each do |factory_name|
8585
expect(policy).to permit(create(factory_name, consumer: viewer_consumer, study_groups: viewer_study_groups), rfc)
8686
end
8787
end
8888

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)
96103
end
97104
end
98105

106+
it 'does not grant access to authors' do
107+
expect(policy).not_to permit(rfc.author, rfc)
108+
end
109+
99110
it 'grant access to other authors of the programming group' do
100111
rfc.submission.update(contributor: programming_group)
101112
expect(policy).to permit(viewer_other_group_member, rfc)
@@ -172,7 +183,7 @@
172183
permissions(:report?) do
173184
let(:reports_enabled) { true }
174185

175-
it_behaves_like 'grants access to everyone', {block_author: true}
186+
it_behaves_like 'grants access to everyone but the author'
176187
end
177188
end
178189

@@ -230,7 +241,7 @@
230241
permissions(:report?) do
231242
let(:reports_enabled) { true }
232243

233-
it_behaves_like 'grants access to everyone', {block_author: true}
244+
it_behaves_like 'grants access to everyone but the author'
234245
end
235246
end
236247

@@ -250,7 +261,7 @@
250261
permissions(:report?) do
251262
let(:reports_enabled) { true }
252263

253-
it_behaves_like 'grants access to everyone', {block_author: true}
264+
it_behaves_like 'grants access to everyone but the author'
254265
end
255266
end
256267
end
@@ -331,7 +342,7 @@
331342
permissions(:report?) do
332343
let(:reports_enabled) { true }
333344

334-
it_behaves_like 'grants access to everyone', {block_author: true}
345+
it_behaves_like 'grants access to everyone but the author'
335346
end
336347
end
337348

@@ -351,7 +362,7 @@
351362
permissions(:report?) do
352363
let(:reports_enabled) { true }
353364

354-
it_behaves_like 'grants access to everyone', {block_author: true}
365+
it_behaves_like 'grants access to everyone but the author'
355366
end
356367
end
357368
end
@@ -448,7 +459,7 @@
448459
permissions(:report?) do
449460
let(:reports_enabled) { true }
450461

451-
it_behaves_like 'grants access to everyone', {block_author: true}
462+
it_behaves_like 'grants access to everyone but the author'
452463
end
453464
end
454465
end

0 commit comments

Comments
 (0)