aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/public_body_controller_spec.rb34
-rw-r--r--spec/fixtures/public_bodies.yml18
2 files changed, 52 insertions, 0 deletions
diff --git a/spec/controllers/public_body_controller_spec.rb b/spec/controllers/public_body_controller_spec.rb
index 4e1841164..000d1cf80 100644
--- a/spec/controllers/public_body_controller_spec.rb
+++ b/spec/controllers/public_body_controller_spec.rb
@@ -208,6 +208,40 @@ describe PublicBodyController, "when showing JSON version for API" do
end
+describe PublicBodyController, "when showing public body statistics" do
+
+ it "should render the right template with the right data" do
+ config = MySociety::Config.load_default()
+ config['MINIMUM_REQUESTS_FOR_STATISTICS'] = 1
+ get :statistics
+ response.should render_template('public_body/statistics')
+ # There are 5 different graphs we're creating at the moment.
+ assigns[:graph_list].length.should == 5
+ # The first is the only one with raw values, the rest are
+ # percentages with error bars:
+ assigns[:graph_list].each_with_index do |graph, index|
+ if index == 0
+ graph['errorbars'].should be_false
+ graph['x_values'].length.should == 4
+ graph['x_values'].should == [0, 1, 2, 3]
+ graph['y_values'].should == [1, 2, 2, 4]
+ else
+ graph['errorbars'].should be_true
+ # Just check the first one:
+ if index == 1
+ graph['x_values'].should == [0, 1, 2, 3]
+ graph['y_values'].should == [0, 50, 100, 100]
+ end
+ # Check that at least every confidence interval value is
+ # numeric:
+ graph['cis_below'].each { |v| v.should be_instance_of(Float) }
+ graph['cis_above'].each { |v| v.should be_instance_of(Float) }
+ end
+ end
+ end
+
+end
+
describe PublicBodyController, "when doing type ahead searches" do
render_views
diff --git a/spec/fixtures/public_bodies.yml b/spec/fixtures/public_bodies.yml
index 65cba4b28..6eae53db8 100644
--- a/spec/fixtures/public_bodies.yml
+++ b/spec/fixtures/public_bodies.yml
@@ -12,6 +12,9 @@ geraldine_public_body:
created_at: 2007-10-24 10:51:01.161639
api_key: 1
info_requests_count: 4
+ info_requests_successful_count: 0
+ info_requests_not_held_count: 0
+ info_requests_overdue_count: 3
humpadink_public_body:
name: "Department for Humpadinking"
first_letter: D
@@ -27,6 +30,9 @@ humpadink_public_body:
notes: An albatross told me!!!
api_key: 2
info_requests_count: 2
+ info_requests_successful_count: 1
+ info_requests_not_held_count: 0
+ info_requests_overdue_count: 1
forlorn_public_body:
name: "Department of Loneliness"
first_letter: D
@@ -42,6 +48,9 @@ forlorn_public_body:
notes: A very lonely public body that no one has corresponded with
api_key: 3
info_requests_count: 0
+ info_requests_successful_count: 0
+ info_requests_not_held_count: 0
+ info_requests_overdue_count: 0
silly_walks_public_body:
id: 5
version: 1
@@ -57,6 +66,9 @@ silly_walks_public_body:
notes: You know the one.
api_key: 4
info_requests_count: 2
+ info_requests_successful_count: 2
+ info_requests_not_held_count: 0
+ info_requests_overdue_count: 0
sensible_walks_public_body:
id: 6
version: 1
@@ -72,6 +84,9 @@ sensible_walks_public_body:
created_at: 2008-10-25 10:51:01.161639
api_key: 5
info_requests_count: 1
+ info_requests_successful_count: 1
+ info_requests_not_held_count: 0
+ info_requests_overdue_count: 0
other_public_body:
id: 7
version: 1
@@ -87,3 +102,6 @@ other_public_body:
created_at: 2008-10-25 10:51:01.161639
api_key: 6
info_requests_count: 0
+ info_requests_successful_count: 0
+ info_requests_not_held_count: 0
+ info_requests_overdue_count: 0