diff options
Diffstat (limited to 't')
-rw-r--r-- | t/Mock/MapIt.pm | 1 | ||||
-rw-r--r-- | t/cobrand/oxfordshire.t | 84 |
2 files changed, 84 insertions, 1 deletions
diff --git a/t/Mock/MapIt.pm b/t/Mock/MapIt.pm index ad1d0c99c..926d94b1e 100644 --- a/t/Mock/MapIt.pm +++ b/t/Mock/MapIt.pm @@ -28,6 +28,7 @@ my @PLACES = ( [ 'SW1A 1AA', 51.501009, -0.141588, 2504, 'Westminster City Council', 'LBO' ], [ 'GL50 2PR', 51.896268, -2.093063, 2226, 'Gloucestershire County Council', 'CTY', 2326, 'Cheltenham Borough Council', 'DIS', 4544, 'Lansdown', 'DIW', 143641, 'Lansdown and Park', 'CED' ], [ '?', 51.754926, -1.256179, 2237, 'Oxfordshire County Council', 'CTY', 2421, 'Oxford City Council', 'DIS' ], + [ 'OX20 1SZ', 51.754926, -1.256179, 2237, 'Oxfordshire County Council', 'CTY', 2421, 'Oxford City Council', 'DIS' ], [ 'BR1 3UH', 51.4021, 0.01578, 2482, 'Bromley Council', 'LBO' ], [ '?', 50.78301, -0.646929 ], [ 'GU51 4AE', 51.279456, -0.846216, 2333, 'Hart District Council', 'DIS', 2227, 'Hampshire County Council', 'CTY' ], diff --git a/t/cobrand/oxfordshire.t b/t/cobrand/oxfordshire.t index 89792765c..e6c16950c 100644 --- a/t/cobrand/oxfordshire.t +++ b/t/cobrand/oxfordshire.t @@ -1,3 +1,5 @@ +use FixMyStreet::Integrations::ExorRDI; + use FixMyStreet::TestMech; my $mech = FixMyStreet::TestMech->new; @@ -47,6 +49,8 @@ my $superuser = $mech->create_user_ok('superuser@example.com', name => 'Super Us my $inspector = $mech->create_user_ok('inspector@example.com', name => 'Inspector'); $inspector->user_body_permissions->create({ body => $oxon, permission_type => 'report_inspect' }); +my @problems = FixMyStreet::DB->resultset('Problem')->search({}, { rows => 3 })->all; + subtest 'Exor RDI download appears on Oxfordshire cobrand admin' => sub { FixMyStreet::override_config { ALLOWED_COBRANDS => [ { 'oxfordshire' => '.' } ], @@ -97,7 +101,6 @@ subtest 'Exor file looks okay' => sub { $dt2->set_extra_metadata(activity_code => 'S'); $dt2->set_extra_metadata(defect_code => 'ACC2'); $dt2->update; - my @problems = FixMyStreet::DB->resultset('Problem')->search({}, { rows => 3 })->all; my $i = 123; foreach my $problem (@problems) { $problem->update({ state => 'action scheduled', external_id => $i }); @@ -142,9 +145,88 @@ subtest 'Exor file looks okay' => sub { "P,0,999999" "X,3,3,3,3,0,0,0,3,0,3,0,0,0" EOF + foreach my $problem (@problems) { + $problem->discard_changes; + is $problem->get_extra_metadata('rdi_processed'), undef, "Problem was not logged as sent in RDI"; + } + } }; +subtest 'Reports are marked as inspected correctly' => sub { + FixMyStreet::override_config { + ALLOWED_COBRANDS => [ 'oxfordshire' ], + }, sub { + my $date = DateTime->new(year => 2017, month => 5, day => 5, hour => 12); + my $params = { + start_date => $date, + end_date => $date, + inspection_date => $date, + user => $inspector, + mark_as_processed => 1, + }; + my $rdi = FixMyStreet::Integrations::ExorRDI->new($params); + $rdi->construct; + + my $now = DateTime->now->strftime( '%Y-%m-%d %H:%M' ); + foreach my $problem (@problems) { + $problem->discard_changes; + is $problem->get_extra_metadata('rdi_processed'), $now, "Problem was logged as sent in RDI"; + } + }; +}; + +subtest 'response times messages displayed' => sub { + my $oxfordshire = $mech->create_body_ok( + 2237, 'Oxfordshire County Council' + ); + my $contact = $mech->create_contact_ok( + body_id => $oxfordshire->id, + category => 'Pothole', + email => 'pothole@example.com', + ); + + FixMyStreet::override_config { + ALLOWED_COBRANDS => [ 'oxfordshire' ], + MAPIT_URL => 'http://mapit.uk/', + }, sub { + $mech->log_out_ok; + $mech->clear_emails_ok; + + $mech->get_ok('/around'); + $mech->submit_form_ok( { + with_fields => { pc => 'OX20 1SZ' } + }, + "submit_location" + ); + + $mech->follow_link_ok( { text_regex => qr/skip this step/i, }, + "follow 'skip this step' link" ); + + $mech->submit_form_ok( + { + with_fields => { + title => 'Test Report', + detail => 'Test report details.', + photo1 => '', + email => 'test-2@example.com', + name => 'Test User', + category => 'Pothole', + } + }, + "submit details" + ); + + $mech->text_contains('Problems in the Pothole category are generally responded'); + my $email = $mech->get_email; + ok $email, 'got and email'; + like $mech->get_text_body_from_email, qr/Problems in the Pothole category/, 'emails contains response time message'; + my $url = $mech->get_link_from_email($email); + $mech->get_ok($url); + $mech->text_contains('Problems in the Pothole category are generally responded') + }; +}; + END { done_testing(); } |