diff options
Diffstat (limited to 't')
-rwxr-xr-x | t/Page.t | 31 | ||||
-rw-r--r-- | t/app/helpers/send_email.t | 19 | ||||
-rw-r--r-- | t/templates/mysite/test-header | 1 |
3 files changed, 14 insertions, 37 deletions
@@ -11,7 +11,7 @@ use strict; use warnings; -use Test::More tests => 8; +use Test::More tests => 4; use Test::Exception; use FindBin; @@ -36,33 +36,6 @@ sub set_lang($) { mySociety::Locale::change(); } -sub test_header() { - my $q = mock_query(); - my $html; - my %params = (title => 'test title'); - set_lang('en-gb,English,en_GB'); - - # Test that param that isn't explicitly allowed raises error - $params{'test-param'} = 'test'; - throws_ok { Page::header($q, %params); } qr/bad parameter/, 'bad parameter caught ok'; - delete $params{'test-param'}; - - # Test that template passed is rendered - $params{'template'} = 'test'; - $html = Page::template_include('test-header', $q, - '/../t/templates/' . $q->{site} . '/', - title => 'My test title', lang => 'en-gb' - ); - - like ($html, qr/My test header template/, 'named template rendered ok'); - - return 1; -} - -sub test_footer(){ - return 1; -} - sub test_base_url_with_lang { set_lang('en-gb,English,en_GB'); my $q = mock_query(); @@ -80,5 +53,3 @@ sub test_base_url_with_lang { ok(test_base_url_with_lang() == 1, 'Ran all tests for base_url_with_lang'); -ok(test_footer() == 1, 'Ran all tests for the footer function'); -ok(test_header() == 1, 'Ran all tests for the header function'); diff --git a/t/app/helpers/send_email.t b/t/app/helpers/send_email.t index 2e90b9f1a..5ab84e017 100644 --- a/t/app/helpers/send_email.t +++ b/t/app/helpers/send_email.t @@ -15,11 +15,17 @@ use Email::Send::Test; use Path::Class; use_ok 'FixMyStreet::App'; -my $c = FixMyStreet::App->new; - -# fake up the request a little -$c->req->uri( URI->new('http://localhost/') ); -$c->req->base( $c->req->uri ); +my $c = FixMyStreet::App->new( + { + request => Catalyst::Request->new( + { + base => URI->new('http://fixmystreet.com/'), + uri => URI->new('http://fixmystreet.com/') + } + ), + } +); +$c->setup_request(); # set some values in the stash $c->stash->{foo} = 'bar'; @@ -40,7 +46,8 @@ my $email_as_string = $emails[0]->as_string; ok $email_as_string =~ s{\s+Date:\s+\S.*?$}{}xms, "Found and stripped out date"; my $expected_email_content = file(__FILE__)->dir->file('send_email_sample.txt')->slurp; -$expected_email_content =~ s{CONTACT_EMAIL}{ FixMyStreet->config('CONTACT_EMAIL') }e; +my $sender = '"' . FixMyStreet->config('CONTACT_NAME') . '" <' . FixMyStreet->config('CONTACT_EMAIL') . '>'; +$expected_email_content =~ s{CONTACT_EMAIL}{$sender}; is $email_as_string, $expected_email_content, diff --git a/t/templates/mysite/test-header b/t/templates/mysite/test-header deleted file mode 100644 index 83d959d3d..000000000 --- a/t/templates/mysite/test-header +++ /dev/null @@ -1 +0,0 @@ -My test header template |