Permalink
Browse files

Merge pull request #4 from andyjack/warning-message

expose_stash() warning message edits
  • Loading branch information...
jjn1056 committed Nov 25, 2015
2 parents ab8af05 + 31e5f1b commit 2c5af5f4c94148d5c2e08a65347a3b4839266847
Showing with 30 additions and 2 deletions.
  1. +2 −1 lib/Catalyst/View/JSON.pm
  2. +13 −1 t/01_server.t
  3. +15 −0 t/lib/TestApp/Controller/Root.pm
@@ -61,7 +61,8 @@ sub process {
} elsif (!ref($expose)) {
$single_key = $expose;
} else {
$c->log->warn("expose_stash should be an array referernce or Regexp object.");
$c->log->warn("expose_stash should be an array reference, Regexp object, or key for a single stash entry.");
$c->log->warn("Returning all stash entries");
}
}
@@ -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 ) = @_;

0 comments on commit 2c5af5f

Please sign in to comment.