diff options
author | Louise Crow <louise.crow@gmail.com> | 2013-11-07 15:31:37 +0000 |
---|---|---|
committer | Louise Crow <louise.crow@gmail.com> | 2013-11-07 15:31:37 +0000 |
commit | 9541299e871bfd82d9c48745cce721a919dbde73 (patch) | |
tree | b25aad32648fe1915c8d8b6b87713e57a848948d /spec/spec_helper.rb | |
parent | 9bb6e1cc43563278ad038415de9e71f8cb21793c (diff) | |
parent | 7c8dccba9d266c479df2c125b724f8e12811d05f (diff) |
Merge branch 'rails-3-develop' of ssh://git.mysociety.org/data/git/public/alaveteli into rails-3-develop
Diffstat (limited to 'spec/spec_helper.rb')
-rw-r--r-- | spec/spec_helper.rb | 25 |
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", |