diff options
author | Chris Mytton <chrism@mysociety.org> | 2020-05-15 17:42:06 +0100 |
---|---|---|
committer | M Somerville <matthew-github@dracos.co.uk> | 2020-10-12 13:38:03 +0100 |
commit | 19deaf332d2843e3b4337f3e2047bce47e4a7cd1 (patch) | |
tree | 0b8c09257b286eda03f188f61e76acb2aeec9439 /t | |
parent | c778cff750282e814820b2f8ffee5e5c909e269a (diff) |
[Oxfordshire] Add instruct defect functionality back in
In the past Oxfordshire had a way for inspectors to "instruct a defect",
which generated a CSV which got emailed to Oxfordshire with a list of
defects.
They now want to bring this functionality back, but instead of emailing
a CSV they want it to call an API.
As a first step towards that goal, this change adds back some of the
instruct defect functionality that was removed in 68e18ff.
Diffstat (limited to 't')
-rw-r--r-- | t/app/controller/report_inspect.t | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/t/app/controller/report_inspect.t b/t/app/controller/report_inspect.t index c10fe7f94..367327c16 100644 --- a/t/app/controller/report_inspect.t +++ b/t/app/controller/report_inspect.t @@ -246,7 +246,7 @@ FixMyStreet::override_config { $user->update; }; - subtest "test update is required when instructing" => sub { + subtest "test public update is required if include_update is checked" => sub { $report->update; $report->comments->delete_all; $mech->get_ok("/report/$report_id"); @@ -913,6 +913,41 @@ FixMyStreet::override_config { $contact2->unset_extra_metadata('assigned_users_only'); $contact2->update; }; + + subtest 'instruct defect' => sub { + $user->user_body_permissions->create({ body => $oxon, permission_type => 'report_instruct' }); + $mech->get_ok("/report/$report2_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, + } }); + $report2->discard_changes; + is $report2->get_extra_metadata('inspected'), 1, 'report marked as inspected'; + $mech->get_ok("/report/$report2_id"); + my $meta = $mech->extract_update_metas; + like $meta->[0], qr/State changed to: Action scheduled/, 'First update mentions action scheduled'; + like $meta->[1], qr/Posted by .*defect raised/, 'Update mentions defect raised'; + my $log_entry = $report2->inspection_log_entry; + is $log_entry->object_id, $report2_id, 'Log entry has correct ID'; + is $log_entry->object_type, 'problem', 'Log entry has correct type'; + is $log_entry->action, 'inspected', 'Log entry has correct action'; + }; + + subtest "test update is required when instructing defect" => sub { + $report2->unset_extra_metadata('inspected'); + $report2->update; + $report2->inspection_log_entry->delete; + $report2->comments->delete_all; + $mech->get_ok("/report/$report2_id"); + $mech->submit_form_ok({ button => 'save', with_fields => { + public_update => "", include_update => "0", + state => 'action scheduled', raise_defect => 1, + } }); + is_deeply $mech->page_errors, [ "Please provide a public update for this report." ], 'errors match'; + $report2->discard_changes; + is $report2->comments->count, 0, "Update wasn't created"; + is $report2->get_extra_metadata('inspected'), undef, 'report not marked as inspected'; + }; }; done_testing(); |