diff options
author | Dave Arter <davea@mysociety.org> | 2020-08-24 16:34:59 +0100 |
---|---|---|
committer | Dave Arter <davea@mysociety.org> | 2020-08-24 17:14:05 +0100 |
commit | d9cf470f321dc334391a35405a527521a3b605d5 (patch) | |
tree | 12744ac9a12117bb548f3911fb255173b6498045 /t/cobrand/hackney.t | |
parent | 51252c8ad919aa7fe0f8c8fe7ac8afadb6de5b18 (diff) |
[Hackney] Allow editing & addition of contacts with special destination addresses
This adds a cobrand hook to validate the email address provided when editing a contact
in the admin.
Diffstat (limited to 't/cobrand/hackney.t')
-rw-r--r-- | t/cobrand/hackney.t | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/t/cobrand/hackney.t b/t/cobrand/hackney.t index 374bf2ea9..6ab47a7ce 100644 --- a/t/cobrand/hackney.t +++ b/t/cobrand/hackney.t @@ -48,6 +48,10 @@ $hackney_user->user_body_permissions->create({ body => $hackney, permission_type => 'moderate', }); +$hackney_user->user_body_permissions->create({ + body => $hackney, + permission_type => 'category_edit', +}); my $contact2 = $mech->create_contact_ok( body_id => $hackney->id, @@ -291,5 +295,28 @@ subtest "check category extra uses correct name" => sub { like $extra_details->{category_extra}, qr/Hackney Council/, 'correct name in category extras'; }; +subtest "can edit special destination email addresses" => sub { + FixMyStreet::override_config { + MAPIT_URL => 'http://mapit.uk/', + ALLOWED_COBRANDS => ['hackney'], + COBRAND_FEATURES => { anonymous_account => { hackney => 'anonymous' } }, + }, sub { + $contact2->update({ send_method => 'Email' }); + $mech->log_in_ok( $hackney_user->email ); + $mech->get_ok("/admin/body/" . $hackney->id . "/" . $contact2->category); + $mech->submit_form_ok( { with_fields => { email => 'park:parks@example.com;estate:estates@example;other:new@example.org' } }, + "submit valid new email address"); + $mech->content_lacks("Please enter a valid email"); + $contact2->discard_changes; + is $contact2->email, 'park:parks@example.com;estate:estates@example;other:new@example.org', "New email addresses saved"; + + $mech->get_ok("/admin/body/" . $hackney->id . "/" . $contact2->category); + $mech->submit_form_ok( { with_fields => { email => 'invalid' } }, + "submit invalid new email address"); + $mech->content_contains("Please enter a valid email"); + $contact2->discard_changes; + is $contact2->email, 'park:parks@example.com;estate:estates@example;other:new@example.org', "Invalid email addresses not saved"; + }; +}; done_testing(); |