aboutsummaryrefslogtreecommitdiffstats
path: root/t/app/controller
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2019-05-09 09:49:31 +0100
committerMatthew Somerville <matthew-github@dracos.co.uk>2019-05-09 09:49:31 +0100
commitd6c53df54914479e7a8a3e6b1a20e0a7548a57df (patch)
treee163dfabea50e48b7bdda45827bd7c856337342e /t/app/controller
parentc25332f3c0a6201726882c9d5b69bf314b5d061d (diff)
parent0236d3a37da94e06e9e6208f50f6c0b9388feb7c (diff)
Merge branch 'template-same-name-spot'
Diffstat (limited to 't/app/controller')
-rw-r--r--t/app/controller/admin/templates.t24
1 files changed, 24 insertions, 0 deletions
diff --git a/t/app/controller/admin/templates.t b/t/app/controller/admin/templates.t
index 0d4430cad..6944f4b04 100644
--- a/t/app/controller/admin/templates.t
+++ b/t/app/controller/admin/templates.t
@@ -66,6 +66,30 @@ subtest "response templates can be added" => sub {
is $oxfordshire->response_templates->count, 1, "Response template was added";
};
+subtest "but not another with the same title" => sub {
+ my $fields = {
+ title => "Report acknowledgement",
+ text => "Another report acknowledgement.",
+ auto_response => undef,
+ "contacts[".$oxfordshirecontact->id."]" => 1,
+ };
+ my $list_url = "/admin/templates/" . $oxfordshire->id;
+ $mech->get_ok( "$list_url/new" );
+ $mech->submit_form_ok( { with_fields => $fields } );
+ is $mech->uri->path, "$list_url/new", 'not redirected';
+ $mech->content_contains( 'Please correct the errors below' );
+ $mech->content_contains( 'There is already a template with that title.' );
+
+ my @ts = $oxfordshire->response_templates->all;
+ is @ts, 1, "No new response template was added";
+
+ my $url = "$list_url/" . $ts[0]->id;
+ $mech->get_ok($url);
+ $mech->submit_form_ok( { with_fields => $fields } );
+ is $mech->uri->path, $list_url, 'redirected';
+ is $oxfordshire->response_templates->count, 1, "No new response template was added";
+};
+
subtest "response templates are included on page" => sub {
FixMyStreet::override_config {
ALLOWED_COBRANDS => [ 'oxfordshire' ],