diff options
author | Matthew Somerville <matthew-github@dracos.co.uk> | 2019-05-03 13:31:57 +0100 |
---|---|---|
committer | Matthew Somerville <matthew-github@dracos.co.uk> | 2019-05-07 15:01:07 +0100 |
commit | 0236d3a37da94e06e9e6208f50f6c0b9388feb7c (patch) | |
tree | 53a206661f0b46303faaa3cf1e77c748f59b1621 /t/app | |
parent | b8fd2a09332798214188cbedecb85294645c06dc (diff) |
Prevent creation of two templates with same title.
Diffstat (limited to 't/app')
-rw-r--r-- | t/app/controller/admin/templates.t | 24 |
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' ], |