diff options
-rw-r--r-- | perllib/FixMyStreet/App.pm | 6 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/About.pm | 31 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Root.pm | 12 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/View/Web.pm | 19 | ||||
-rw-r--r-- | t/app/controller/about.t | 18 |
5 files changed, 85 insertions, 1 deletions
diff --git a/perllib/FixMyStreet/App.pm b/perllib/FixMyStreet/App.pm index 60c25d0be..870453b09 100644 --- a/perllib/FixMyStreet/App.pm +++ b/perllib/FixMyStreet/App.pm @@ -34,6 +34,12 @@ __PACKAGE__->config( # Disable deprecated behavior needed by old applications disable_component_resolution_regex_fallback => 1, + + # Serve anything in web dir that is not a .cgi script + static => { # + include_path => [ __PACKAGE__->path_to("web") . "" ], + ignore_extensions => ['cgi'], + } ); # Start the application diff --git a/perllib/FixMyStreet/App/Controller/About.pm b/perllib/FixMyStreet/App/Controller/About.pm new file mode 100644 index 000000000..42a0ed18e --- /dev/null +++ b/perllib/FixMyStreet/App/Controller/About.pm @@ -0,0 +1,31 @@ +package FixMyStreet::App::Controller::About; +use Moose; +use namespace::autoclean; + +BEGIN { extends 'Catalyst::Controller'; } + +=head1 NAME + +FixMyStreet::App::Controller::About - Catalyst Controller + +=head1 DESCRIPTION + +Catalyst Controller. + +=head1 METHODS + +=cut + +=head2 index + +=cut + +sub index : Path : Args(0) { + my ( $self, $c ) = @_; + + # don't need to do anything here - should just pass through. +} + +__PACKAGE__->meta->make_immutable; + +1; diff --git a/perllib/FixMyStreet/App/Controller/Root.pm b/perllib/FixMyStreet/App/Controller/Root.pm index fc3932975..b61650f79 100644 --- a/perllib/FixMyStreet/App/Controller/Root.pm +++ b/perllib/FixMyStreet/App/Controller/Root.pm @@ -16,6 +16,18 @@ FixMyStreet::App::Controller::Root - Root Controller for FixMyStreet::App =head1 METHODS +=head2 auto + +Set up general things for this instance + +=cut + +sub auto { + my ( $self, $c ) = @_; + + return; +} + =head2 index The root page (/) diff --git a/perllib/FixMyStreet/App/View/Web.pm b/perllib/FixMyStreet/App/View/Web.pm index a201242bc..dcda54db9 100644 --- a/perllib/FixMyStreet/App/View/Web.pm +++ b/perllib/FixMyStreet/App/View/Web.pm @@ -11,7 +11,8 @@ __PACKAGE__->config( INCLUDE_PATH => [ # FixMyStreet::App->path_to( 'templates', 'web', 'default' ), ], - render_die => 1, + render_die => 1, + expose_methods => ['loc'], ); =head1 NAME @@ -24,4 +25,20 @@ TT View for FixMyStreet::App. =cut +=head2 loc + + [% loc('Some text to localize') %] + +Passes the text to the localisation engine for translations. + +FIXME - currently just passes through. + +=cut + +sub loc { + my ( $self, $c, @args ) = @_; + return join ' ', @args; +} + 1; + diff --git a/t/app/controller/about.t b/t/app/controller/about.t new file mode 100644 index 000000000..2ac628367 --- /dev/null +++ b/t/app/controller/about.t @@ -0,0 +1,18 @@ +use strict; +use warnings; + +use Test::More; +use Test::WWW::Mechanize::Catalyst 'FixMyStreet::App'; + +ok( my $mech = Test::WWW::Mechanize::Catalyst->new, 'Created mech object' ); + +# check that we can get the page +$mech->get_ok('/about'); +$mech->content_contains('FixMyStreet.com'); + +# check that geting the page as EHA produces a different page +ok $mech->host("www.reportemptyhomes.co.uk"), 'change host to reportemptyhomes'; +$mech->get_ok('/about'); +$mech->content_lacks('FixMyStreet.com'); + +done_testing(); |