aboutsummaryrefslogtreecommitdiffstats
path: root/t/app
diff options
context:
space:
mode:
Diffstat (limited to 't/app')
-rw-r--r--t/app/controller/report_inspect.t6
-rw-r--r--t/app/model/problem.t11
2 files changed, 16 insertions, 1 deletions
diff --git a/t/app/controller/report_inspect.t b/t/app/controller/report_inspect.t
index 9a62b1eb7..b4d6636b9 100644
--- a/t/app/controller/report_inspect.t
+++ b/t/app/controller/report_inspect.t
@@ -93,7 +93,7 @@ FixMyStreet::override_config {
$mech->content_lacks('Invalid location');
};
- subtest "test duplicate report is shown" => sub {
+ subtest "test duplicate reports are shown" => sub {
my ($report2) = $mech->create_problems_for_body(1, $oxon->id, 'The other report is a duplicate of this one', {
category => $report->category, cobrand => 'fixmystreet', areas => ',2237,2420',
whensent => \'current_timestamp',
@@ -107,6 +107,10 @@ FixMyStreet::override_config {
$mech->get_ok("/report/$report_id");
$mech->content_contains($report2->title);
+ my $report2_id = $report2->id;
+ $mech->get_ok("/report/$report2_id");
+ $mech->content_contains($report->title);
+
$report->unset_extra_metadata('duplicate_of');
$report->state($old_state);
$report->update;
diff --git a/t/app/model/problem.t b/t/app/model/problem.t
index bd7d0e55c..1130078c0 100644
--- a/t/app/model/problem.t
+++ b/t/app/model/problem.t
@@ -763,6 +763,17 @@ subtest 'check response templates' => sub {
is $problem->response_templates, 2, 'Global and pothole templates returned';
};
+subtest 'check duplicate reports' => sub {
+ my ($problem1, $problem2) = $mech->create_problems_for_body(2, $body_ids{2651}, 'TITLE');
+ $problem1->set_extra_metadata(duplicate_of => $problem2->id);
+ $problem1->state('duplicate');
+ $problem1->update;
+
+ is $problem1->duplicate_of->title, $problem2->title, 'problem1 returns correct problem from duplicate_of';
+ is scalar @{ $problem2->duplicates }, 1, 'problem2 has correct number of duplicates';
+ is $problem2->duplicates->[0]->title, $problem1->title, 'problem2 includes problem1 in duplicates';
+};
+
END {
$problem->comments->delete if $problem;
$problem->delete if $problem;