diff options
Diffstat (limited to 't')
-rw-r--r-- | t/open311/getservicerequests.t | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/t/open311/getservicerequests.t b/t/open311/getservicerequests.t index 93163b5b9..f4eae59b1 100644 --- a/t/open311/getservicerequests.t +++ b/t/open311/getservicerequests.t @@ -14,6 +14,9 @@ my $user = $mech->create_user_ok('system_user@example.com', name => 'test users' my $body = $mech->create_body_ok(2482, 'Bromley'); my $contact = $mech->create_contact_ok( body_id => $body->id, category => 'Sidewalk and Curb Issues', email => 'sidewalks' ); +my $body2 = $mech->create_body_ok(2217, 'Buckinghamshire'); +my $contact2 = $mech->create_contact_ok( body_id => $body2->id, category => 'Sidewalk and Curb Issues', email => 'sidewalks' ); + my $dtf = DateTime::Format::W3CDTF->new; my $requests_xml = qq{<?xml version="1.0" encoding="utf-8"?> @@ -469,6 +472,54 @@ for my $test ( }; } +for my $test ( + { + test_desc => 'filters out phone numbers', + desc => 'This has a description with values:0117 469 0123 and more 07700 900123', + }, + { + test_desc => 'filters out emails', + desc => 'This has a description with values:test@example.org and more user@council.gov.uk', + }, +) { + subtest $test->{test_desc} => sub { + my $xml = prepare_xml({ + desc => $test->{desc}, + lat => 51.615559, + long => -0.556903, + }); + + my $o = Open311->new( + jurisdiction => 'mysociety', + endpoint => 'http://example.com', + test_mode => 1, + test_get_returns => { 'requests.xml' => $xml} + ); + + my $update = Open311::GetServiceRequests->new( + system_user => $user, + start_date => $start_date, + end_date => $end_date + ); + + FixMyStreet::override_config { + ALLOWED_COBRANDS => [ 'FixMyStreet', 'Buckinghamshire' ], + MAPIT_URL => 'http://mapit.uk/', + }, sub { + $update->create_problems( $o, $body2 ); + }; + + my $p = FixMyStreet::DB->resultset('Problem')->search( + { external_id => 123456 } + )->first; + + ok $p, 'problem created'; + is $p->detail, 'This has a description with values: and more ', "report description filtered"; + + $p->delete; + }; +} + sub prepare_xml { my $replacements = shift; |