diff options
Diffstat (limited to 't')
-rw-r--r-- | t/app/controller/report_inspect.t | 87 | ||||
-rw-r--r-- | t/cobrand/oxfordshire.t | 7 |
2 files changed, 78 insertions, 16 deletions
diff --git a/t/app/controller/report_inspect.t b/t/app/controller/report_inspect.t index f74c94c34..74d99c0a9 100644 --- a/t/app/controller/report_inspect.t +++ b/t/app/controller/report_inspect.t @@ -148,6 +148,67 @@ FixMyStreet::override_config { $report2->update; }; + subtest "can mark a report as duplicate without supplying a duplicate and a public update" => sub { + my $old_state = $report->state; + $report->comments->delete_all; + + $mech->get_ok("/report/$report_id"); + $mech->submit_form_ok({ button => 'save', with_fields => { state => 'Duplicate', include_update => "0" } }); + + $mech->content_contains('provide a duplicate ID', "error message about missing duplicate id"); + $report->discard_changes; + $report2->discard_changes; + + is $report->state, $old_state, 'report not marked as duplicate'; + is $report->comments->search({ problem_state => 'duplicate' })->count, 0, 'no update marking report as duplicate was left'; + + is $report->get_extra_metadata('duplicate_of'), undef; + + $mech->submit_form_ok({ button => 'save', with_fields => { state => 'Duplicate', public_update => 'This is a duplicate', include_update => "1" } }); + $mech->content_lacks('provide a duplicate ID', "no error message about missing duplicate id"); + $report->discard_changes; + $report2->discard_changes; + + is $report->state, 'duplicate', 'report marked as duplicate'; + is $report->comments->search({ problem_state => 'duplicate' })->count, 1, 'update marking report as duplicate was left'; + is $report->get_extra_metadata('duplicate_of'), undef; + is_deeply $report2->get_extra_metadata('duplicates'), undef; + + $report->update({ state => $old_state }); + }; + + subtest "can mark a report as duplicate without supplying a public update and a duplicate id" => sub { + my $old_state = $report->state; + $report->comments->delete_all; + + $mech->get_ok("/report/$report_id"); + $mech->submit_form_ok({ button => 'save', with_fields => { state => 'Duplicate', include_update => "0" } }); + + $mech->content_contains('provide a duplicate ID', "error message about missing duplicate id"); + $report->discard_changes; + $report2->discard_changes; + + is $report->state, $old_state, 'report not marked as duplicate'; + is $report->comments->search({ problem_state => 'duplicate' })->count, 0, 'no update marking report as duplicate was left'; + + is $report->get_extra_metadata('duplicate_of'), undef; + + $mech->submit_form_ok({ button => 'save', with_fields => { state => 'Duplicate', duplicate_of => $report2->id, include_update => "0" } }); + $mech->content_lacks('provide a duplicate ID', "no error message about missing duplicate id"); + $report->discard_changes; + $report2->discard_changes; + + is $report->state, 'duplicate', 'report marked as duplicate'; + is $report->comments->search({ problem_state => 'duplicate' })->count, 1, 'update marking report as duplicate was left'; + is $report->get_extra_metadata('duplicate_of'), $report2->id; + is_deeply $report2->get_extra_metadata('duplicates'), [ $report->id ]; + + $report->set_extra_metadata('duplicate_of', undef); + $report->update({ state => $old_state }); + $report2->set_extra_metadata('duplicates', undef); + $report2->update; + }; + subtest "marking a report as a duplicate with update correctly sets update status" => sub { my $old_state = $report->state; $report->comments->delete_all; @@ -386,36 +447,36 @@ foreach my $test ( button => 'save', with_fields => { include_update => 0, - detailed_information => 'XXX172XXX' . 'x' x 163, + detailed_information => 'XXX164XXX' . 'x' x (164-9) } }); $report->discard_changes; - like $report->get_extra_metadata('detailed_information'), qr/XXX172XXX/, 'detailed information saved'; - $mech->content_lacks('limited to 172 characters', "172 charcters of detailed information ok"); - $mech->content_contains('XXX172XXX', "Detailed information field contains submitted text"); + like $report->get_extra_metadata('detailed_information'), qr/XXX164XXX/, 'detailed information saved'; + $mech->content_lacks('limited to 164 characters', "164 charcters of detailed information ok"); + $mech->content_contains('XXX164XXX', "Detailed information field contains submitted text"); $mech->submit_form_ok({ button => 'save', with_fields => { include_update => 0, - detailed_information => 'XXX173XXX' . 'x' x 164, + detailed_information => 'XXX165XXX' . 'x' x (164-8) } }); if ($test->{limited}) { - $mech->content_contains('172 characters maximum'); - $mech->content_contains('limited to 172 characters', "173 charcters of detailed information not ok"); - $mech->content_contains('XXX173XXX', "Detailed information field contains submitted text"); + $mech->content_contains('164 characters maximum'); + $mech->content_contains('limited to 164 characters', "165 charcters of detailed information not ok"); + $mech->content_contains('XXX165XXX', "Detailed information field contains submitted text"); $report->discard_changes; - like $report->get_extra_metadata('detailed_information'), qr/XXX172XXX/, 'detailed information not saved'; + like $report->get_extra_metadata('detailed_information'), qr/XXX164XXX/, 'detailed information not saved'; } else { $mech->content_lacks(' characters maximum'); - $mech->content_lacks('limited to 172 characters', "173 charcters of detailed information ok"); - $mech->content_contains('XXX173XXX', "Detailed information field contains submitted text"); + $mech->content_lacks('limited to 164 characters', "165 charcters of detailed information ok"); + $mech->content_contains('XXX165XXX', "Detailed information field contains submitted text"); $report->discard_changes; - like $report->get_extra_metadata('detailed_information'), qr/XXX173XXX/, 'detailed information saved'; + like $report->get_extra_metadata('detailed_information'), qr/XXX165XXX/, 'detailed information saved'; } }; }; @@ -498,7 +559,7 @@ FixMyStreet::override_config { public_update => '', priority => $rp->id, include_update => '1', - detailed_information => 'XXX172XXXxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', + detailed_information => 'XXX164XXXxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', defect_type => '', traffic_information => '' }; diff --git a/t/cobrand/oxfordshire.t b/t/cobrand/oxfordshire.t index abafa1fe8..dcf8b25c9 100644 --- a/t/cobrand/oxfordshire.t +++ b/t/cobrand/oxfordshire.t @@ -107,6 +107,7 @@ subtest 'Exor file looks okay' => sub { 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, @@ -129,19 +130,19 @@ subtest 'Exor file looks okay' => sub { "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 "" +"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 "" +"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 none","124 "" +"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" |