diff options
author | Matthew Somerville <matthew-github@dracos.co.uk> | 2019-02-15 13:32:20 +0000 |
---|---|---|
committer | Matthew Somerville <matthew-github@dracos.co.uk> | 2019-02-18 13:14:50 +0000 |
commit | fa33cd37ec6e478356ade8ef3554d01df77287f8 (patch) | |
tree | fce7ac414bd9bb33751700627f52577e784475c4 /t | |
parent | f0eab21555efca2218d3cc49cf435ea09d03ac4b (diff) |
[Bromley] Allow subcategory attachment to users.
Diffstat (limited to 't')
-rw-r--r-- | t/cobrand/bromley.t | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/t/cobrand/bromley.t b/t/cobrand/bromley.t index 6ee4be282..05581bdfe 100644 --- a/t/cobrand/bromley.t +++ b/t/cobrand/bromley.t @@ -4,7 +4,7 @@ use FixMyStreet::Script::Reports; my $mech = FixMyStreet::TestMech->new; # Create test data -my $user = $mech->create_user_ok( 'bromley@example.com' ); +my $user = $mech->create_user_ok( 'bromley@example.com', name => 'Bromley' ); my $body = $mech->create_body_ok( 2482, 'Bromley Council'); my $contact = $mech->create_contact_ok( body_id => $body->id, @@ -16,6 +16,7 @@ $contact->set_extra_fields( { code => 'easting', datatype => 'number', }, { code => 'northing', datatype => 'number', }, { code => 'service_request_id_ext', datatype => 'number', }, + { code => 'service_sub_code', values => [ { key => 'RED', name => 'Red' }, { key => 'BLUE', name => 'Blue' } ], }, ); $contact->update; my $tfl = $mech->create_body_ok( 2482, 'TfL'); @@ -211,4 +212,20 @@ subtest 'check geolocation overrides' => sub { } }; +subtest 'check special subcategories in admin' => sub { + $mech->create_user_ok('superuser@example.com', is_superuser => 1); + $mech->log_in_ok('superuser@example.com'); + $user->update({ from_body => $body->id }); + FixMyStreet::override_config { + ALLOWED_COBRANDS => 'bromley', + MAPIT_URL => 'http://mapit.uk/', + }, sub { + $mech->get_ok('/admin/user_edit/' . $user->id); + $mech->submit_form_ok({ with_fields => { 'contacts['.$contact->id.']' => 1, 'contacts[BLUE]' => 1 } }); + }; + $user->discard_changes; + is_deeply $user->get_extra_metadata('categories'), [ $contact->id ]; + is_deeply $user->get_extra_metadata('subcategories'), [ 'BLUE' ]; +}; + done_testing(); |