aboutsummaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2018-06-22 12:57:51 +0100
committerMatthew Somerville <matthew-github@dracos.co.uk>2018-06-22 14:27:49 +0100
commitb9ff1828d109befbe279698d7403889e9987c704 (patch)
tree140005cf2f927f473c1df7c7efac1d27241695c6 /t
parentd268f042ce441485b3512308055f37bd08c63588 (diff)
Defect type changes must be after category change.
As with priorities, they depend upon the category and so must be looked up after that has been updated.
Diffstat (limited to 't')
-rw-r--r--t/app/controller/report_inspect.t26
1 files changed, 26 insertions, 0 deletions
diff --git a/t/app/controller/report_inspect.t b/t/app/controller/report_inspect.t
index 260339da8..33e3b39c3 100644
--- a/t/app/controller/report_inspect.t
+++ b/t/app/controller/report_inspect.t
@@ -7,6 +7,14 @@ 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',
@@ -394,6 +402,24 @@ 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 });