aboutsummaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
Diffstat (limited to 't')
-rw-r--r--t/open311/populate-service-list.t68
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();