From: Arthur Axel 'fREW' Schmidt Date: Thu, 13 Aug 2015 23:23:20 +0000 (-0700) Subject: Add test that env does not get trampled X-Git-Tag: 5.90100~2^2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=878f62712380e7945c29dc1cb215b8afd30fb923 Add test that env does not get trampled --- diff --git a/Changes b/Changes index 92d65c0..452584f 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,7 @@ # This file documents the revision history for Perl extension Catalyst. + - Add test that env does not get trampled (Arthur Axel fREW Schmidt) + 5.90098 - 2015-08-11 - Fix for RT#106373 (Issue when you try to install and also have an old verion of Test::Mechanize::WWW::Catalyst) diff --git a/t/middleware-stash.t b/t/middleware-stash.t index baeb108..24b95f2 100644 --- a/t/middleware-stash.t +++ b/t/middleware-stash.t @@ -3,6 +3,28 @@ use strict; { + package MyMiddleware; + $INC{'MyMiddleware'} = __FILE__; + + our $INNER_VAR_EXPOSED; + + use base 'Plack::Middleware'; + + sub call { + my ($self, $env) = @_; + + my $res = $self->app->($env); + + return $self->response_cb($res, sub{ + my $inner = shift; + + $INNER_VAR_EXPOSED = $env->{inner_var_from_catalyst}; + + return; + }); + + } + package MyAppChild::Controller::User; $INC{'MyAppChild/Controller/User.pm'} = __FILE__; @@ -14,6 +36,8 @@ use strict; $c->stash->{inner} = "inner"; $c->res->body( "inner: ${\$c->stash->{inner}}, outer: ${\$c->stash->{outer}}"); + $c->req->env->{inner_var_from_catalyst} = 'station'; + is_deeply [sort {$a cmp $b} keys(%{$c->stash})], ['inner','outer'], 'both keys in stash'; } @@ -48,5 +72,6 @@ use Catalyst::Test 'MyAppParent'; my $res = request '/user/stash'; is $res->content, 'inner: inner, outer: outer', 'got expected response'; +is $MyMiddleware::INNER_VAR_EXPOSED, 'station', 'env does not get trampled'; done_testing;