Skip to content

Commit

Permalink
document and test multiple conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Aug 10, 2012
1 parent c5bf2b6 commit 0d5b7a9
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 9 deletions.
4 changes: 4 additions & 0 deletions Changes
@@ -1,4 +1,8 @@

3.29 2012-08-11
- Improved documentation.
- Improved tests.

3.28 2012-08-10
- Added skip_body attribute to Mojo::Content.
- Added is_empty method to Mojo::Message::Response.
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojolicious.pm
Expand Up @@ -38,7 +38,7 @@ has static => sub { Mojolicious::Static->new };
has types => sub { Mojolicious::Types->new };

our $CODENAME = 'Rainbow';
our $VERSION = '3.28';
our $VERSION = '3.29';

# "These old doomsday devices are dangerously unstable.
# I'll rest easier not knowing where they are."
Expand Down
3 changes: 2 additions & 1 deletion lib/Mojolicious/Routes/Route.pm
Expand Up @@ -480,7 +480,8 @@ L<Mojolicious::Lite> tutorial for more argument variations.
=head2 C<over>
my $over = $r->over;
$r = $r->over(foo => qr/\w+/);
$r = $r->over(foo => 1);
$r = $r->over(foo => 1, bar => qr/\w+/);
Activate conditions for this route. Note that this automatically disables the
routing cache, since conditions are too complex for caching.
Expand Down
21 changes: 14 additions & 7 deletions t/mojolicious/lite_app.t
Expand Up @@ -9,7 +9,7 @@ BEGIN {
$ENV{MOJO_REACTOR} = 'Mojo::Reactor::Poll';
}

use Test::More tests => 707;
use Test::More tests => 710;

# "Wait you're the only friend I have...
# You really want a robot for a friend?
Expand Down Expand Up @@ -285,8 +285,10 @@ get '/foo_wildcard_too/*test' => sub {
};

# GET /with/header/condition
get '/with/header/condition' => (headers => {'X-Secret-Header' => 'bar'}) =>
'with_header_condition';
get '/with/header/condition' => (
headers => {'X-Secret-Header' => 'bar'},
headers => {'X-Another-Header' => 'baz'}
) => 'with_header_condition';

# POST /with/header/condition
post '/with/header/condition' => sub {
Expand Down Expand Up @@ -954,17 +956,22 @@ $t->get_ok('/foo_wildcard_too/123')->status_is(200)->content_is('123');
$t->get_ok('/foo_wildcard_too/')->status_is(404);

# GET /with/header/condition
$t->get_ok('/with/header/condition', {'X-Secret-Header' => 'bar'})
->status_is(200)->content_like(qr!^Test ok<base href="http://localhost!);
$t->get_ok('/with/header/condition',
{'X-Secret-Header' => 'bar', 'X-Another-Header' => 'baz'})->status_is(200)
->content_like(qr!^Test ok<base href="http://localhost!);

# GET /with/header/condition (not found)
# GET /with/header/condition (missing headers)
$t->get_ok('/with/header/condition')->status_is(404)->content_like(qr/Oops!/);

# GET /with/header/condition (missing header)
$t->get_ok('/with/header/condition', {'X-Secret-Header' => 'bar'})
->status_is(404)->content_like(qr/Oops!/);

# POST /with/header/condition
$t->post_ok('/with/header/condition', {'X-Secret-Header' => 'bar'}, 'bar')
->status_is(200)->content_is('foo bar');

# POST /with/header/condition (not found)
# POST /with/header/condition (missing header)
$t->post_ok('/with/header/condition', {}, 'bar')->status_is(404)
->content_like(qr/Oops!/);

Expand Down

0 comments on commit 0d5b7a9

Please sign in to comment.