diff options
author | Matthew Somerville <matthew@mysociety.org> | 2019-09-12 13:45:14 +0100 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2019-09-12 13:57:20 +0100 |
commit | 05de4770022b21e7ff7ff87ee2c7bba358989f60 (patch) | |
tree | fc4b8cacba0022f8015963731ac438202dce2b51 | |
parent | 7e1934d4f5aa61a467780193dcf966fecd50ea5d (diff) |
Make sure determine_contact_type called later.
The request cobrand is set on the schema during the app's
setup_request(), which is called by the root auto action.
So anything in a controller's begin action will access an
incorrect cobrand (if one has already been set).
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Contact.pm | 3 | ||||
-rw-r--r-- | t/cobrand/bathnes.t | 15 |
2 files changed, 16 insertions, 2 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Contact.pm b/perllib/FixMyStreet/App/Controller/Contact.pm index c8cd14907..06566a8ab 100644 --- a/perllib/FixMyStreet/App/Controller/Contact.pm +++ b/perllib/FixMyStreet/App/Controller/Contact.pm @@ -33,7 +33,6 @@ sub begin : Private { my ($self, $c) = @_; $c->forward('/begin'); $c->forward('setup_request'); - $c->forward('determine_contact_type'); } =head2 index @@ -44,6 +43,7 @@ Display contact us page sub index : Path : Args(0) { my ( $self, $c ) = @_; + $c->forward('determine_contact_type'); } =head2 submit @@ -55,6 +55,7 @@ Handle contact us form submission sub submit : Path('submit') : Args(0) { my ( $self, $c ) = @_; + $c->forward('determine_contact_type'); $c->res->redirect( '/contact' ) and return unless $c->req->method eq 'POST'; $c->go('index') unless $c->forward('validate'); diff --git a/t/cobrand/bathnes.t b/t/cobrand/bathnes.t index 6586dcb96..1ebddd05a 100644 --- a/t/cobrand/bathnes.t +++ b/t/cobrand/bathnes.t @@ -11,7 +11,7 @@ my $counciluser = $mech->create_user_ok('counciluser@example.com', name => 'Coun my $normaluser = $mech->create_user_ok('normaluser@example.com', name => 'Normal User'); $normaluser->update({ phone => "+447123456789" }); -$mech->create_problems_for_body(1, $body->id, 'Title', { +my ($problem) = $mech->create_problems_for_body(1, $body->id, 'Title', { areas => ",2651,", category => 'Potholes', cobrand => 'fixmystreet', user => $normaluser, service => 'iOS', extra => { _fields => [ @@ -199,4 +199,17 @@ subtest 'extra CSV columns are present if permission granted' => sub { }; +subtest 'check cobrand correctly reset on each request' => sub { + FixMyStreet::override_config { + 'ALLOWED_COBRANDS' => [ 'bathnes', 'fixmystreet' ], + }, sub { + $mech->log_in_ok( $superuser->email ); + $mech->host('www.fixmystreet.com'); + $mech->get_ok( '/contact?id=' . $problem->id ); + $mech->host('bathnes.fixmystreet.com'); + $mech->get_ok( '/contact?reject=1&id=' . $problem->id ); + $mech->content_contains('Reject report'); + } +}; + done_testing(); |