diff options
Diffstat (limited to 't')
-rw-r--r-- | t/app/controller/report_new_open311.t | 8 | ||||
-rw-r--r-- | t/cobrand/bromley.t | 62 | ||||
-rw-r--r-- | t/open311/getservicerequestupdates.t | 4 | ||||
-rw-r--r-- | t/open311/populate-service-list.t | 13 |
4 files changed, 72 insertions, 15 deletions
diff --git a/t/app/controller/report_new_open311.t b/t/app/controller/report_new_open311.t index 22b37fd55..db6e07933 100644 --- a/t/app/controller/report_new_open311.t +++ b/t/app/controller/report_new_open311.t @@ -30,6 +30,14 @@ my $contact1 = $mech->create_contact_ok( } ], ); +my $contact1b = $mech->create_contact_ok( + body_id => $body->id, # Edinburgh + category => 'Moon lighting', + email => '100b', + extra => [ { description => 'Moon type', code => 'type', required => 'False', values => + [ { name => 'Full', key => 'full' }, { name => 'New', key => 'new' } ] } + ], +); my $contact2 = $mech->create_contact_ok( body_id => $body->id, # Edinburgh category => 'Graffiti Removal', diff --git a/t/cobrand/bromley.t b/t/cobrand/bromley.t index 1f61cd3de..6066c66b6 100644 --- a/t/cobrand/bromley.t +++ b/t/cobrand/bromley.t @@ -7,7 +7,7 @@ my $mech = FixMyStreet::TestMech->new; # Create test data my $user = $mech->create_user_ok( 'bromley@example.com' ); -my $body = $mech->create_body_ok( 2482, 'Bromley', id => 2482 ); +my $body = $mech->create_body_ok( 2482, 'Bromley Council', id => 2482 ); $mech->create_contact_ok( body_id => $body->id, category => 'Other', @@ -56,6 +56,66 @@ subtest 'testing special Open311 behaviour', sub { is $report->external_id, 248, 'Report has right external ID'; }; +for my $test ( + { + cobrand => 'bromley', + fields => { + submit_update => 1, + rznvy => 'unregistered@example.com', + update => 'Update from an unregistered user', + add_alert => undef, + first_name => 'Unreg', + last_name => 'User', + fms_extra_title => 'DR', + may_show_name => undef, + } + }, + { + cobrand => 'fixmystreet', + fields => { + submit_update => 1, + rznvy => 'unregistered@example.com', + update => 'Update from an unregistered user', + add_alert => undef, + name => 'Unreg User', + fms_extra_title => 'DR', + may_show_name => undef, + } + }, +) +{ + subtest 'check Bromley update emails via ' . $test->{cobrand} . ' cobrand are correct' => sub { + $mech->log_out_ok(); + $mech->clear_emails_ok(); + + my $report_id = $report->id; + + FixMyStreet::override_config { + ALLOWED_COBRANDS => [ $test->{cobrand} ], + }, sub { + $mech->get_ok("/report/$report_id"); + $mech->submit_form_ok( + { + with_fields => $test->{fields} + }, + 'submit update' + ); + }; + $mech->content_contains('Nearly done! Now check your email'); + + my $email = $mech->get_email; + ok $email, "got an email"; + like $email->body, qr/This update will be sent to Bromley Council/i, "Email indicates problem will be sent to Bromley"; + unlike $email->body, qr/Note that we do not send updates to/i, "Email does not say updates aren't sent to Bromley"; + + my $unreg_user = FixMyStreet::App->model( 'DB::User' )->find( { email => 'unregistered@example.com' } ); + + ok $unreg_user, 'found user'; + + $mech->delete_user( $unreg_user ); + }; +} + # Clean up $mech->delete_user($user); $mech->delete_body($body); diff --git a/t/open311/getservicerequestupdates.t b/t/open311/getservicerequestupdates.t index 134d5422e..e13a34492 100644 --- a/t/open311/getservicerequestupdates.t +++ b/t/open311/getservicerequestupdates.t @@ -52,13 +52,13 @@ for my $test ( desc => 'basic parsing - empty element', updated_datetime => '<updated_datetime />', res => { update_id => 638344, service_request_id => 1, - status => 'open', description => 'This is a note', updated_datetime => {} } , + status => 'open', description => 'This is a note', updated_datetime => undef } , }, { desc => 'basic parsing - element with no content', updated_datetime => '<updated_datetime></updated_datetime>', res => { update_id => 638344, service_request_id => 1, - status => 'open', description => 'This is a note', updated_datetime => {} } , + status => 'open', description => 'This is a note', updated_datetime => undef } , }, { desc => 'basic parsing - element with content', diff --git a/t/open311/populate-service-list.t b/t/open311/populate-service-list.t index f001926d2..606bcbc44 100644 --- a/t/open311/populate-service-list.t +++ b/t/open311/populate-service-list.t @@ -419,7 +419,6 @@ for my $test ( ); my $service_list = get_xml_simple_object( $services_xml ); - $service_list = { service => [ $service_list->{ service } ] }; $processor->_current_open311( $o ); $processor->_current_body( $body ); @@ -690,17 +689,7 @@ sub get_standard_xml { sub get_xml_simple_object { my $xml = shift; - - my $simple = XML::Simple->new(); - my $obj; - - eval { - $obj = $simple->XMLin( $xml ); - }; - - die $@ if $@; - - return $obj; + return Open311->_get_xml_object($xml); } done_testing(); |