diff options
author | Dave Arter <davea@mysociety.org> | 2020-04-29 10:14:05 +0100 |
---|---|---|
committer | Dave Arter <davea@mysociety.org> | 2020-04-29 12:53:00 +0100 |
commit | faad588069c2db225a46c2ad6de749b65232f6f7 (patch) | |
tree | 0c339f3cb123574f9f61214e030cca3f63bb9de2 | |
parent | 13e9cbb95d6ba619c4046bbbdcd7e7cb7b0f9e67 (diff) |
[Oxfordshire] Include external problem reference in CSV export
For https://github.com/mysociety/fixmystreet-commercial/issues/1876
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Oxfordshire.pm | 15 | ||||
-rw-r--r-- | t/cobrand/oxfordshire.t | 29 |
2 files changed, 44 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/Cobrand/Oxfordshire.pm b/perllib/FixMyStreet/Cobrand/Oxfordshire.pm index 12714185d..481fb7d6e 100644 --- a/perllib/FixMyStreet/Cobrand/Oxfordshire.pm +++ b/perllib/FixMyStreet/Cobrand/Oxfordshire.pm @@ -197,4 +197,19 @@ sub available_permissions { return $perms; } +sub dashboard_export_problems_add_columns { + my $self = shift; + my $c = $self->{c}; + + push @{$c->stash->{csv}->{headers}}, "HIAMS Ref"; + push @{$c->stash->{csv}->{columns}}, "customer_reference"; + + $c->stash->{csv}->{extra_data} = sub { + my $ref = shift->get_extra_metadata('customer_reference') || ''; + return { + customer_reference => $ref, + }; + }; +} + 1; diff --git a/t/cobrand/oxfordshire.t b/t/cobrand/oxfordshire.t index dd5eedc8d..907c66c19 100644 --- a/t/cobrand/oxfordshire.t +++ b/t/cobrand/oxfordshire.t @@ -5,6 +5,7 @@ use FixMyStreet::Script::Alerts; my $mech = FixMyStreet::TestMech->new; my $oxon = $mech->create_body_ok(2237, 'Oxfordshire County Council'); +my $counciluser = $mech->create_user_ok('counciluser@example.com', name => 'Council User', from_body => $oxon); subtest 'check /around?ajax defaults to open reports only' => sub { my $categories = [ 'Bridges', 'Fences', 'Manhole' ]; @@ -105,6 +106,34 @@ subtest 'check unable to fix label' => sub { }; }; +subtest 'extra CSV columns are present' => sub { + FixMyStreet::override_config { + ALLOWED_COBRANDS => [ 'oxfordshire' ], + MAPIT_URL => 'http://mapit.uk/', + }, sub { + + $mech->log_in_ok( $counciluser->email ); + + $mech->get_ok('/dashboard?export=1'); + + my @rows = $mech->content_as_csv; + is scalar @rows, 7, '1 (header) + 6 (reports) = 7 lines'; + is scalar @{$rows[0]}, 21, '21 columns present'; + + is_deeply $rows[0], + [ + 'Report ID', 'Title', 'Detail', 'User Name', 'Category', + 'Created', 'Confirmed', 'Acknowledged', 'Fixed', 'Closed', + 'Status', 'Latitude', 'Longitude', 'Query', 'Ward', + 'Easting', 'Northing', 'Report URL', 'Site Used', + 'Reported As', 'HIAMS Ref', + ], + 'Column headers look correct'; + + is $rows[1]->[20], 'ENQ12456', 'HIAMS reference included in row'; + }; +}; + END { done_testing(); } |