aboutsummaryrefslogtreecommitdiffstats
path: root/t/app/controller
diff options
context:
space:
mode:
Diffstat (limited to 't/app/controller')
-rw-r--r--t/app/controller/report_display.t2
-rw-r--r--t/app/controller/report_inspect.t46
-rw-r--r--t/app/controller/report_updates.t2
3 files changed, 42 insertions, 8 deletions
diff --git a/t/app/controller/report_display.t b/t/app/controller/report_display.t
index 9817a640d..fad8b2bbb 100644
--- a/t/app/controller/report_display.t
+++ b/t/app/controller/report_display.t
@@ -117,7 +117,7 @@ subtest "duplicate reports are signposted correctly" => sub {
my $report2_id = $report2->id;
ok $mech->get("/report/$report2_id"), "get '/report/$report2_id'";
- $mech->content_contains('This report is a duplicate.');
+ $mech->content_contains('This report is a duplicate');
$mech->content_contains($report->title);
$mech->log_out_ok;
diff --git a/t/app/controller/report_inspect.t b/t/app/controller/report_inspect.t
index b4d6636b9..56e6e957f 100644
--- a/t/app/controller/report_inspect.t
+++ b/t/app/controller/report_inspect.t
@@ -21,12 +21,14 @@ my $wodc = $mech->create_body_ok(2420, 'West Oxfordshire District Council', id =
$mech->create_contact_ok( body_id => $wodc->id, category => 'Horses', email => 'horses@example.net' );
-my ($report) = $mech->create_problems_for_body(1, $oxon->id, 'Test', {
+my ($report, $report2) = $mech->create_problems_for_body(2, $oxon->id, 'Test', {
category => 'Cows', cobrand => 'fixmystreet', areas => ',2237,2420',
whensent => \'current_timestamp',
latitude => 51.847693, longitude => -1.355908,
});
my $report_id = $report->id;
+my $report2_id = $report2->id;
+
my $user = $mech->log_in_ok('test@example.com');
$user->update( { from_body => $oxon } );
@@ -94,11 +96,6 @@ FixMyStreet::override_config {
};
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',
- latitude => 51.847694, longitude => -1.355909,
- });
my $old_state = $report->state;
$report->set_extra_metadata('duplicate_of' => $report2->id);
$report->state('duplicate');
@@ -107,7 +104,6 @@ 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);
@@ -116,6 +112,42 @@ FixMyStreet::override_config {
$report->update;
};
+ subtest "marking a report as a duplicate with update correctly sets update status" => 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', duplicate_of => $report2->id, public_update => "This is a duplicate.", save_inspected => "1" } });
+ $report->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';
+
+ $report->update({ state => $old_state });
+ };
+
+ subtest "marking a report as a duplicate doesn't clobber user-provided update" => sub {
+ my $old_state = $report->state;
+ $report->comments->delete_all;
+
+ $mech->get_ok("/report/$report_id");
+ my $update_text = "This text was entered as an update by the user.";
+ $mech->submit_form_ok({ button => 'save', with_fields => {
+ state => 'Duplicate',
+ duplicate_of => $report2->id,
+ public_update => $update_text,
+ save_inspected => "1",
+ }});
+ $report->discard_changes;
+
+ is $report->state, 'duplicate', 'report marked as duplicate';
+ is $report->comments->search({ problem_state => 'duplicate' })->count, 1, 'update marked report as duplicate';
+ $mech->content_contains($update_text);
+ $mech->content_lacks("Thank you for your report. This problem has already been reported.");
+
+ $report->update({ state => $old_state });
+ };
+
foreach my $test (
{ type => 'report_edit_priority', priority => 1 },
{ type => 'report_edit_category', category => 1 },
diff --git a/t/app/controller/report_updates.t b/t/app/controller/report_updates.t
index e1cd0da71..5a88097fa 100644
--- a/t/app/controller/report_updates.t
+++ b/t/app/controller/report_updates.t
@@ -685,6 +685,8 @@ for my $test (
my $meta_state = $test->{meta} || $test->{fields}->{state};
if ( $test->{reopened} ) {
like $update_meta->[0], qr/reopened$/, 'update meta says reopened';
+ } elsif ( $test->{state} eq 'duplicate' ) {
+ like $update_meta->[0], qr/closed as $meta_state$/, 'update meta includes state change';
} else {
like $update_meta->[0], qr/marked as $meta_state$/, 'update meta includes state change';
}