Skip to content

Commit

Permalink
params('query') didn't work for dancer_response
Browse files Browse the repository at this point in the history
  • Loading branch information
ambs authored and Alexis Sukrieh committed Jun 11, 2011
1 parent 19b33b0 commit 4c562de
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
13 changes: 7 additions & 6 deletions lib/Dancer/Request.pm
Expand Up @@ -126,12 +126,13 @@ sub new_for_request {
$params ||= {};
$method = uc($method);

my $req = $class->new( env => { %ENV,
PATH_INFO => $path,
REQUEST_METHOD => $method});
$req->{params} = {%{$req->{params}}, %{$params}};
$req->{body} = $body if defined $body;
$req->{headers} = $headers if $headers;
my $req = $class->new(env => { %ENV,
PATH_INFO => $path,
REQUEST_METHOD => $method});
$req->{params} = {%{$req->{params}}, %{$params}};
$req->{_query_params} = $req->{params};
$req->{body} = $body if defined $body;
$req->{headers} = $headers if $headers;

return $req;
}
Expand Down
8 changes: 7 additions & 1 deletion t/23_dancer_tests/02_tests_functions.t
Expand Up @@ -3,7 +3,7 @@ use warnings;

use Test::More;

plan tests => 27;
plan tests => 28;

use Dancer qw/ :syntax :tests /;
use Dancer::Test;
Expand Down Expand Up @@ -39,6 +39,10 @@ del '/user/:id' => sub {
{ user => $deleted };
};

get '/query' => sub {
return join(":",params('query'));
};

my $resp = dancer_response GET => '/marco';

my @req = ( [ GET => $route ], $route, $resp );
Expand Down Expand Up @@ -82,3 +86,5 @@ $r = dancer_response(
is_deeply $r->{content}, { user => { id => 2, name => "Franck Cuny" } },
"id is correctly increased";

$r = dancer_response( GET => '/query', { params => {foo => 'bar'}});
is $r->{content} => "foo:bar";

0 comments on commit 4c562de

Please sign in to comment.