New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expose_stash() warning message edits #4

Merged
merged 3 commits into from Nov 25, 2015
Jump to file or symbol
Failed to load files and symbols.
+28 −1
Diff settings

Always

Just for now

Viewing a subset of changes. View all
Prev

add a test for displaying expose_stash warning msg

  • Loading branch information...
andyjack committed Jan 29, 2015
commit 31e5f1b56f4a34417221732495a6a3a7747f20f4
Copy path View file
@@ -9,7 +9,7 @@ use Test::More;
use Catalyst::Test 'TestApp';
use JSON::MaybeXS 1.003000 ':legacy';
plan tests => 40;
plan tests => 47;
BEGIN {
no warnings 'redefine';
@@ -154,4 +154,16 @@ my $entrypoint = "http://localhost/foo";
is $data->{foo}, "fake";
}
{
my $request = HTTP::Request->new( GET => "http://localhost/warnmsg" );
ok( my $response = request($request), 'Request' );
ok( $response->is_success, 'Response Successful 2xx' );
is( $response->code, 200, 'Response Code' );
is_deeply( [ $response->content_type ], [ 'application/json', 'charset=utf-8' ] );
my $data = from_json($response->content);
is $data->{json_foo}, "bar";
is_deeply $data->{json_baz}, [ 1, 2, 3 ];
is $data->{'foo'}, 'barbarbar';
}
@@ -18,6 +18,21 @@ sub foo : Global {
$c->forward('View::JSON');
}
sub warnmsg : Global {
my ( $self, $c ) = @_;
# case where setting expose_stash returns everything in
# the stash. Set a true value to enter to code path
# that shows the warning message.
$c->component('View::JSON')->expose_stash(\1);
$c->stash->{json_foo} = "bar";
$c->stash->{json_baz} = [ 1, 2, 3 ];
$c->stash->{foo} = "barbarbar";
$c->forward('View::JSON');
}
sub foo2 : Global {
my( $self, $c ) = @_;
ProTip! Use n and p to navigate between commits in a pull request.