aboutsummaryrefslogtreecommitdiffstats
path: root/t/app/controller/admin/report_edit.t
diff options
context:
space:
mode:
Diffstat (limited to 't/app/controller/admin/report_edit.t')
-rw-r--r--t/app/controller/admin/report_edit.t125
1 files changed, 123 insertions, 2 deletions
diff --git a/t/app/controller/admin/report_edit.t b/t/app/controller/admin/report_edit.t
index a8a0bd143..5e3e6c315 100644
--- a/t/app/controller/admin/report_edit.t
+++ b/t/app/controller/admin/report_edit.t
@@ -79,6 +79,7 @@ foreach my $test (
anonymous => 0,
flagged => undef,
non_public => undef,
+ closed_updates => undef,
},
changes => { title => 'Edited Report', },
log_entries => [qw/edit/],
@@ -95,6 +96,7 @@ foreach my $test (
anonymous => 0,
flagged => undef,
non_public => undef,
+ closed_updates => undef,
},
changes => { detail => 'Edited Detail', },
log_entries => [qw/edit edit/],
@@ -111,6 +113,7 @@ foreach my $test (
anonymous => 0,
flagged => undef,
non_public => undef,
+ closed_updates => undef,
},
changes => { name => 'Edited User', },
log_entries => [qw/edit edit edit/],
@@ -128,6 +131,7 @@ foreach my $test (
anonymous => 0,
flagged => undef,
non_public => undef,
+ closed_updates => undef,
},
changes => {
flagged => 'on',
@@ -147,6 +151,7 @@ foreach my $test (
anonymous => 0,
flagged => 'on',
non_public => undef,
+ closed_updates => undef,
},
changes => { username => $user2->email, },
log_entries => [qw/edit edit edit edit edit/],
@@ -164,6 +169,7 @@ foreach my $test (
anonymous => 0,
flagged => 'on',
non_public => undef,
+ closed_updates => undef,
},
expect_comment => 1,
changes => { state => 'unconfirmed' },
@@ -181,6 +187,7 @@ foreach my $test (
anonymous => 0,
flagged => 'on',
non_public => undef,
+ closed_updates => undef,
},
expect_comment => 1,
changes => { state => 'confirmed' },
@@ -198,6 +205,7 @@ foreach my $test (
anonymous => 0,
flagged => 'on',
non_public => undef,
+ closed_updates => undef,
},
expect_comment => 1,
changes => { state => 'fixed' },
@@ -216,6 +224,7 @@ foreach my $test (
anonymous => 0,
flagged => 'on',
non_public => undef,
+ closed_updates => undef,
},
expect_comment => 1,
changes => { state => 'hidden' },
@@ -235,6 +244,7 @@ foreach my $test (
anonymous => 0,
flagged => 'on',
non_public => undef,
+ closed_updates => undef,
},
expect_comment => 1,
changes => {
@@ -257,6 +267,7 @@ foreach my $test (
anonymous => 1,
flagged => 'on',
non_public => undef,
+ closed_updates => undef,
},
changes => {},
log_entries => [
@@ -275,6 +286,7 @@ foreach my $test (
anonymous => 1,
flagged => 'on',
non_public => undef,
+ closed_updates => undef,
},
changes => {
non_public => 'on',
@@ -285,6 +297,24 @@ foreach my $test (
resend => 0,
},
{
+ description => 'close to updates',
+ fields => {
+ title => 'Edited Report',
+ detail => 'Edited Detail',
+ state => 'confirmed',
+ name => 'Edited User',
+ username => $user2->email,
+ anonymous => 1,
+ flagged => 'on',
+ non_public => 'on',
+ closed_updates => undef,
+ },
+ changes => { closed_updates => 'on' },
+ log_entries => [
+ qw/edit edit resend edit state_change edit state_change edit state_change edit state_change edit state_change edit edit edit edit edit/
+ ],
+ },
+ {
description => 'change state to investigating as body superuser',
fields => {
title => 'Edited Report',
@@ -295,12 +325,13 @@ foreach my $test (
anonymous => 1,
flagged => 'on',
non_public => 'on',
+ closed_updates => undef,
},
expect_comment => 1,
user_body => $oxfordshire,
changes => { state => 'investigating' },
log_entries => [
- qw/edit state_change edit resend edit state_change edit state_change edit state_change edit state_change edit state_change edit edit edit edit edit/
+ qw/edit state_change edit edit resend edit state_change edit state_change edit state_change edit state_change edit state_change edit edit edit edit edit/
],
resend => 0,
},
@@ -315,13 +346,14 @@ foreach my $test (
anonymous => 1,
flagged => 'on',
non_public => 'on',
+ closed_updates => undef,
},
expect_comment => 1,
expected_text => '*Category changed from ‘Other’ to ‘Potholes’*',
user_body => $oxfordshire,
changes => { state => 'in progress', category => 'Potholes' },
log_entries => [
- qw/edit state_change edit state_change edit resend edit state_change edit state_change edit state_change edit state_change edit state_change edit edit edit edit edit/
+ qw/edit state_change edit state_change edit edit resend edit state_change edit state_change edit state_change edit state_change edit state_change edit edit edit edit edit/
],
resend => 0,
},
@@ -364,9 +396,22 @@ foreach my $test (
$mech->content_lacks( 'type="submit" name="resend"', 'no resend button' );
}
+ if ($report->state eq 'fixed') {
+ $mech->content_contains('pin-green');
+ }
+
$test->{changes}->{flagged} = 1 if $test->{changes}->{flagged};
$test->{changes}->{non_public} = 1 if $test->{changes}->{non_public};
+ if ($test->{changes}->{closed_updates}) {
+ is $report->get_extra_metadata('closed_updates'), 1, "closed_updates updated";
+ $mech->get_ok("/report/$report_id");
+ $mech->content_lacks('Provide an update');
+ $report->unset_extra_metadata('closed_updates');
+ $report->update;
+ delete $test->{changes}->{closed_updates};
+ }
+
is $report->$_, $test->{changes}->{$_}, "$_ updated" for grep { $_ ne 'username' } keys %{ $test->{changes} };
if ( $test->{user} ) {
@@ -447,6 +492,7 @@ subtest 'change email to new user' => sub {
anonymous => 1,
flagged => 'on',
non_public => 'on',
+ closed_updates => undef,
external_id => '13',
external_body => '',
external_team => '',
@@ -553,4 +599,79 @@ subtest "Test setting a report from unconfirmed to something else doesn't cause
$mech->get_ok("/report/$report_id");
};
+subtest "Test display of report extra data" => sub {
+ $mech->get_ok("/admin/report_edit/$report_id");
+ $mech->content_contains('Extra data: No');
+ $report->set_extra_metadata('extra_field', 'this is extra data');
+ $report->update;
+ $mech->get_ok("/admin/report_edit/$report_id");
+ $mech->content_contains('extra_field</strong>: this is extra data');
+};
+
+my $report2 = FixMyStreet::App->model('DB::Problem')->find_or_create(
+ {
+ postcode => 'SW1A 1AA',
+ bodies_str => '2504',
+ areas => ',105255,11806,11828,2247,2504,',
+ category => 'Other',
+ title => 'Report to Duplicate Edit',
+ detail => 'Detail for Duplicate Report to Edit',
+ used_map => 't',
+ name => 'Test User',
+ anonymous => 'f',
+ external_id => '13',
+ state => 'confirmed',
+ confirmed => $dt->ymd . ' ' . $dt->hms,
+ lang => 'en-gb',
+ service => '',
+ cobrand => '',
+ cobrand_data => '',
+ send_questionnaire => 't',
+ latitude => '51.5016605453401',
+ longitude => '-0.142497580865087',
+ user_id => $user->id,
+ whensent => $dt->ymd . ' ' . $dt->hms,
+ }
+);
+
+subtest "Test display of report duplicates extra data" => sub {
+ $report->update( { extra => undef } );
+ $mech->get_ok("/admin/report_edit/$report_id");
+ $mech->content_contains('Extra data: No');
+
+ $report2->set_duplicate_of($report_id);
+ $report2->update;
+
+ $mech->get_ok("/admin/report_edit/$report_id");
+ $mech->content_contains('Duplicates</strong>: ' . $report2->id);
+};
+
+subtest "Test display of fields extra data" => sub {
+ $report->unset_extra_metadata( 'duplicates' );
+ $report->update;
+ $mech->get_ok("/admin/report_edit/$report_id");
+ $mech->content_contains('Extra data: No');
+
+ $report->push_extra_fields( {
+ name => 'report_url',
+ value => 'http://example.com',
+ });
+ $report->update;
+
+ $report->discard_changes;
+
+ $mech->get_ok("/admin/report_edit/$report_id");
+ $mech->content_contains('report_url</strong>: http://example.com');
+
+ $report->set_extra_fields( {
+ description => 'Report URL',
+ name => 'report_url',
+ value => 'http://example.com',
+ });
+ $report->update;
+
+ $mech->get_ok("/admin/report_edit/$report_id");
+ $mech->content_contains('Report URL (report_url)</strong>: http://example.com');
+};
+
done_testing();