diff options
author | Hakim Cassimally <hakim@mysociety.org> | 2014-07-31 13:02:34 +0000 |
---|---|---|
committer | Hakim Cassimally <hakim@mysociety.org> | 2014-07-31 13:02:34 +0000 |
commit | 1cae50a5635f783518cb2a7e0c2ea4372e8480e0 (patch) | |
tree | af7d04c401390ac14979da3544dcf02a629c8761 | |
parent | 0c254d386b2580bdcd2ffea43391acc1e682a6d4 (diff) |
[SeeSomething] fix and test for stats content
-rw-r--r-- | t/cobrand/seesomething.t | 51 | ||||
-rw-r--r-- | templates/web/seesomething/admin/stats.html | 2 |
2 files changed, 51 insertions, 2 deletions
diff --git a/t/cobrand/seesomething.t b/t/cobrand/seesomething.t index 3e818f2d1..1c36925e4 100644 --- a/t/cobrand/seesomething.t +++ b/t/cobrand/seesomething.t @@ -10,6 +10,14 @@ use FixMyStreet::TestMech; my $EMAIL = 'seesomething@example.com'; my $mech = FixMyStreet::TestMech->new; +my $db = FixMyStreet::App->model('DB')->schema; +my $dt_parser = $db->storage->datetime_parser; + +$db->txn_begin; + +$db->resultset('Comment')->delete; +$db->resultset('Problem')->delete; + my $user = $mech->create_user_ok( $EMAIL ); my $body = $mech->create_body_ok( 2520, 'Coventry City Council' ); @@ -22,6 +30,31 @@ $mech->create_body_ok( 2535, 'Sandwell Borough Council' ); $user->update({ from_body => $body }); +my $date = $dt_parser->format_datetime(DateTime->now); + +my $report = FixMyStreet::App->model('DB::Problem')->find_or_create( { + postcode => 'EH1 1BB', + bodies_str => '2520', + areas => ',2520,', + service => 'Android', + category => 'Bus', + subcategory => 'Loud Music', + title => 'Loud Music', + detail => 'Loud Music', + used_map => 1, + name => 'SeeSomething Test User', + anonymous => 0, + state => 'confirmed', + confirmed => $date, + lang => 'en-gb', + cobrand => 'default', + cobrand_data => '', + send_questionnaire => 1, + latitude => '52.4081', + longitude => '-1.5106', + user_id => $user->id, +} ); + subtest 'admin/stats' => sub { FixMyStreet::override_config { ALLOWED_COBRANDS => [ 'seesomething' ], @@ -29,11 +62,27 @@ subtest 'admin/stats' => sub { my $user = $mech->log_in_ok( $EMAIL ); $mech->get( '/admin/stats' ); - ok $mech->success or do { + if (ok $mech->success) { + + $date =~s/ / /; + $date =~s/\+0000//; + my $xml = <<EOXML; + <tr> + <td>Android</td> + <td>Bus</td> + <td class="nowrap">Loud Music</td> + <td class="nowrap">Coventry </td> + <td class="nowrap">$date</td> + </tr> +EOXML + $mech->content_contains($xml); + } + else { diag $mech->content; diag $mech->status; }; } }; +$db->txn_rollback; done_testing; diff --git a/templates/web/seesomething/admin/stats.html b/templates/web/seesomething/admin/stats.html index b69973af4..4cf184f4f 100644 --- a/templates/web/seesomething/admin/stats.html +++ b/templates/web/seesomething/admin/stats.html @@ -50,7 +50,7 @@ No Results found <td>[% report.service || 'Other' %]</td> <td>[% report.category %]</td> <td class="nowrap">[% report.subcategory %]</td> - <td class="nowrap">[% council_details.${report.bodies_str}.name %]</td> + <td class="nowrap">[% council_details.${report.bodies_str} %]</td> <td class="nowrap">[% PROCESS format_time time=report.confirmed %]</td> </tr> [%- END %] |