aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perllib/FixMyStreet/App/Controller/Report.pm8
-rw-r--r--perllib/FixMyStreet/Cobrand/Zurich.pm2
-rw-r--r--t/app/controller/report_display.t6
-rw-r--r--t/cobrand/zurich.t9
4 files changed, 23 insertions, 2 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Report.pm b/perllib/FixMyStreet/App/Controller/Report.pm
index 7062f481f..df4dc5f77 100644
--- a/perllib/FixMyStreet/App/Controller/Report.pm
+++ b/perllib/FixMyStreet/App/Controller/Report.pm
@@ -221,9 +221,15 @@ sub format_problem_for_display : Private {
if ( $c->stash->{ajax} ) {
$c->res->content_type('application/json; charset=utf-8');
+
+ # encode_json doesn't like DateTime objects, so strip them out
+ my $report_hashref = $c->cobrand->problem_as_hashref( $problem, $c );
+ delete $report_hashref->{created};
+ delete $report_hashref->{confirmed};
+
my $content = encode_json(
{
- report => $c->cobrand->problem_as_hashref( $problem, $c ),
+ report => $report_hashref,
updates => $c->cobrand->updates_as_hashref( $problem, $c ),
}
);
diff --git a/perllib/FixMyStreet/Cobrand/Zurich.pm b/perllib/FixMyStreet/Cobrand/Zurich.pm
index 7068d3b03..c8af63987 100644
--- a/perllib/FixMyStreet/Cobrand/Zurich.pm
+++ b/perllib/FixMyStreet/Cobrand/Zurich.pm
@@ -174,7 +174,7 @@ sub updates_as_hashref {
my $hashref = {};
- if (problem_has_public_response($problem)) {
+ if ($self->problem_has_public_response($problem)) {
$hashref->{update_pp} = $self->prettify_dt( $problem->lastupdate );
if ( $problem->state ne 'external' ) {
diff --git a/t/app/controller/report_display.t b/t/app/controller/report_display.t
index 605371ed7..17b9180c1 100644
--- a/t/app/controller/report_display.t
+++ b/t/app/controller/report_display.t
@@ -115,6 +115,12 @@ subtest "duplicate reports are signposted correctly" => sub {
$report2->update;
};
+subtest "test /report/ajax" => sub {
+ my $json = $mech->get_ok_json( "/report/ajax/$report_id" );
+ is $json->{report}->{title}, "Test 2", "correct title";
+ is $json->{report}->{state}, "confirmed", "correct state";
+};
+
subtest "test a good report" => sub {
$mech->get_ok("/report/$report_id");
is $mech->uri->path, "/report/$report_id", "at /report/$report_id";
diff --git a/t/cobrand/zurich.t b/t/cobrand/zurich.t
index f5c6b1145..eccb0c8eb 100644
--- a/t/cobrand/zurich.t
+++ b/t/cobrand/zurich.t
@@ -126,6 +126,15 @@ FixMyStreet::override_config {
$mech->content_contains('Überprüfung ausstehend')
or die $mech->content;
+FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ 'zurich' ],
+ MAP_TYPE => 'Zurich,OSM',
+}, sub {
+ my $json = $mech->get_ok_json( '/report/ajax/' . $report->id );
+ is $json->{report}->{title}, "Überprüfung ausstehend", "correct title";
+ is $json->{report}->{state}, "submitted", "correct state";
+};
+
subtest "Banners are displayed correctly" => sub {
FixMyStreet::override_config {
ALLOWED_COBRANDS => [ 'zurich' ],