aboutsummaryrefslogtreecommitdiffstats
path: root/spec/spec_helper.rb
diff options
context:
space:
mode:
authorMark Longair <mhl@pobox.com>2013-11-04 11:06:13 +0000
committerMark Longair <mhl@pobox.com>2013-11-05 15:47:17 +0000
commit23ca1b442493f30f07cf80bdd20f8f060464bb92 (patch)
treec249c3491d0b3ef90ddd818934d2e5383b793723 /spec/spec_helper.rb
parentb16ed7188e0df7329da7c5d6c07ce16df2c0682d (diff)
For percentage stats, exclude hidden or unclassified requests
The WDTK volunteers pointed out that it's not fair to include hidden requests in the denominator, since they're typically hidden for a good reason (e.g. being vexatious, spam, etc.), and we have no information about those that are awaiting_description (i.e. unclassified) so they should be excluded as well.
Diffstat (limited to 'spec/spec_helper.rb')
-rw-r--r--spec/spec_helper.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 6e65018f1..9d16f6387 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -158,6 +158,31 @@ Spork.prefork do
ActiveRecord::Base.default_timezone = old_zone
end
+ # To test the statistics calculations, it's helpful to have the
+ # request fixtures in different states, but changing the fixtures
+ # themselves disrupts many other tests. This function takes a
+ # block, and runs that block with the info requests for the
+ # Geraldine Quango altered so that one is hidden and there's a
+ # successful one.
+ def with_hidden_and_successful_requests
+ external = info_requests(:external_request)
+ chicken = info_requests(:naughty_chicken_request)
+ old_external_prominence = external.prominence
+ old_chicken_described_state = chicken.described_state
+ begin
+ external.prominence = 'hidden'
+ external.save!
+ chicken.described_state = 'successful'
+ chicken.save!
+ yield
+ ensure
+ external.prominence = old_external_prominence
+ external.save!
+ chicken.described_state = old_chicken_described_state
+ chicken.save!
+ end
+ end
+
def load_test_categories
PublicBodyCategories.add(:en, [
"Local and regional",