diff options
author | louise <louise> | 2009-09-10 08:54:33 +0000 |
---|---|---|
committer | louise <louise> | 2009-09-10 08:54:33 +0000 |
commit | cdaae9dbf5631ee7c8bf6822fcc0ced0b91de8a6 (patch) | |
tree | 63774a50fbbf7c163e351377b1a54db3a7916e80 | |
parent | d020b599a3e8be4d9455e8dd5981132b04b2b20c (diff) |
Delegate to cobrand for base_url in base_url_with_lang, delegate to cobrand for contact_email
-rw-r--r-- | perllib/Cobrand.pm | 21 | ||||
-rwxr-xr-x | t/Cobrand.t | 4 | ||||
-rw-r--r-- | t/Cobrands/Mysite/Util.pm | 4 | ||||
-rwxr-xr-x | t/Page.t | 15 |
4 files changed, 29 insertions, 15 deletions
diff --git a/perllib/Cobrand.pm b/perllib/Cobrand.pm index d589c9fbe..f5a1cc528 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.11 2009-09-09 15:29:26 louise Exp $ +# $Id: Cobrand.pm,v 1.12 2009-09-10 08:54:34 louise Exp $ package Cobrand; use strict; @@ -85,11 +85,30 @@ Return the base url for the cobranded version of the site =cut sub base_url{ my $cobrand = shift; + return mySociety::Config::get('BASE_URL') unless $cobrand; my $handle = cobrand_handle($cobrand); return mySociety::Config::get('BASE_URL') unless $handle; return $handle->base_url(); } +=item contact_email COBRAND + +Return the contact email for the cobranded version of the site + +=cut +sub contact_email{ + my $cobrand = shift; + $cobrand = uc($cobrand); + my $sender; + if ($cobrand){ + $sender = mySociety::Config::get("CONTACT_EMAIL_" . $cobrand, undef); + } + if (!$sender){ + $sender = mySociety::Config::get('CONTACT_EMAIL'); + } + return $sender; +} + =item set_lang_and_domain COBRAND LANG Set the language and domain of the site based on the cobrand and host diff --git a/t/Cobrand.t b/t/Cobrand.t index 3f2e34fba..13e9ef6b4 100755 --- a/t/Cobrand.t +++ b/t/Cobrand.t @@ -6,7 +6,7 @@ # Copyright (c) 2009 UK Citizens Online Democracy. All rights reserved. # Email: louise@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: Cobrand.t,v 1.5 2009-09-09 15:29:27 louise Exp $ +# $Id: Cobrand.t,v 1.6 2009-09-10 08:54:33 louise Exp $ # use strict; @@ -63,7 +63,7 @@ sub test_base_url{ # should get the result of the page function in the cobrand module if one exists my $base_url = Cobrand::base_url($cobrand); - is('mysite.example.com', $base_url, 'base_url returns output from cobrand module'); + is('http://mysite.example.com', $base_url, 'base_url returns output from cobrand module'); # should return the base url from the config if there is no cobrand module $cobrand = 'nosite'; diff --git a/t/Cobrands/Mysite/Util.pm b/t/Cobrands/Mysite/Util.pm index ebefe6336..f9248b68f 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.3 2009-09-09 15:29:27 louise Exp $ +# $Id: Util.pm,v 1.4 2009-09-10 08:54:33 louise Exp $ package Cobrands::Mysite::Util; use Page; @@ -34,7 +34,7 @@ sub page{ } sub base_url{ - return 'mysite.example.com'; + return 'http://mysite.example.com'; } 1; @@ -6,12 +6,12 @@ # Copyright (c) 2009 UK Citizens Online Democracy. All rights reserved. # Email: louise@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: Page.t,v 1.2 2009-09-03 13:54:13 louise Exp $ +# $Id: Page.t,v 1.3 2009-09-10 08:54:33 louise Exp $ # use strict; use warnings; -use Test::More tests => 9; +use Test::More tests => 8; use Test::Exception; use FindBin; @@ -60,23 +60,18 @@ sub test_footer(){ } sub test_base_url_with_lang { - $ENV{HTTP_HOST}='test.com'; set_lang('en-gb,English,en_GB'); my $q = mock_query(); my $url = Page::base_url_with_lang($q); - ok($url eq 'http://test.com', 'Basic url rendered ok'); + ok($url eq 'http://mysite.example.com', 'Basic url rendered ok'); $q = new MockQuery('emptyhomes'); $url = Page::base_url_with_lang($q); - ok($url eq 'http://en.test.com', 'Empty homes url with lang returned ok'); + like($url, qr/http:\/\/en\.emptyhomes\./, 'Empty homes url with lang returned ok'); $url = Page::base_url_with_lang($q, 1); - ok($url eq 'http://cy.test.com', 'Empty homes url with lang reversed returned ok'); + like($url, qr/http:\/\/cy\.emptyhomes\./, 'Empty homes url with lang reversed returned ok'); - $q = new MockQuery('emptyhomes'); - $ENV{HTTP_HOST}='en.test.com'; - $url = Page::base_url_with_lang($q); - ok($url eq 'http://en.test.com', 'No extra lang part for emptyhomes url with lang part'); } ok(test_base_url_with_lang() == 1, 'Ran all tests for base_url_with_lang'); |