From e9961ee495ab87cbe67cf37e53edbae0794541d2 Mon Sep 17 00:00:00 2001 From: Dave Arter Date: Thu, 5 Feb 2015 15:09:49 +0000 Subject: [Zurich] 'photo required' functionality - Save 'photo_required' value in Contact->extra from admin edit form - Enforce per-category photo requirement on new reports A new step has been added to the photo upload process that ensures a photo is present if any of the categories chosen for the report require it. If the photo is missing an error is displayed to the user in the same manner as if the photo upload was invalid. - Add test of mandatory photo categories --- t/cobrand/zurich.t | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 't') diff --git a/t/cobrand/zurich.t b/t/cobrand/zurich.t index e1cb55b16..ffee28259 100644 --- a/t/cobrand/zurich.t +++ b/t/cobrand/zurich.t @@ -69,6 +69,7 @@ $division->parent( $zurich->id ); $division->send_method( 'Zurich' ); $division->endpoint( 'division@example.org' ); $division->update; +$division->body_areas->find_or_create({ area_id => 274456 }); my $subdivision = $mech->create_body_ok( 3, 'Subdivision A' ); $subdivision->parent( $division->id ); $subdivision->send_method( 'Zurich' ); @@ -644,6 +645,41 @@ subtest "hidden report email are only sent when requested" => sub { }; }; +subtest "photo must be supplied for categories that require it" => sub { + FixMyStreet::App->model('DB::Contact')->find_or_create({ + body => $division, + category => "Graffiti - photo required", + email => "graffiti\@example.org", + confirmed => 1, + deleted => 0, + editor => "editor", + whenedited => DateTime->now(), + note => "note for graffiti", + extra => { photo_required => 1 } + }); + FixMyStreet::override_config { + MAPIT_TYPES => [ 'O08' ], + MAPIT_URL => 'http://global.mapit.mysociety.org/', + ALLOWED_COBRANDS => [ 'zurich' ], + MAPIT_ID_WHITELIST => [ 274456 ], + MAPIT_GENERATION => 2, + }, sub { + $mech->post_ok( '/report/new', { + detail => 'Problem-Bericht', + lat => 47.381817, + lon => 8.529156, + email => 'user@example.org', + pc => '', + name => '', + category => 'Graffiti - photo required', + photo => '', + submit_problem => 1, + }); + is $mech->res->code, 200, "missing photo shouldn't return anything but 200"; + $mech->content_contains(_("Photo is required."), 'response should contain photo error message'); + }; +}; + subtest "test stats" => sub { FixMyStreet::override_config { ALLOWED_COBRANDS => [ 'zurich' ], -- cgit v1.2.3