diff options
Diffstat (limited to 't/cobrand')
-rw-r--r-- | t/cobrand/oxfordshire.t | 84 |
1 files changed, 83 insertions, 1 deletions
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(); } |