diff options
author | Matthew Somerville <matthew-github@dracos.co.uk> | 2018-03-13 17:14:55 +0000 |
---|---|---|
committer | Matthew Somerville <matthew-github@dracos.co.uk> | 2018-03-15 18:37:22 +0000 |
commit | b10ef57fc439648be3caaf44d7cbe117bf1fb521 (patch) | |
tree | 40ccdab5c06eb897458e3b30f398d2dd8f6f7215 | |
parent | c0fb85e249180ed58dd436caece3328938256296 (diff) |
Truncate dates in Open311 output to the second.
This fixes #2023 by removing the comma.
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Open311.pm | 8 | ||||
-rw-r--r-- | t/app/controller/open311.t | 13 |
3 files changed, 18 insertions, 4 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 003ec4bb9..26444fc34 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ - Don't delete hidden field values when inspecting reports. #1999 - Fix text layout issues in /reports/…/summary dashboard charts. - Fix post-edit issues on admin report edit page. + - Truncate dates in Open311 output to the second. #2023 - Admin improvements: - Inspectors can set non_public status of reports. #1992 - Default start date is shown on the dashboard. diff --git a/perllib/FixMyStreet/App/Controller/Open311.pm b/perllib/FixMyStreet/App/Controller/Open311.pm index c7e4e5bee..ddc976f2d 100644 --- a/perllib/FixMyStreet/App/Controller/Open311.pm +++ b/perllib/FixMyStreet/App/Controller/Open311.pm @@ -231,14 +231,15 @@ sub output_requests : Private { $problem->state( $statusmap{$problem->state} ); + my ($lat, $lon) = map { Utils::truncate_coordinate($_) } $problem->latitude, $problem->longitude; my $request = { 'service_request_id' => $id, 'title' => $problem->title, # Not in Open311 v2 'detail' => $problem->detail, # Not in Open311 v2 'description' => $problem->title .': ' . $problem->detail, - 'lat' => $problem->latitude, - 'long' => $problem->longitude, + 'lat' => $lat, + 'long' => $lon, 'status' => $problem->state, # 'status_notes' => {}, # Zurich has visible unconfirmed reports @@ -441,11 +442,10 @@ sub is_jurisdiction_id_ok : Private { # Input: DateTime object # Output: 2011-04-23T10:28:55+02:00 -# FIXME Need generic solution to find time zone sub w3date : Private { my $datestr = shift; return unless $datestr; - return DateTime::Format::W3CDTF->format_datetime($datestr); + return DateTime::Format::W3CDTF->format_datetime($datestr->truncate(to => 'second')); } =head1 AUTHOR diff --git a/t/app/controller/open311.t b/t/app/controller/open311.t index 29cd38129..9f4f594fe 100644 --- a/t/app/controller/open311.t +++ b/t/app/controller/open311.t @@ -1,3 +1,4 @@ +use JSON::MaybeXS; use FixMyStreet::TestMech; my $mech = FixMyStreet::TestMech->new; @@ -5,4 +6,16 @@ my $mech = FixMyStreet::TestMech->new; $mech->get_ok('/open311.cgi/v2/requests.rss?jurisdiction_id=fiksgatami.no&status=open&agency_responsible=1854'); like $mech->uri, qr[/open311/v2/requests\.rss\?.{65}]; # Don't know order parameters will be in now +$mech->create_problems_for_body(2, 2237, 'Around page'); +$mech->get_ok('/open311/v2/requests.xml?jurisdiction_id=foo&status=open&agency_responsible=2237'); +$mech->content_contains('<description>Around page Test 2 for 2237: Around page Test 2 for 2237 Detail</description>'); +$mech->content_contains('<interface_used>Web interface</interface_used>'); +$mech->content_contains('<status>open</status>'); + +$mech->get_ok('/open311/v2/requests.json?jurisdiction_id=foo&status=open&agency_responsible=2237'); +my $json = decode_json($mech->content); +my $problems = $json->{requests}[0]{request}; +is @$problems, 2; +like $problems->[0]{description}, qr/Around page Test/; + done_testing(); |