diff options
author | Matthew Somerville <matthew@mysociety.org> | 2013-10-25 13:49:11 +0100 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2013-10-25 13:49:11 +0100 |
commit | 5b1520f738a362b5c6a0def5b5d322a728df3951 (patch) | |
tree | 93a10ae5ea8b0f91f91ea54233731c78157161ca | |
parent | 604d306f4fc0f0024fc9a493f391413811dfbb3f (diff) |
Set confirmed timestamp on any admin unconfirmed state change.
This fixes #527.
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Admin.pm | 2 | ||||
-rw-r--r-- | t/app/controller/admin.t | 11 |
2 files changed, 11 insertions, 2 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm index 6264d1a73..0c81a8750 100644 --- a/perllib/FixMyStreet/App/Controller/Admin.pm +++ b/perllib/FixMyStreet/App/Controller/Admin.pm @@ -760,7 +760,7 @@ sub report_edit : Path('report_edit') : Args(1) { $problem->photo(undef); } - if ( $new_state eq 'confirmed' and $old_state eq 'unconfirmed' ) { + if ( $problem->is_visible() and $old_state eq 'unconfirmed' ) { $problem->confirmed( \'ms_current_timestamp()' ); } diff --git a/t/app/controller/admin.t b/t/app/controller/admin.t index 80ea839da..85f4572fc 100644 --- a/t/app/controller/admin.t +++ b/t/app/controller/admin.t @@ -562,7 +562,7 @@ foreach my $test ( $report->discard_changes; if ( $report->state eq 'confirmed' ) { - $mech->content_contains( 'type="submit" name="resend"', 'no resend button' ); + $mech->content_contains( 'type="submit" name="resend"', 'resend button' ); } else { $mech->content_lacks( 'type="submit" name="resend"', 'no resend button' ); } @@ -1212,6 +1212,15 @@ for my $test ( }; } +subtest "Test setting a report from unconfirmed to something else doesn't cause a front end error" => sub { + $report->update( { confirmed => undef, state => 'unconfirmed', non_public => 0 } ); + $mech->get_ok("/admin/report_edit/$report_id"); + $mech->submit_form_ok( { with_fields => { state => 'investigating' } } ); + $report->discard_changes; + ok( $report->confirmed, 'report has a confirmed timestamp' ); + $mech->get_ok("/report/$report_id"); +}; + $mech->delete_user( $user ); $mech->delete_user( $user2 ); $mech->delete_user( $user3 ); |