diff options
author | Louise Crow <louise.crow@gmail.com> | 2013-09-04 09:49:34 +0100 |
---|---|---|
committer | Louise Crow <louise.crow@gmail.com> | 2013-09-04 09:49:34 +0100 |
commit | 95afa296f8989ac691df24cc28a963c06a4c86e3 (patch) | |
tree | b1b80813f963ee4a417b05d4bb4d012648d30dff /spec/controllers/public_body_controller_spec.rb | |
parent | 05f9fca1fb2161e078429b6a1f3796a0bf13eade (diff) | |
parent | 4656b24591593bdf5521030ce6bdf68baec6d160 (diff) |
Merge branch 'body-statistics' into rails-3-develop
Diffstat (limited to 'spec/controllers/public_body_controller_spec.rb')
-rw-r--r-- | spec/controllers/public_body_controller_spec.rb | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/spec/controllers/public_body_controller_spec.rb b/spec/controllers/public_body_controller_spec.rb index 4e1841164..92130f3d0 100644 --- a/spec/controllers/public_body_controller_spec.rb +++ b/spec/controllers/public_body_controller_spec.rb @@ -208,6 +208,41 @@ 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 + config['PUBLIC_BODY_STATISTICS_PAGE'] = true + 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 + # a Float (rather than NilClass, say): + 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 |