diff options
Diffstat (limited to 't')
-rw-r--r-- | t/app/controller/report_inspect.t | 16 | ||||
-rw-r--r-- | t/app/controller/report_updates.t | 42 |
2 files changed, 57 insertions, 1 deletions
diff --git a/t/app/controller/report_inspect.t b/t/app/controller/report_inspect.t index e668fddbf..33486aa28 100644 --- a/t/app/controller/report_inspect.t +++ b/t/app/controller/report_inspect.t @@ -79,10 +79,21 @@ FixMyStreet::override_config { public_update => "This is a public update.", include_update => "1", state => 'action scheduled', raise_defect => 1, } }); + $mech->get_ok("/report/$report_id"); + $mech->submit_form_ok({ with_fields => { + update => "This is a second public update, of normal update form, no actual change.", + } }); $report->discard_changes; - is $report->comments->first->text, "This is a public update.", 'Update was created'; + my $comment = ($report->comments( undef, { order_by => { -desc => 'id' } } )->all)[1]->text; + is $comment, "This is a public update.", 'Update was created'; is $report->get_extra_metadata('inspected'), 1, 'report marked as inspected'; is $report->user->get_extra_metadata('reputation'), $reputation, "User reputation wasn't changed"; + $mech->get_ok("/report/$report_id"); + my $meta = $mech->extract_update_metas; + like $meta->[0], qr/Updated by .*action scheduled/, 'First update mentions action scheduled'; + like $meta->[1], qr/Posted by .*defect raised/, 'Update mentions defect raised'; + unlike $meta->[2], qr/Posted by .*action scheduled/, 'Update does not mention action scheduled'; + $user->unset_extra_metadata('categories'); $user->update; }; @@ -245,6 +256,9 @@ FixMyStreet::override_config { } }); $report->discard_changes; is $report->get_extra_metadata('inspected'), 1, 'report marked as inspected'; + $mech->get_ok("/report/$report_id"); + my $meta = $mech->extract_update_metas; + like $meta->[-1], qr/Updated by .*defect raised/, 'Update mentions defect raised'; }; subtest "Oxfordshire-specific traffic management options are shown" => sub { diff --git a/t/app/controller/report_updates.t b/t/app/controller/report_updates.t index 81174181c..4cb035bac 100644 --- a/t/app/controller/report_updates.t +++ b/t/app/controller/report_updates.t @@ -928,6 +928,48 @@ subtest 'check meta correct for second comment marking as reopened' => sub { like $update_meta->[1], qr/reopened/, 'update meta says reopened'; }; +subtest "check first comment with status change but no text is displayed" => sub { + $user->from_body( $body->id ); + $user->update; + + $report->comments->delete; + + my $comment = FixMyStreet::App->model('DB::Comment')->create( + { + user => $user, + name => $user->from_body->name, + problem_id => $report->id, + text => '', + confirmed => DateTime->now( time_zone => 'local'), + problem_state => 'investigating', + anonymous => 0, + mark_open => 0, + mark_fixed => 0, + state => 'confirmed', + } + ); + $mech->log_in_ok( $user->email ); + + $mech->get_ok("/report/$report_id"); + + my $update_meta = $mech->extract_update_metas; + like $update_meta->[0], qr/Updated by/, 'updated by meta if no text'; + unlike $update_meta->[0], qr/Test User/, 'commenter name not included'; + like $update_meta->[0], qr/investigating/, 'update meta includes state change'; + + ok $user->user_body_permissions->create({ + body => $body, + permission_type => 'view_body_contribute_details' + }), 'Give user view_body_contribute_details permissions'; + + $mech->get_ok("/report/$report_id"); + $update_meta = $mech->extract_update_metas; + like $update_meta->[0], qr/Updated by/, 'updated by meta if no text'; + like $update_meta->[0], qr/Test User/, 'commenter name included if user has view contribute permission'; + like $update_meta->[0], qr/investigating/, 'update meta includes state change'; +}; + + $user->from_body(undef); $user->update; |