diff options
Diffstat (limited to 't')
-rw-r--r-- | t/app/controller/report_inspect.t | 43 | ||||
-rw-r--r-- | t/app/sendreport/inspection_required.t | 15 | ||||
-rw-r--r-- | t/cobrand/oxfordshire.t | 140 |
3 files changed, 1 insertions, 197 deletions
diff --git a/t/app/controller/report_inspect.t b/t/app/controller/report_inspect.t index ef05288c7..b6498e840 100644 --- a/t/app/controller/report_inspect.t +++ b/t/app/controller/report_inspect.t @@ -8,14 +8,6 @@ my $oxon = $mech->create_body_ok(2237, 'Oxfordshire County Council', { can_be_de my $contact = $mech->create_contact_ok( body_id => $oxon->id, category => 'Cows', email => 'cows@example.net' ); my $contact2 = $mech->create_contact_ok( body_id => $oxon->id, category => 'Sheep', email => 'SHEEP', send_method => 'Open311' ); my $contact3 = $mech->create_contact_ok( body_id => $oxon->id, category => 'Badgers', email => 'badgers@example.net' ); -my $dt = FixMyStreet::DB->resultset("DefectType")->create({ - body => $oxon, - name => 'Small Defect', description => "Teeny", -}); -FixMyStreet::DB->resultset("ContactDefectType")->create({ - contact => $contact, - defect_type => $dt, -}); my $rp = FixMyStreet::DB->resultset("ResponsePriority")->create({ body => $oxon, name => 'High Priority', @@ -144,7 +136,7 @@ FixMyStreet::override_config { $mech->get_ok("/report/$report_id"); $mech->submit_form_ok({ button => 'save', with_fields => { public_update => "This is a public update.", include_update => "1", - state => 'action scheduled', raise_defect => 1, + state => 'action scheduled', } }); $mech->get_ok("/report/$report_id"); $mech->submit_form_ok({ with_fields => { @@ -153,28 +145,23 @@ FixMyStreet::override_config { $report->discard_changes; my $comment = ($report->comments( undef, { order_by => { -desc => 'id' } } )->all)[1]->text; is $comment, "This is a public update.", 'Update was created'; - is $report->get_extra_metadata('inspected'), 1, 'report marked as inspected'; is $report->user->get_extra_metadata('reputation'), $reputation, "User reputation wasn't changed"; $mech->get_ok("/report/$report_id"); my $meta = $mech->extract_update_metas; like $meta->[0], qr/State changed to: Action scheduled/, 'First update mentions action scheduled'; - like $meta->[2], qr/Posted by .*defect raised/, 'Update mentions defect raised'; $user->unset_extra_metadata('categories'); $user->update; }; subtest "test update is required when instructing" => sub { - $report->unset_extra_metadata('inspected'); $report->update; - $report->inspection_log_entry->delete; $report->comments->delete_all; $mech->get_ok("/report/$report_id"); $mech->submit_form_ok({ button => 'save', with_fields => { public_update => undef, include_update => "1" } }); is_deeply $mech->page_errors, [ "Please provide a public update for this report." ], 'errors match'; $report->discard_changes; is $report->comments->count, 0, "Update wasn't created"; - is $report->get_extra_metadata('inspected'), undef, 'report not marked as inspected'; }; subtest "test location changes" => sub { @@ -448,24 +435,6 @@ FixMyStreet::override_config { is $report->response_priority->id, $rp->id, 'response priority set'; }; - subtest "check can set defect type for category when changing from category with no defect types" => sub { - $report->update({ category => 'Sheep', defect_type_id => undef }); - $user->user_body_permissions->delete; - $user->user_body_permissions->create({ body => $oxon, permission_type => 'report_inspect' }); - $mech->get_ok("/report/$report_id"); - $mech->submit_form_ok({ - button => 'save', - with_fields => { - include_update => 0, - defect_type => $dt->id, - category => 'Cows', - } - }); - $report->discard_changes; - is $report->defect_type->id, $dt->id, 'defect type set'; - $report->update({ defect_type_id => undef }); - }; - subtest "check can't set priority that isn't for a category" => sub { $report->discard_changes; $report->update({ category => 'Cows', response_priority_id => $rp->id }); @@ -627,7 +596,6 @@ FixMyStreet::override_config { subtest "test positive reputation" => sub { $user->user_body_permissions->create({ body => $oxon, permission_type => 'report_instruct' }); - $report->unset_extra_metadata('inspected'); $report->update; $report->inspection_log_entry->delete if $report->inspection_log_entry; my $reputation = $report->user->get_extra_metadata("reputation") || 0; @@ -636,24 +604,16 @@ FixMyStreet::override_config { state => 'in progress', include_update => undef, } }); $report->discard_changes; - is $report->get_extra_metadata('inspected'), undef, 'report not marked as inspected'; $mech->submit_form_ok({ button => 'save', with_fields => { state => 'action scheduled', include_update => undef, } }); $report->discard_changes; - is $report->get_extra_metadata('inspected'), undef, 'report not marked as inspected'; is $report->user->get_extra_metadata('reputation'), $reputation+1, "User reputation was increased"; $mech->submit_form_ok({ button => 'save', with_fields => { state => 'action scheduled', include_update => undef, - raise_defect => 1, } }); - $report->discard_changes; - is $report->get_extra_metadata('inspected'), 1, 'report marked as inspected'; - $mech->get_ok("/report/$report_id"); - my $meta = $mech->extract_update_metas; - like $meta->[-1], qr/Updated by .*defect raised/, 'Update mentions defect raised'; }; subtest "Oxfordshire-specific traffic management options are shown" => sub { @@ -697,7 +657,6 @@ FixMyStreet::override_config { priority => $rp->id, include_update => '1', detailed_information => 'XXX164XXXxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', - defect_type => '', traffic_information => '' }; my $values = $mech->visible_form_values('report_inspect_form'); diff --git a/t/app/sendreport/inspection_required.t b/t/app/sendreport/inspection_required.t index 64d6f70ee..5eff516f5 100644 --- a/t/app/sendreport/inspection_required.t +++ b/t/app/sendreport/inspection_required.t @@ -34,21 +34,8 @@ subtest "Report isn't sent if uninspected" => sub { is $report->whensent, undef, "Report hasn't been sent"; }; -subtest 'Report is sent when inspected' => sub { - $mech->clear_emails_ok; - $report->set_extra_metadata(inspected => 1); - $report->update; - - FixMyStreet::Script::Reports::send(); - - $report->discard_changes; - $mech->email_count_is( 1 ); - ok $report->whensent, 'Report marked as sent'; -}; - subtest 'Uninspected report is sent when made by trusted user' => sub { $mech->clear_emails_ok; - $report->unset_extra_metadata('inspected'); $report->whensent( undef ); $report->update; @@ -63,7 +50,6 @@ subtest 'Uninspected report is sent when made by trusted user' => sub { $report->discard_changes; $mech->email_count_is( 1 ); ok $report->whensent, 'Report marked as sent'; - is $report->get_extra_metadata('inspected'), undef, 'Report not marked as inspected'; }; subtest "Uninspected report isn't sent when user rep is too low" => sub { @@ -94,7 +80,6 @@ subtest 'Uninspected report is sent when user rep is high enough' => sub { $report->discard_changes; $mech->email_count_is( 1 ); ok $report->whensent, 'Report marked as sent'; - is $report->get_extra_metadata('inspected'), undef, 'Report not marked as inspected'; }; done_testing(); diff --git a/t/cobrand/oxfordshire.t b/t/cobrand/oxfordshire.t index 2625aa0d5..b8422a28b 100644 --- a/t/cobrand/oxfordshire.t +++ b/t/cobrand/oxfordshire.t @@ -1,6 +1,4 @@ - use Test::MockModule; -use FixMyStreet::Integrations::ExorRDI; use FixMyStreet::TestMech; my $mech = FixMyStreet::TestMech->new; @@ -47,145 +45,8 @@ subtest 'check /around?ajax defaults to open reports only' => sub { } }; -my $superuser = $mech->create_user_ok('superuser@example.com', name => 'Super User', is_superuser => 1); -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' => '.' } ], - }, sub { - $mech->log_in_ok( $superuser->email ); - $mech->get_ok('/admin'); - $mech->content_contains("Download Exor RDI"); - } -}; - -subtest "Exor RDI download doesn't appear outside of Oxfordshire cobrand admin" => sub { - FixMyStreet::override_config { - ALLOWED_COBRANDS => [ { 'fixmystreet' => '.' } ], - }, sub { - $mech->log_in_ok( $superuser->email ); - $mech->get_ok('/admin'); - $mech->content_lacks("Download Exor RDI"); - } -}; - -subtest 'Exor file looks okay' => sub { - FixMyStreet::override_config { - ALLOWED_COBRANDS => [ 'oxfordshire' ], - MAPIT_URL => 'http://mapit.uk/', - }, sub { - $mech->log_in_ok( $superuser->email ); - $mech->get_ok('/admin/exordefects'); - $mech->submit_form_ok( { with_fields => { - start_date => '2017-05-05', - end_date => '2017-05-05', - user_id => $inspector->id, - } }, 'submit download'); - $mech->content_contains("No inspections by that inspector in the selected date range"); - - my $dt = FixMyStreet::DB->resultset('DefectType')->create({ - body => $oxon, - name => 'Footpath', - description => 'Footpath stuff', - }); - $dt->set_extra_metadata(activity_code => 'FC'); - $dt->set_extra_metadata(defect_code => 'SFP1'); - $dt->update; - my $dt2 = FixMyStreet::DB->resultset('DefectType')->create({ - body => $oxon, - name => 'Accidental sign damage', - description => 'Accidental sign damage', - }); - $dt2->set_extra_metadata(activity_code => 'S'); - $dt2->set_extra_metadata(defect_code => 'ACC2'); - $dt2->update; - my $i = 123; - foreach my $problem (@problems) { - $problem->update({ state => 'action scheduled', external_id => $i }); - $problem->update({ defect_type => $dt }) if $i == 123; - $problem->set_extra_metadata(traffic_information => 'Signs and Cones') if $i == 124; - $problem->update({ defect_type => $dt2 }) if $i == 124; - FixMyStreet::DB->resultset('AdminLog')->create({ - admin_user => $inspector->name, - user => $inspector, - object_type => 'problem', - action => 'inspected', - object_id => $problem->id, - whenedited => DateTime->new(year => 2017, month => 5, day => 5, hour => 12), - }); - $i++; - } - $mech->submit_form_ok( { with_fields => { - start_date => '2017-05-05', - end_date => '2017-05-05', - user_id => $inspector->id, - } }, 'submit download'); - (my $rdi = $mech->content) =~ s/\r\n/\n/g; - $rdi =~ s/(I,[FMS]C?,,)\d+/$1XXX/g; # Remove unique ID figures, unknown order - is $rdi, <<EOF, "RDI file matches expected"; -"1,1.8,1.0.0.0,ENHN," -"G,1989169,,,XX,170505,1600,D,INS,N,,,," -"H,FC" -"I,FC,,XXX,"434970E 209683N Nearest postcode: OX28 4DS.",1200,,,,,,,,"TM none","123 XX TM0 "" -"J,SFP1,2,,,434970,209683,,,,," -"M,resolve,,,/CFC,," -"P,0,999999" -"G,1989169,,,XX,170505,1600,D,INS,N,,,," -"H,MC" -"I,MC,,XXX,"434970E 209683N Nearest postcode: OX28 4DS.",1200,,,,,,,,"TM none","125 XX TM0 "" -"J,SFP2,2,,,434970,209683,,,,," -"M,resolve,,,/CMC,," -"P,0,999999" -"G,1989169,,,XX,170505,1600,D,INS,N,,,," -"H,S" -"I,S,,XXX,"434970E 209683N Nearest postcode: OX28 4DS.",1200,,,,,,,,"TM Signs and Cones","124 XX TM1 "" -"J,ACC2,2,,,434970,209683,,,,," -"M,resolve,,,/CSI,," -"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' ], - MAPIT_URL => 'http://mapit.uk/', - }, sub { - my $date = DateTime->new(year => 2017, month => 5, day => 5, hour => 12); - - my $now = DateTime->now( - time_zone => FixMyStreet->time_zone || FixMyStreet->local_time_zone - ); - my $datetime = Test::MockModule->new('DateTime'); - $datetime->mock('now', sub { $now }); - - 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; - - foreach my $problem (@problems) { - $problem->discard_changes; - is $problem->get_extra_metadata('rdi_processed'), $now->strftime( '%Y-%m-%d %H:%M' ), "Problem was logged as sent in RDI"; - } - }; -}; - subtest 'can use customer reference to search for reports' => sub { FixMyStreet::override_config { ALLOWED_COBRANDS => [ 'oxfordshire' ], @@ -195,7 +56,6 @@ subtest 'can use customer reference to search for reports' => sub { $problem->set_extra_metadata( customer_reference => 'ENQ12456' ); $problem->update; - $mech->log_out_ok; $mech->get_ok('/around?pc=ENQ12456'); is $mech->uri->path, '/report/' . $problem->id, 'redirects to report'; }; |