diff options
author | louise <louise> | 2009-08-26 17:24:39 +0000 |
---|---|---|
committer | louise <louise> | 2009-08-26 17:24:39 +0000 |
commit | 47be3af4139fb43150201f145d73d057589746e5 (patch) | |
tree | 0aa83aa0b45149b2b8de0416e978c02d4f2402ff | |
parent | 9f5f37ea2a64907b3695051191d1c5636980a958 (diff) |
Adding a cobrand param to the querystring has no effect if there is no cobrand in the domain or there is no perl module for the cobrand
-rw-r--r-- | perllib/Cobrand.pm | 6 | ||||
-rwxr-xr-x | perllib/t/Cobrand.t | 11 | ||||
-rwxr-xr-x | web/index.cgi | 7 |
3 files changed, 18 insertions, 6 deletions
diff --git a/perllib/Cobrand.pm b/perllib/Cobrand.pm index fba948868..cd336f0e4 100644 --- a/perllib/Cobrand.pm +++ b/perllib/Cobrand.pm @@ -7,7 +7,7 @@ # Copyright (c) 2009 UK Citizens Online Democracy. All rights reserved. # Email: louise@mysociety.org. WWW: http://www.mysociety.org # -# $Id: Cobrand.pm,v 1.3 2009-08-26 16:52:14 louise Exp $ +# $Id: Cobrand.pm,v 1.4 2009-08-26 17:24:39 louise Exp $ package Cobrand; use strict; @@ -35,7 +35,9 @@ sub cobrand_page{ my $cobrand_class = ucfirst($cobrand); my $class = "Cobrands::" . $cobrand_class . "::Util"; eval "use $class"; - my $handle = $class->new; + my $handle; + eval{ $handle = $class->new }; + return 0 if $@; my ($out, %params) = $handle->page($q); return ($out, %params); } diff --git a/perllib/t/Cobrand.t b/perllib/t/Cobrand.t index 36ec9fefa..c9ad93b65 100755 --- a/perllib/t/Cobrand.t +++ b/perllib/t/Cobrand.t @@ -6,12 +6,12 @@ # Copyright (c) 2009 UK Citizens Online Democracy. All rights reserved. # Email: louise@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: Cobrand.t,v 1.1 2009-08-26 16:52:14 louise Exp $ +# $Id: Cobrand.t,v 1.2 2009-08-26 17:24:40 louise Exp $ # use strict; use warnings; -use Test::More tests => 2; +use Test::More tests => 3; use Test::Exception; use FindBin; @@ -24,9 +24,16 @@ use MockQuery; sub test_cobrand_page{ my $q = new MockQuery('mysite'); + # should get the result of the page function in the cobrand module if one exists my ($html, $params) = Cobrand::cobrand_page($q); like($html, qr/A cobrand produced page/, 'cobrand_page returns output from cobrand module'); + + # should return 0 if no cobrand module exists + $q = new MockQuery('mynonexistingsite'); + ($html, $params) = Cobrand::cobrand_page($q); + is($html, 0, 'cobrand_page returns 0 if there is no cobrand module'); return 1; + } diff --git a/web/index.cgi b/web/index.cgi index 0319f56a6..56cd79147 100755 --- a/web/index.cgi +++ b/web/index.cgi @@ -6,7 +6,7 @@ # Copyright (c) 2006 UK Citizens Online Democracy. All rights reserved. # Email: matthew@mysociety.org. WWW: http://www.mysociety.org # -# $Id: index.cgi,v 1.273 2009-08-26 16:52:14 louise Exp $ +# $Id: index.cgi,v 1.274 2009-08-26 17:24:39 louise Exp $ use strict; use Standard; @@ -84,8 +84,11 @@ sub main { } elsif ($q->param('pc') || ($q->param('x') && $q->param('y'))) { ($out, %params) = display_location($q); $params{title} = _('Viewing a location'); - } elsif ($q->param('cobrand_page')) { + } elsif ($q->param('cobrand_page') && ($q->{site} ne 'fixmystreet')) { ($out, %params) = Cobrand::cobrand_page($q); + if (! $out){ + $out = front_page($q); + } } else { $out = front_page($q); } |