aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perllib/Open311/GetServiceRequests.pm2
-rw-r--r--t/open311/getservicerequests.t5
2 files changed, 4 insertions, 3 deletions
diff --git a/perllib/Open311/GetServiceRequests.pm b/perllib/Open311/GetServiceRequests.pm
index b1cb0c4dc..78e9647fa 100644
--- a/perllib/Open311/GetServiceRequests.pm
+++ b/perllib/Open311/GetServiceRequests.pm
@@ -137,7 +137,7 @@ sub create_problems {
};
$problems = $self->schema->resultset('Problem')->to_body($body)->search( $criteria );
- my @contacts = grep { $request->{service_code} eq $_->category } $contacts->all;
+ my @contacts = grep { $request->{service_code} eq $_->email } $contacts->all;
my $contact = $contacts[0] ? $contacts[0]->category : 'Other';
my $state = $open311->map_state($request->{status});
diff --git a/t/open311/getservicerequests.t b/t/open311/getservicerequests.t
index a28c6e3cf..c59e5cc41 100644
--- a/t/open311/getservicerequests.t
+++ b/t/open311/getservicerequests.t
@@ -12,7 +12,7 @@ my $mech = FixMyStreet::TestMech->new;
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 => 'sidewalks', email => 'sidewalks@example.com' );
+my $contact = $mech->create_contact_ok( body_id => $body->id, category => 'Sidewalk and Curb Issues', email => 'sidewalks' );
my $dtf = DateTime::Format::W3CDTF->new;
@@ -90,13 +90,14 @@ subtest 'basic parsing checks' => sub {
)->first;
ok $p, 'Found problem';
+ is $p->title, 'Sidewalk and Curb Issues problem', 'correct problem title';
is $p->detail, 'This is a sidewalk problem', 'correct problem description';
is $p->created, $p1_date, 'Problem has correct creation date';
is $p->confirmed, $p1_date, 'Problem has correct confirmed date';
is $p->whensent, $p1_date, 'Problem has whensent set';
is $p->state, 'confirmed', 'correct problem state';
is $p->user->id, $user->id, 'user set to system user';
- is $p->category, 'sidewalks', 'correct problem category';
+ is $p->category, 'Sidewalk and Curb Issues', 'correct problem category';
my $p2 = FixMyStreet::DB->resultset('Problem')->search( { external_id => 638345 } )->first;
ok $p2, 'second problem found';