diff options
author | Dave Arter <davea@mysociety.org> | 2018-10-26 18:34:23 +0100 |
---|---|---|
committer | Dave Arter <davea@mysociety.org> | 2018-11-02 15:54:09 +0000 |
commit | d5d5e0cbfd991ac14aceed618672a2f5171b33dd (patch) | |
tree | c45071bc00cbb6d4ecfd30ba042521a2b3014524 /t/open311 | |
parent | 1ff2b4648af59b6e6909d4a8f1162fdbaa552d00 (diff) |
Add tests for per-cobrand category group handling
Diffstat (limited to 't/open311')
-rw-r--r-- | t/open311/populate-service-list.t | 68 |
1 files changed, 47 insertions, 21 deletions
diff --git a/t/open311/populate-service-list.t b/t/open311/populate-service-list.t index b54b1c242..313d5c809 100644 --- a/t/open311/populate-service-list.t +++ b/t/open311/populate-service-list.t @@ -1,4 +1,21 @@ #!/usr/bin/env perl +package FixMyStreet::Cobrand::Tester; + +use parent 'FixMyStreet::Cobrand::Default'; + +sub council_area_id { 1 } + + +package FixMyStreet::Cobrand::TesterGroups; + +use parent 'FixMyStreet::Cobrand::Default'; + +sub council_area_id { 1 } + +sub enable_category_groups { 1 } + + +package main; use FixMyStreet::Test; use FixMyStreet::DB; @@ -28,27 +45,36 @@ $bromley->body_areas->find_or_create({ area_id => 2482 } ); -subtest 'check basic functionality' => sub { - FixMyStreet::DB->resultset('Contact')->search( { body_id => 1 } )->delete(); - - my $service_list = get_xml_simple_object( get_standard_xml() ); - - my $processor = Open311::PopulateServiceList->new(); - $processor->_current_body( $body ); - $processor->process_services( $service_list ); - - my $contact_count = FixMyStreet::DB->resultset('Contact')->search( { body_id => 1 } )->count(); - is $contact_count, 3, 'correct number of contacts'; - - for my $test ( - { code => "001", group => "sanitation" }, - { code => "002", group => "street" }, - { code => "003", group => "street" }, - ) { - my $contact = FixMyStreet::DB->resultset('Contact')->search( { body_id => 1, email => $test->{code} } )->first; - is $contact->get_extra->{group}, $test->{group}, "Group set correctly"; - } -}; +for my $test ( + { cobrand => 'tester', groups => 0 }, + { cobrand => 'testergroups', groups => 1 }, +) { + FixMyStreet::override_config { + ALLOWED_COBRANDS => [ $test->{cobrand} ], + }, sub { + subtest 'check basic functionality' => sub { + FixMyStreet::DB->resultset('Contact')->search( { body_id => 1 } )->delete(); + + my $service_list = get_xml_simple_object( get_standard_xml() ); + + my $processor = Open311::PopulateServiceList->new(); + $processor->_current_body( $body ); + $processor->process_services( $service_list ); + + my $contact_count = FixMyStreet::DB->resultset('Contact')->search( { body_id => 1 } )->count(); + is $contact_count, 3, 'correct number of contacts'; + + for my $expects ( + { code => "001", group => $test->{groups} ? "sanitation" : undef }, + { code => "002", group => $test->{groups} ? "street" : undef }, + { code => "003", group => $test->{groups} ? "street" : undef }, + ) { + my $contact = FixMyStreet::DB->resultset('Contact')->search( { body_id => 1, email => $expects->{code} } )->first; + is $contact->get_extra->{group}, $expects->{group}, "Group set correctly"; + } + }; + }; +} subtest 'check non open311 contacts marked as deleted' => sub { FixMyStreet::DB->resultset('Contact')->search( { body_id => 1 } )->delete(); |