aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perllib/Cobrand.pm6
-rwxr-xr-xperllib/t/Cobrand.t11
-rwxr-xr-xweb/index.cgi7
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);
}