aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perllib/Cobrand.pm21
-rwxr-xr-xt/Cobrand.t16
-rw-r--r--t/Cobrands/Mysite/Util.pm6
3 files changed, 38 insertions, 5 deletions
diff --git a/perllib/Cobrand.pm b/perllib/Cobrand.pm
index 3cd0fd03a..1acff1358 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.26 2009-10-13 09:24:09 louise Exp $
+# $Id: Cobrand.pm,v 1.27 2009-10-15 16:34:31 louise Exp $
package Cobrand;
use strict;
@@ -360,6 +360,24 @@ sub extra_params {
}
+=item show_watermark
+
+Returns a boolean indicating whether the map watermark should be displayed
+
+=cut
+sub show_watermark {
+ my ($cobrand) = @_;
+ my $handle;
+ if ($cobrand){
+ $handle = cobrand_handle($cobrand);
+ }
+ if ( !$cobrand || !$handle || !$handle->can('show_watermark')){
+ return 1;
+ } else{
+ return $handle->show_watermark();
+ }
+}
+
=item url
Given a URL, return a URL with any extra params needed appended to it.
@@ -376,7 +394,6 @@ sub url {
} else{
return $handle->url($url);
}
- return $url;
}
=item header_params
diff --git a/t/Cobrand.t b/t/Cobrand.t
index b0921213d..10f227052 100755
--- a/t/Cobrand.t
+++ b/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.16 2009-10-13 09:24:09 louise Exp $
+# $Id: Cobrand.t,v 1.17 2009-10-15 16:34:31 louise Exp $
#
use strict;
use warnings;
-use Test::More tests => 50;
+use Test::More tests => 53;
use Test::Exception;
use FindBin;
@@ -227,6 +227,17 @@ sub test_url {
is($url, '/xyz', 'url returns passed url if there is no url function defined by the cobrand');
}
+sub test_show_watermark {
+ my $cobrand = 'mysite';
+ my $watermark = Cobrand::show_watermark($cobrand);
+ is($watermark, 0, 'show_watermark returns output from cobrand module');
+
+ $cobrand = 'nosite';
+ $watermark = Cobrand::show_watermark($cobrand);
+ is($watermark, 1, 'watermark returns 1 if there is no show_watermark function defined by the cobrand');
+
+}
+
ok(test_cobrand_handle() == 1, 'Ran all tests for the cobrand_handle function');
ok(test_cobrand_page() == 1, 'Ran all tests for the cobrand_page function');
ok(test_site_restriction() == 1, 'Ran all tests for the site_restriction function');
@@ -243,3 +254,4 @@ ok(test_root_path_js() == 1, 'Ran all tests for root_js');
ok(test_site_title() == 1, 'Ran all tests for site_title');
ok(test_on_map_list_limit() == 1, 'Ran all tests for on_map_list_limit');
ok(test_url() == 1, 'Ran all tests for url');
+ok(test_show_watermark() == 1, 'Ran all tests for show_watermark');
diff --git a/t/Cobrands/Mysite/Util.pm b/t/Cobrands/Mysite/Util.pm
index 2ee49ad13..3669afa05 100644
--- a/t/Cobrands/Mysite/Util.pm
+++ b/t/Cobrands/Mysite/Util.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: Util.pm,v 1.15 2009-10-13 09:24:37 louise Exp $
+# $Id: Util.pm,v 1.16 2009-10-15 16:34:31 louise Exp $
package Cobrands::Mysite::Util;
use Page;
@@ -86,4 +86,8 @@ sub on_map_list_limit {
sub url {
return '/transformed_url';
}
+
+sub show_watermark {
+ return 0;
+}
1;