aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perllib/FixMyStreet/Cobrand/SeeSomething.pm11
-rw-r--r--t/cobrand/seesomething.t39
-rw-r--r--templates/web/seesomething/admin/stats.html2
3 files changed, 46 insertions, 6 deletions
diff --git a/perllib/FixMyStreet/Cobrand/SeeSomething.pm b/perllib/FixMyStreet/Cobrand/SeeSomething.pm
index e5e937267..af386429c 100644
--- a/perllib/FixMyStreet/Cobrand/SeeSomething.pm
+++ b/perllib/FixMyStreet/Cobrand/SeeSomething.pm
@@ -88,14 +88,15 @@ sub admin_stats {
my %councils =
map {
- $c->stash->{council_details}->{$_}->{name} =~ s/(?:Borough|City) Council//;
- $_ => $c->stash->{council_details}->{$_}
+ my $name = $_->name;
+ $name =~ s/(?:Borough|City) Council//;
+ ($_->id => $name);
}
- @{ $self->council_id };
+ $c->model('DB::Body')->search({ id => $self->council_id });
$c->stash->{council_details} = \%councils;
- if ( !$c->user_exists || !grep { $_ == $c->user->from_council } @{ $self->council_id } ) {
+ if ( !$c->user_exists || !grep { $_ == $c->user->from_body->id } @{ $self->council_id } ) {
$c->detach( '/page_error_404_not_found' );
}
@@ -123,7 +124,7 @@ sub admin_stats {
},
{
columns => [ qw(
- service category subcategory council confirmed
+ service category subcategory confirmed bodies_str
) ],
order_by => { -desc=> [ 'confirmed' ] },
rows => 20,
diff --git a/t/cobrand/seesomething.t b/t/cobrand/seesomething.t
new file mode 100644
index 000000000..3e818f2d1
--- /dev/null
+++ b/t/cobrand/seesomething.t
@@ -0,0 +1,39 @@
+use strict;
+use warnings;
+use DateTime;
+use Test::More;
+use JSON;
+
+use FixMyStreet;
+use FixMyStreet::TestMech;
+
+my $EMAIL = 'seesomething@example.com';
+
+my $mech = FixMyStreet::TestMech->new;
+my $user = $mech->create_user_ok( $EMAIL );
+
+my $body = $mech->create_body_ok( 2520, 'Coventry City Council' );
+$mech->create_body_ok( 2522, 'Dudley Borough Council' );
+$mech->create_body_ok( 2514, 'Birmingham City Council' );
+$mech->create_body_ok( 2546, 'Walsall Borough Council' );
+$mech->create_body_ok( 2519, 'Wolverhampton City Council' );
+$mech->create_body_ok( 2538, 'Solihull Borough Council' );
+$mech->create_body_ok( 2535, 'Sandwell Borough Council' );
+
+$user->update({ from_body => $body });
+
+subtest 'admin/stats' => sub {
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ 'seesomething' ],
+ }, sub {
+ my $user = $mech->log_in_ok( $EMAIL );
+
+ $mech->get( '/admin/stats' );
+ ok $mech->success or do {
+ diag $mech->content;
+ diag $mech->status;
+ };
+ }
+};
+
+done_testing;
diff --git a/templates/web/seesomething/admin/stats.html b/templates/web/seesomething/admin/stats.html
index 713c3fb6d..b69973af4 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.council}.name %]</td>
+ <td class="nowrap">[% council_details.${report.bodies_str}.name %]</td>
<td class="nowrap">[% PROCESS format_time time=report.confirmed %]</td>
</tr>
[%- END %]