diff options
author | pezholio <pezholio@gmail.com> | 2017-05-05 15:20:55 +0100 |
---|---|---|
committer | pezholio <pezholio@gmail.com> | 2017-05-05 15:24:22 +0100 |
commit | afa66d3cd1b4d84e151bd8c438060fc8fc340bbe (patch) | |
tree | a419b5c28019fe30c6f4b4b857856853ea62cfc6 /t | |
parent | 77ff26ef363a54f0c550649d2a02bad0f449b926 (diff) |
Subscribe inspectors to updates when state changes
Diffstat (limited to 't')
-rw-r--r-- | t/app/controller/report_inspect.t | 16 |
1 files changed, 16 insertions, 0 deletions
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; |