diff options
author | Dave Arter <davea@mysociety.org> | 2018-05-15 14:10:43 +0100 |
---|---|---|
committer | Dave Arter <davea@mysociety.org> | 2018-06-26 14:44:23 +0100 |
commit | ae0381e4e74f82cf55181f07528558e7df37443e (patch) | |
tree | d449442c45f79a3b0e5a01db9fb47d615ae09f6d /t | |
parent | 7c009ce048fbe36db24dd1a24f3542503db2e898 (diff) |
Enable editing of category group in admin
Fixes mysociety/fixmystreetforcouncils#275
Diffstat (limited to 't')
-rw-r--r-- | t/app/controller/admin/bodies.t | 53 |
1 files changed, 52 insertions, 1 deletions
diff --git a/t/app/controller/admin/bodies.t b/t/app/controller/admin/bodies.t index a485d286d..f67e45bf6 100644 --- a/t/app/controller/admin/bodies.t +++ b/t/app/controller/admin/bodies.t @@ -1,9 +1,17 @@ +package FixMyStreet::Cobrand::Tester; + +use parent 'FixMyStreet::Cobrand::Default'; + +sub enable_category_groups { 1 } + +package main; use FixMyStreet::TestMech; my $mech = FixMyStreet::TestMech->new; my $superuser = $mech->create_user_ok('superuser@example.com', name => 'Super User', is_superuser => 1); $mech->log_in_ok( $superuser->email ); +my $body = $mech->create_body_ok(2650, 'Aberdeen City Council'); # This override is wrapped around ALL the /admin/body tests FixMyStreet::override_config { @@ -12,7 +20,6 @@ FixMyStreet::override_config { BASE_URL => 'http://www.example.org', }, sub { -my $body = $mech->create_body_ok(2650, 'Aberdeen City Council'); $mech->get_ok('/admin/body/' . $body->id); $mech->content_contains('Aberdeen City Council'); $mech->content_like(qr{AB\d\d}); @@ -56,6 +63,7 @@ subtest 'check contact creation' => sub { subtest 'check contact editing' => sub { $mech->get_ok('/admin/body/' . $body->id .'/test%20category'); + $mech->content_lacks( 'group</strong> is used for the top-level category' ); $mech->submit_form_ok( { with_fields => { email => 'test2@example.com', @@ -201,4 +209,47 @@ subtest 'check text output' => sub { }; # END of override wrap +FixMyStreet::override_config { + ALLOWED_COBRANDS => ['tester'], + MAPIT_URL => 'http://mapit.uk/', + MAPIT_TYPES => [ 'UTA' ], + BASE_URL => 'http://www.example.org', +}, sub { + subtest 'group editing works' => sub { + $mech->get_ok('/admin/body/' . $body->id); + $mech->content_contains( 'group</strong> is used for the top-level category' ); + + $mech->submit_form_ok( { with_fields => { + category => 'grouped category', + email => 'test@example.com', + note => 'test note', + group => 'group a', + non_public => undef, + state => 'unconfirmed', + } } ); + + my $contact = $body->contacts->find({ category => 'grouped category' }); + is $contact->get_extra_metadata('group'), 'group a', "group stored correctly"; + }; + + subtest 'group can be unset' => sub { + $mech->get_ok('/admin/body/' . $body->id); + $mech->content_contains( 'group</strong> is used for the top-level category' ); + + $mech->submit_form_ok( { with_fields => { + category => 'grouped category', + email => 'test@example.com', + note => 'test note', + group => undef, + non_public => undef, + state => 'unconfirmed', + } } ); + + my $contact = $body->contacts->find({ category => 'grouped category' }); + is $contact->get_extra_metadata('group'), undef, "group unset correctly"; + }; + +}; + + done_testing(); |