Skip to content

Commit

Permalink
Only apply not many requests to requestable bodies
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
garethrees committed Nov 10, 2022
1 parent e6cbc64 commit 0302d06
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
6 changes: 5 additions & 1 deletion app/models/public_body.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion app/views/admin_public_body/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@

<ul>
<li><code>missing_email</code> users can help source missing request addresses via a <%= link_to 'public search', list_public_bodies_by_tag_path('missing_email') %>.</li>
<li><code>not_many_requests</code> users can find low-transparency bodies via a <%= link_to 'public search', list_public_bodies_by_tag_path('not_many_requests') %>.</li>
<li><code>not_many_requests</code> users can find low-transparency bodies via a <%= link_to 'public search', list_public_bodies_by_tag_path('not_many_requests') %>. Only applied to bodies that are requestable.</li>
</ul>
</div>
</div>
Expand Down
12 changes: 12 additions & 0 deletions spec/models/public_body_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0302d06

Please sign in to comment.