From 0302d06b4bc60986e666710bbf2dcb17b3dcfd87 Mon Sep 17 00:00:00 2001 From: Gareth Rees Date: Fri, 14 Oct 2022 09:22:15 +0100 Subject: [PATCH] Only apply not many requests to requestable bodies Our main intent with this tag is for it to act as a hook for suggesting some good basic requests to "bootstrap transparency". There's no point in doing this if users can't make requests to the body. --- app/models/public_body.rb | 6 +++++- app/views/admin_public_body/_form.html.erb | 2 +- spec/models/public_body_spec.rb | 12 ++++++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/app/models/public_body.rb b/app/models/public_body.rb index 52032ab319..b8c7d5900c 100644 --- a/app/models/public_body.rb +++ b/app/models/public_body.rb @@ -1002,10 +1002,14 @@ def missing_email? end def update_not_many_requests_tag - if info_requests.is_searchable.size < not_many_public_requests_size + if is_requestable? && not_many_public_requests? add_tag_if_not_already_present('not_many_requests') else remove_tag('not_many_requests') end end + + def not_many_public_requests? + info_requests.is_searchable.size < not_many_public_requests_size + end end diff --git a/app/views/admin_public_body/_form.html.erb b/app/views/admin_public_body/_form.html.erb index 79f474e2f7..2a0db0024c 100644 --- a/app/views/admin_public_body/_form.html.erb +++ b/app/views/admin_public_body/_form.html.erb @@ -70,7 +70,7 @@ diff --git a/spec/models/public_body_spec.rb b/spec/models/public_body_spec.rb index 9f8daf256f..b1e97d4f05 100644 --- a/spec/models/public_body_spec.rb +++ b/spec/models/public_body_spec.rb @@ -255,6 +255,18 @@ expect(public_body).not_to be_tagged('not_many_requests') end end + + context 'when a not_requestable body is is tagged not_many_requests' do + let!(:public_body) { FactoryBot.create(:public_body) } + + before { public_body.add_tag_if_not_already_present('not_many_requests') } + before { public_body.update(request_email: '') } + + it 'removes the not many requests tag' do + subject + expect(public_body).not_to be_tagged('not_many_requests') + end + end end describe '#name' do