aboutsummaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
authorDave Arter <davea@mysociety.org>2015-02-05 15:09:49 +0000
committerDave Arter <davea@mysociety.org>2015-10-06 09:09:22 +0100
commite9961ee495ab87cbe67cf37e53edbae0794541d2 (patch)
tree79596f3b3cad4325351fb2a92e617c401471d61e /t
parenta78bb3fc98dd1851e371c78d9743125d02baf04e (diff)
[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
Diffstat (limited to 't')
-rw-r--r--t/cobrand/zurich.t36
1 files changed, 36 insertions, 0 deletions
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' ],