Skip to content

Commit

Permalink
fixup! Automatically tag bodies with few public requests
Browse files Browse the repository at this point in the history
  • Loading branch information
garethrees committed Oct 14, 2022
1 parent 81cd7cf commit 8e489c9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/models/public_body.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ def self.admin_title
]
end

# Set to 0 to prevent application of the not_many_requests tag
cattr_accessor :not_many_public_requests_size, default: 5

has_many :info_requests,
Expand Down
13 changes: 13 additions & 0 deletions spec/models/public_body_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1005,6 +1005,12 @@
end

describe 'when generating json for the api' do
around(:example) do |example|
orig = PublicBody.not_many_public_requests_size
PublicBody.not_many_public_requests_size = 0
example.run
PublicBody.not_many_public_requests_size = orig
end

let(:public_body) do
FactoryBot.create(:public_body,
Expand Down Expand Up @@ -1370,6 +1376,13 @@ def set_default_attributes(public_body)
end

RSpec.describe PublicBody, " when loading CSV files" do
around(:example) do |example|
orig = PublicBody.not_many_public_requests_size
PublicBody.not_many_public_requests_size = 0
example.run
PublicBody.not_many_public_requests_size = orig
end

before(:each) do
# InternalBody is created the first time it's accessed, which happens sometimes during imports,
# depending on the tag used. By accessing it here before every test, it doesn't disturb our checks later on
Expand Down

0 comments on commit 8e489c9

Please sign in to comment.