diff options
-rw-r--r-- | perllib/FixMyStreet/Cobrand.pm | 18 | ||||
-rw-r--r-- | t/app/controller/about.t | 2 | ||||
-rw-r--r-- | t/app/controller/admin.t | 45 | ||||
-rw-r--r-- | t/app/controller/report_import.t | 2 | ||||
-rw-r--r-- | t/app/controller/reports.t | 4 |
5 files changed, 47 insertions, 24 deletions
diff --git a/perllib/FixMyStreet/Cobrand.pm b/perllib/FixMyStreet/Cobrand.pm index 647261e32..b88f6facc 100644 --- a/perllib/FixMyStreet/Cobrand.pm +++ b/perllib/FixMyStreet/Cobrand.pm @@ -109,4 +109,22 @@ sub get_class_for_moniker { return 'FixMyStreet::Cobrand::Default'; } +=head2 exists + + FixMyStreet::Cobrand->exists( $moniker ); + +Given a moniker, returns true if that cobrand is available to us for use + +=cut + +sub exists { + my ( $class, $moniker ) = @_; + + foreach my $avail ( $class->available_cobrand_classes ) { + return 1 if $moniker eq $avail->{moniker}; + } + + return 0; +} + 1; diff --git a/t/app/controller/about.t b/t/app/controller/about.t index ea7b1af20..4e49cdac9 100644 --- a/t/app/controller/about.t +++ b/t/app/controller/about.t @@ -13,7 +13,7 @@ $mech->content_contains('html class="no-js" lang="en-gb"'); SKIP: { skip( "Need 'emptyhomes' in ALLOWED_COBRANDS config", 8 ) - unless FixMyStreet::App->config->{ALLOWED_COBRANDS} =~ m{emptyhomes}; + unless FixMyStreet::Cobrand->exists('emptyhomes'); # check that geting the page as EHA produces a different page ok $mech->host("reportemptyhomes.co.uk"), 'change host to reportemptyhomes'; diff --git a/t/app/controller/admin.t b/t/app/controller/admin.t index 9b517abf3..09d99cfdf 100644 --- a/t/app/controller/admin.t +++ b/t/app/controller/admin.t @@ -105,34 +105,39 @@ subtest 'check summary counts' => sub { $mech->content_contains( "$q_count questionnaires sent" ); - ok $mech->host('barnet.fixmystreet.com'); + SKIP: { + skip( "Need 'barnet' in ALLOWED_COBRANDS config", 7 ) + unless FixMyStreet::Cobrand->exists('barnet'); - $mech->get_ok('/admin'); - $mech->title_like(qr/Summary/); + ok $mech->host('barnet.fixmystreet.com'); - my ($num_live) = $mech->content =~ /(\d+)<\/strong> live problems/; - my ($num_alerts) = $mech->content =~ /(\d+) confirmed alerts/; - my ($num_qs) = $mech->content =~ /(\d+) questionnaires sent/; + $mech->get_ok('/admin'); + $mech->title_like(qr/Summary/); - $report->council(2489); - $report->cobrand('barnet'); - $report->update; + my ($num_live) = $mech->content =~ /(\d+)<\/strong> live problems/; + my ($num_alerts) = $mech->content =~ /(\d+) confirmed alerts/; + my ($num_qs) = $mech->content =~ /(\d+) questionnaires sent/; - $alert->cobrand('barnet'); - $alert->update; + $report->council(2489); + $report->cobrand('barnet'); + $report->update; - $mech->get_ok('/admin'); + $alert->cobrand('barnet'); + $alert->update; - $mech->content_contains( ($num_live+1) . "</strong> live problems" ); - $mech->content_contains( ($num_alerts+1) . " confirmed alerts" ); - $mech->content_contains( ($num_qs+1) . " questionnaires sent" ); + $mech->get_ok('/admin'); - $report->council(2504); - $report->cobrand(''); - $report->update; + $mech->content_contains( ($num_live+1) . "</strong> live problems" ); + $mech->content_contains( ($num_alerts+1) . " confirmed alerts" ); + $mech->content_contains( ($num_qs+1) . " questionnaires sent" ); + + $report->council(2504); + $report->cobrand(''); + $report->update; - $alert->cobrand(''); - $alert->update; + $alert->cobrand(''); + $alert->update; + } FixMyStreet::App->model('DB::Problem')->search( { council => 1 } )->update( { council => 2489 } ); ok $mech->host('fixmystreet.com'); diff --git a/t/app/controller/report_import.t b/t/app/controller/report_import.t index 934bf0346..eb686b44e 100644 --- a/t/app/controller/report_import.t +++ b/t/app/controller/report_import.t @@ -266,7 +266,7 @@ subtest "Submit a correct entry (with location) to cobrand" => sub { SKIP: { skip( "Need 'fiksgatami' in ALLOWED_COBRANDS config", 20 ) - unless FixMyStreet::App->config->{ALLOWED_COBRANDS} =~ m{fiksgatami}; + unless FixMyStreet::Cobrand->exists('fiksgatami'); mySociety::MaPit::configure('http://mapit.nuug.no/'); ok $mech->host("fiksgatami.no"), 'change host to fiksgatami'; diff --git a/t/app/controller/reports.t b/t/app/controller/reports.t index 58803d778..801dbeddb 100644 --- a/t/app/controller/reports.t +++ b/t/app/controller/reports.t @@ -17,14 +17,14 @@ $mech->follow_link_ok( { text_regex => qr/Birmingham/ } ); SKIP: { skip( "Need 'emptyhomes' in ALLOWED_COBRANDS config", 8 ) - unless FixMyStreet::App->config->{ALLOWED_COBRANDS} =~ m{emptyhomes}; + unless FixMyStreet::Cobrand->exists('emptyhomes'); ok $mech->host("reportemptyhomes.com"), 'change host to reportemptyhomes'; $mech->get_ok('/reports'); # EHA lacks one column the others have $mech->content_lacks('state unknown'); skip( "Need 'fiksgatami' in ALLOWED_COBRANDS config", 8 ) - unless FixMyStreet::App->config->{ALLOWED_COBRANDS} =~ m{fiksgatami}; + unless FixMyStreet::Cobrand->exists('fiksgatami'); mySociety::MaPit::configure('http://mapit.nuug.no/'); ok $mech->host("fiksgatami.no"), 'change host to fiksgatami'; $mech->get_ok('/reports'); |