aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perllib/FixMyStreet/TestMech.pm10
-rw-r--r--t/app/controller/report_inspect.t13
-rw-r--r--t/cobrand/zurich.t15
3 files changed, 16 insertions, 22 deletions
diff --git a/perllib/FixMyStreet/TestMech.pm b/perllib/FixMyStreet/TestMech.pm
index 54c39ffb9..122a5d0c9 100644
--- a/perllib/FixMyStreet/TestMech.pm
+++ b/perllib/FixMyStreet/TestMech.pm
@@ -282,6 +282,16 @@ sub get_first_email {
return $email_as_string;
}
+=head2 contains_or_lacks
+
+Based upon boolean FLAG, checks that content contains or lacks TEXT.
+
+=cut
+
+sub contains_or_lacks {
+ my ($mech, $flag, $text) = @_;
+ $flag ? $mech->content_contains($text) : $mech->content_lacks($text);
+}
=head2 page_errors
diff --git a/t/app/controller/report_inspect.t b/t/app/controller/report_inspect.t
index 6d6ec6559..3aea08eec 100644
--- a/t/app/controller/report_inspect.t
+++ b/t/app/controller/report_inspect.t
@@ -91,10 +91,10 @@ FixMyStreet::override_config {
$user->user_body_permissions->delete;
$user->user_body_permissions->create({ body => $oxon, permission_type => $test->{type} });
$mech->get_ok("/report/$report_id/inspect");
- has_or_lacks($test->{priority}, 'Priority');
- has_or_lacks($test->{priority}, 'High');
- has_or_lacks($test->{category}, 'Category');
- has_or_lacks($test->{detailed}, 'Detailed problem information');
+ $mech->contains_or_lacks($test->{priority}, 'Priority');
+ $mech->contains_or_lacks($test->{priority}, 'High');
+ $mech->contains_or_lacks($test->{category}, 'Category');
+ $mech->contains_or_lacks($test->{detailed}, 'Detailed problem information');
$mech->submit_form_ok({
button => 'save',
with_fields => {
@@ -112,8 +112,3 @@ END {
$mech->delete_body($brum);
done_testing();
}
-
-sub has_or_lacks {
- my ($flag, $text) = @_;
- $flag ? $mech->content_contains($text) : $mech->content_lacks($text);
-}
diff --git a/t/cobrand/zurich.t b/t/cobrand/zurich.t
index 53d8dba0f..330cb3389 100644
--- a/t/cobrand/zurich.t
+++ b/t/cobrand/zurich.t
@@ -936,8 +936,8 @@ subtest 'Status update shown as appropriate' => sub {
my ($state, $update, $public, $user_response) = @$_;
$report->update({ state => $state });
$mech->get_ok( '/admin/report_edit/' . $report->id );
- contains_or_lacks($mech, $update, "<textarea name='status_update'");
- contains_or_lacks($mech, $public || $user_response, '<div class="admin-official-answer">');
+ $mech->contains_or_lacks($update, "<textarea name='status_update'");
+ $mech->contains_or_lacks($public || $user_response, '<div class="admin-official-answer">');
if ($public) {
$mech->get_ok( '/report/' . $report->id );
@@ -947,17 +947,6 @@ subtest 'Status update shown as appropriate' => sub {
};
};
-# TODO refactor into FixMyStreet::TestMech;
-sub contains_or_lacks {
- my ($mech, $contains, $text) = @_;
- if ($contains) {
- $mech->content_contains($text);
- }
- else {
- $mech->content_lacks($text);
- }
-}
-
subtest 'time_spent' => sub {
FixMyStreet::override_config {
ALLOWED_COBRANDS => [ 'zurich' ],