aboutsummaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
Diffstat (limited to 't')
-rw-r--r--t/app/controller/admin/bodies.t17
-rw-r--r--t/app/controller/admin/translations.t2
-rw-r--r--t/cobrand/bathnes.t18
-rw-r--r--t/roles/translatable.t7
4 files changed, 42 insertions, 2 deletions
diff --git a/t/app/controller/admin/bodies.t b/t/app/controller/admin/bodies.t
index 75f0f606f..cd86e3da6 100644
--- a/t/app/controller/admin/bodies.t
+++ b/t/app/controller/admin/bodies.t
@@ -51,7 +51,7 @@ subtest 'check contact creation' => sub {
non_public => 'on',
} } );
$mech->get_ok('/admin/body/' . $body->id . '/test/category');
- $mech->content_contains('<h1>test/category</h1>');
+ $mech->content_contains('test/category');
};
subtest 'check contact editing' => sub {
@@ -91,6 +91,21 @@ subtest 'check contact editing' => sub {
$mech->content_contains( '<td><strong>test2@example.com' );
};
+subtest 'check contact renaming' => sub {
+ my ($report) = $mech->create_problems_for_body(1, $body->id, 'Title', { category => 'test category' });
+ $mech->get_ok('/admin/body/' . $body->id .'/test%20category');
+ $mech->submit_form_ok( { with_fields => { category => 'private category' } } );
+ $mech->content_contains('You cannot rename');
+ $mech->submit_form_ok( { with_fields => { category => 'testing category' } } );
+ $mech->content_contains( 'testing category' );
+ $mech->get('/admin/body/' . $body->id . '/test%20category');
+ is $mech->res->code, 404;
+ $mech->get_ok('/admin/body/' . $body->id . '/testing%20category');
+ $report->discard_changes;
+ is $report->category, 'testing category';
+ $mech->submit_form_ok( { with_fields => { category => 'test category' } } );
+};
+
subtest 'check contact updating' => sub {
$mech->get_ok('/admin/body/' . $body->id . '/test%20category');
$mech->content_like(qr{test2\@example.com</strong>[^<]*</td>[^<]*<td>unconfirmed}s);
diff --git a/t/app/controller/admin/translations.t b/t/app/controller/admin/translations.t
index f5c32baa6..442be68d5 100644
--- a/t/app/controller/admin/translations.t
+++ b/t/app/controller/admin/translations.t
@@ -59,7 +59,7 @@ subtest 'check add category with translation' => sub {
$mech->submit_form_ok( { with_fields => {
category => 'Potholes',
translation_de => 'DE potholes',
- email => 'potholes@example.org',
+ email => 'potholes',
} } );
# check that error page includes translations
diff --git a/t/cobrand/bathnes.t b/t/cobrand/bathnes.t
index d434d1160..42a8ffe93 100644
--- a/t/cobrand/bathnes.t
+++ b/t/cobrand/bathnes.t
@@ -1,6 +1,10 @@
+use Test::MockModule;
use FixMyStreet::TestMech;
my $mech = FixMyStreet::TestMech->new;
+my $cobrand = Test::MockModule->new('FixMyStreet::Cobrand::BathNES');
+$cobrand->mock('area_types', sub { [ 'UTA' ] });
+
my $body = $mech->create_body_ok(2551, 'Bath and North East Somerset Council');
my @cats = ('Litter', 'Other', 'Potholes', 'Traffic lights');
for my $contact ( @cats ) {
@@ -59,6 +63,20 @@ subtest 'cobrand displays council name' => sub {
$mech->content_like( qr/Bath and North East Somerset\b/ );
};
+subtest 'check override contact display name' => sub {
+ $mech->log_in_ok( $superuser->email );
+ $mech->get_ok("/admin/body/" . $body->id . '/Litter');
+ $mech->content_contains('<h1>Litter</h1>');
+ $mech->content_contains('extra[display_name]');
+ $mech->submit_form_ok({ with_fields => {
+ 'extra[display_name]' => 'Wittering'
+ }});
+ $mech->get_ok('/reports/Bath+and+North+East+Somerset');
+ $mech->content_contains('Wittering</option>');
+ $mech->content_contains('value="Litter"');
+ $mech->content_lacks('Litter</option>');
+};
+
subtest 'extra CSV columns are absent if permission not granted' => sub {
$mech->log_in_ok( $counciluser->email );
diff --git a/t/roles/translatable.t b/t/roles/translatable.t
index e13f49fc6..9f8c67394 100644
--- a/t/roles/translatable.t
+++ b/t/roles/translatable.t
@@ -74,4 +74,11 @@ FixMyStreet::override_config {
$mech->content_contains('Hull i veien');
};
+subtest 'Check display_name override' => sub {
+ $contact->set_extra_metadata( display_name => 'Override name' );
+ $contact->update;
+ is $contact->category_display, "Override name";
+ is $problem->category_display, "Override name";
+};
+
done_testing;