diff options
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Report.pm | 11 | ||||
-rw-r--r-- | t/app/controller/report_inspect.t | 16 |
2 files changed, 26 insertions, 1 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Report.pm b/perllib/FixMyStreet/App/Controller/Report.pm index ad2702460..b6978424f 100644 --- a/perllib/FixMyStreet/App/Controller/Report.pm +++ b/perllib/FixMyStreet/App/Controller/Report.pm @@ -124,7 +124,7 @@ sub load_problem_or_display_error : Private { $c->detach( '/page_error_404_not_found', [ _('Unknown problem ID') ] ) unless $c->cobrand->show_unconfirmed_reports ; } - elsif ( $problem->hidden_states->{ $problem->state } or + elsif ( $problem->hidden_states->{ $problem->state } or (($problem->get_extra_metadata('closure_status')||'') eq 'hidden')) { $c->detach( '/page_error_410_gone', @@ -388,6 +388,15 @@ sub inspect : Private { $reputation_change = 1 if $c->cobrand->reputation_increment_states->{$state}; $reputation_change = -1 if $c->cobrand->reputation_decrement_states->{$state}; } + + # If an inspector has changed the state, subscribe them to + # updates + my $options = { + cobrand => $c->cobrand->moniker, + cobrand_data => $problem->cobrand_data, + lang => $problem->lang, + }; + $problem->user->create_alert($problem->id, $options); } } diff --git a/t/app/controller/report_inspect.t b/t/app/controller/report_inspect.t index 69e43ad99..00b4e3b38 100644 --- a/t/app/controller/report_inspect.t +++ b/t/app/controller/report_inspect.t @@ -59,8 +59,13 @@ FixMyStreet::override_config { subtest "test basic inspect submission" => sub { $mech->submit_form_ok({ button => 'save', with_fields => { traffic_information => 'Yes', state => 'Action Scheduled', include_update => undef } }); $report->discard_changes; + my $alert = FixMyStreet::App->model('DB::Alert')->find( + { user => $user, alert_type => 'new_updates', confirmed => 1, } + ); + is $report->state, 'action scheduled', 'report state changed'; is $report->get_extra_metadata('traffic_information'), 'Yes', 'report data changed'; + ok defined( $alert ) , 'sign up for alerts'; }; subtest "test inspect & instruct submission" => sub { @@ -129,6 +134,17 @@ FixMyStreet::override_config { $report->update({ state => $old_state }); }; + subtest "changing state does not add another alert" =>sub { + $mech->get_ok("/report/$report_id"); + $mech->submit_form_ok({ button => 'save', with_fields => { state => 'Investigating', public_update => "We're investigating.", include_update => "1" } }); + + my $alert_count = FixMyStreet::App->model('DB::Alert')->search( + { user_id => $user->id, alert_type => 'new_updates', confirmed => 1, parameter => $report_id } + )->count(); + + is $alert_count, 1 , 'User has only one alert'; + }; + subtest "marking a report as a duplicate doesn't clobber user-provided update" => sub { my $old_state = $report->state; $report->comments->delete_all; |