diff options
Diffstat (limited to 't')
-rw-r--r-- | t/app/controller/admin.t | 10 | ||||
-rw-r--r-- | t/app/controller/admin/bodies.t | 11 | ||||
-rw-r--r-- | t/app/controller/report_new_staff.t | 8 | ||||
-rw-r--r-- | t/open311/populate-service-list.t | 46 |
4 files changed, 70 insertions, 5 deletions
diff --git a/t/app/controller/admin.t b/t/app/controller/admin.t index b170633fc..5607f2dc3 100644 --- a/t/app/controller/admin.t +++ b/t/app/controller/admin.t @@ -84,10 +84,10 @@ subtest 'check summary counts' => sub { FixMyStreet::override_config { ALLOWED_COBRANDS => [ 'fixmystreet' ], }, sub { - $mech->get_ok('/admin'); + $mech->get_ok('/admin/stats'); }; - $mech->title_like(qr/Summary/); + $mech->title_like(qr/Stats/); $mech->content_contains( "$problem_count</strong> live problems" ); $mech->content_contains( "$a_count confirmed alerts" ); @@ -102,8 +102,8 @@ subtest 'check summary counts' => sub { }, sub { ok $mech->host('oxfordshire.fixmystreet.com'); - $mech->get_ok('/admin'); - $mech->title_like(qr/Summary/); + $mech->get_ok('/admin/stats'); + $mech->title_like(qr/Stats/); my ($num_live) = $mech->content =~ /(\d+)<\/strong> live problems/; my ($num_alerts) = $mech->content =~ /(\d+) confirmed alerts/; @@ -116,7 +116,7 @@ subtest 'check summary counts' => sub { $alert->cobrand('oxfordshire'); $alert->update; - $mech->get_ok('/admin'); + $mech->get_ok('/admin/stats'); $mech->content_contains( ($num_live+1) . "</strong> live problems" ); $mech->content_contains( ($num_alerts+1) . " confirmed alerts" ); diff --git a/t/app/controller/admin/bodies.t b/t/app/controller/admin/bodies.t index 340351473..c73a90da1 100644 --- a/t/app/controller/admin/bodies.t +++ b/t/app/controller/admin/bodies.t @@ -250,6 +250,17 @@ subtest 'disable form message editing' => sub { }], 'right message added'; }; +subtest 'open311 protection editing' => sub { + $mech->get_ok('/admin/body/' . $body->id . '/test%20category'); + $mech->submit_form_ok( { with_fields => { + open311_protect => 1, + note => 'Protected from Open311 changes', + } } ); + $mech->content_contains('Values updated'); + my $contact = $body->contacts->find({ category => 'test category' }); + is $contact->get_extra_metadata('open311_protect'), 1, 'Open311 protect flag set'; +}; + }; # END of override wrap diff --git a/t/app/controller/report_new_staff.t b/t/app/controller/report_new_staff.t index 422b154ed..3817cdf3a 100644 --- a/t/app/controller/report_new_staff.t +++ b/t/app/controller/report_new_staff.t @@ -45,6 +45,14 @@ subtest "report_mark_private allows users to mark reports as private" => sub { "follow 'skip this step' link" ); + my $edin_cats = $mech->create_contact_ok( body_id => $body_ids{2651}, category => 'Cats', email => 'cats@example.com', non_public => 1 ); + $mech->submit_form_ok({ + button => 'submit_category_part_only', + with_fields => { category => 'Cats' } + }); + $mech->content_contains('id="form_non_public" value="1" checked disabled'); + $edin_cats->delete; + $mech->submit_form_ok( { with_fields => { diff --git a/t/open311/populate-service-list.t b/t/open311/populate-service-list.t index 59f8b7b65..bd837f203 100644 --- a/t/open311/populate-service-list.t +++ b/t/open311/populate-service-list.t @@ -349,6 +349,52 @@ subtest 'check new category marked non_public' => sub { is $contact->non_public, 1, 'contact marked as non_public'; }; +subtest 'check protected categories do not have name/group overwritten' => sub { + my $contact = FixMyStreet::DB->resultset('Contact')->search( { body_id => $body->id } )->first; + $contact->set_extra_metadata('open311_protect', 1); + $contact->set_extra_metadata('group', [ 'sanitation' ]); + $contact->non_public(0); + $contact->update; + + my $services_xml = '<?xml version="1.0" encoding="utf-8"?> + <services> + <service> + <service_code>100</service_code> + <service_name>Cans left out constantly</service_name> + <description>Garbage or recycling cans that have been left out for more than 24 hours after collection. Violators will be cited.</description> + <metadata>false</metadata> + <type>realtime</type> + <keywords>private</keywords> + <group>cleansing</group> + </service> + </services> + '; + + my $service_list = get_xml_simple_object( $services_xml ); + + FixMyStreet::override_config { + ALLOWED_COBRANDS => [ 'tester' ], + COBRAND_FEATURES => { + category_groups => { tester => 1 }, + } + }, sub { + my $processor = Open311::PopulateServiceList->new(); + $processor->_current_body( $body ); + $processor->process_services( $service_list ); + }; + + my $contact_count = FixMyStreet::DB->resultset('Contact')->search( { body_id => $body->id } )->count(); + is $contact_count, 1, 'correct number of contacts'; + + $contact->discard_changes; + is $contact->email, '100', 'email correct'; + is $contact->category, 'Cans left out 24x7', 'category unchanged'; + is_deeply $contact->groups, ['sanitation'], 'group unchanged'; + # test that something did change + is $contact->non_public, 1, 'contact marked as non_public'; +}; + + subtest 'check existing category marked non_public' => sub { my $contact = FixMyStreet::DB->resultset('Contact')->search( { body_id => $body->id } )->first; $contact->update({ |