aboutsummaryrefslogtreecommitdiffstats
path: root/t/app/controller/report_inspect.t
diff options
context:
space:
mode:
authorDave Arter <davea@mysociety.org>2016-11-22 13:04:25 +0000
committerDave Arter <davea@mysociety.org>2016-12-13 16:31:10 +0000
commitec6389940afce877a0bc7771d11a27ee7183f96a (patch)
treefaac683c3d9a5ec56b9e54d8913742f1169f0f5e /t/app/controller/report_inspect.t
parent05ba5147de9dc7b68f3c9048771fcabf80f20eca (diff)
Make it clearer that report is closed when marked as duplicate
- Record state change when leaving update and marking as duplicate - Change save button wording to match problem state when inspecting - Make it clearer that updates marking a report as duplicate actually close the report
Diffstat (limited to 't/app/controller/report_inspect.t')
-rw-r--r--t/app/controller/report_inspect.t46
1 files changed, 39 insertions, 7 deletions
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 },