aboutsummaryrefslogtreecommitdiffstats
path: root/t/app/controller
diff options
context:
space:
mode:
Diffstat (limited to 't/app/controller')
-rw-r--r--t/app/controller/report_inspect.t87
1 files changed, 74 insertions, 13 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 => ''
};