Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fixed another small bug in param method
  • Loading branch information
kraih committed Feb 23, 2012
1 parent 0696064 commit 8e6cac4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/Mojolicious/Controller.pm
Expand Up @@ -167,8 +167,8 @@ sub param {
}

# Captured unreserved values
if (!$RESERVED{$name} && defined(my $values = $p->{$name})) {
return ref $values ? wantarray ? @$values : $$values[0] : $values;
if (!$RESERVED{$name} && defined(my $v = $p->{$name})) {
return ref $v && ref $v eq 'ARRAY' ? wantarray ? @$v : $$v[0] : $v;
}

# Upload
Expand Down
5 changes: 4 additions & 1 deletion t/mojolicious/dispatch.t
Expand Up @@ -25,8 +25,9 @@ use Mojo::Base -strict;

use utf8;

use Test::More tests => 84;
use Test::More tests => 85;

use Mojo::Upload;
use Mojolicious;
use Mojo::Transaction::HTTP;
use Mojolicious::Controller;
Expand Down Expand Up @@ -82,6 +83,8 @@ is $c->param(foo => 'too')->param('foo'), 'too', 'right value';
is $c->param(foo => qw/just works/)->param('foo'), 'just', 'right value';
is_deeply [$c->param('foo')], [qw/just works/], 'right values';
is $c->param(foo => undef)->param('foo'), undef, 'no value';
is $c->param(foo => Mojo::Upload->new(name => 'bar'))->param('foo')->name,
'bar', 'right value';

# Controller with application and routes
$c = Test::Controller->new(app => Mojolicious->new);
Expand Down

0 comments on commit 8e6cac4

Please sign in to comment.