Skip to content

Commit

Permalink
test tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Aug 29, 2013
1 parent db56c8a commit 166d36a
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 66 deletions.
14 changes: 2 additions & 12 deletions t/mojolicious/app.t
Expand Up @@ -45,8 +45,8 @@ is $t->app->routes->find('something')->to_string, '/test4/:something',
'right pattern';
is $t->app->routes->find('test3')->pattern->defaults->{namespace},
'MojoliciousTestController', 'right namespace';
is $t->app->routes->find('authenticated')->pattern->defaults->{controller},
'foo', 'right controller';
is $t->app->routes->find('withblock')->pattern->defaults->{controller}, 'foo',
'right controller';
is ref $t->app->routes->find('something'), 'Mojolicious::Routes::Route',
'right class';
is ref $t->app->routes->find('something')->root, 'Mojolicious::Routes',
Expand Down Expand Up @@ -224,16 +224,6 @@ $t->get_ok('/happy/fun/time' => {'X-Test' => 'Hi there!'})->status_is(200)
->header_is('X-Bender' => undef)->header_is(Server => 'Mojolicious (Perl)')
->content_is('Have fun!');

# Foo::authenticated (authentication bridge)
$t->get_ok('/auth/authenticated' => {'X-Bender' => 'Hi there!'})
->status_is(200)->header_is('X-Bender' => undef)
->header_is(Server => 'Mojolicious (Perl)')->content_is('authenticated');

# Foo::authenticated (authentication bridge)
$t->get_ok('/auth/authenticated')->status_is(401)
->header_is('X-Bender' => undef)->header_is(Server => 'Mojolicious (Perl)')
->content_is('Unauthorized!');

# Foo::test
$t->get_ok('/foo/test' => {'X-Test' => 'Hi there!'})->status_is(200)
->header_is('X-Bender' => 'Bite my shiny metal ass!')
Expand Down
37 changes: 2 additions & 35 deletions t/mojolicious/group_lite_app.t
Expand Up @@ -103,30 +103,11 @@ get '/late/session' => sub {
my $under;
under sub {
shift->res->headers->header('X-Under' => ++$under);
1;
!!1;
};

get '/with/under/count';

# Everything gets past this
under sub {
shift->res->headers->header('X-Possible' => 1);
1;
};

get '/possible' => 'possible';

# Nothing gets past this
under sub {
my $self = shift;
$self->res->headers->header('X-Impossible' => 1);
$self->res->code(401);
$self->tx->resume;
0;
};

get '/impossible' => {text => 'Impossible!'};

# Prefix
under '/prefix';

Expand Down Expand Up @@ -173,7 +154,7 @@ group {
my $self = shift;
return 1 if $self->req->param('ok');
$self->render(text => "You're not ok.");
return undef;
return !!0;
};

get '/authgroup' => {text => "You're ok."};
Expand Down Expand Up @@ -337,17 +318,6 @@ $t->get_ok('/bridge2stash' => {'X-Flash2' => 1})->status_is(200)
->content_is(
"stash too!cookie!signed_cookie!!bad_cookie--12345678!session!!\n");

# Reachable route
$t->get_ok('/possible')->status_is(200)
->header_is(Server => 'Mojolicious (Perl)')->header_is('X-Possible' => 1)
->header_is('X-Impossible' => undef)->content_is("Possible!\n");

# Unreachable route
$t->get_ok('/impossible')->status_is(401)
->header_is(Server => 'Mojolicious (Perl)')
->header_is('X-Possible' => undef)->header_is('X-Impossible' => 1)
->content_is('');

# Prefix
$t->get_ok('/prefix')->status_is(200)
->header_is(Server => 'Mojolicious (Perl)')
Expand Down Expand Up @@ -470,6 +440,3 @@ Not Bender!
@@ withundercount.html.ep
counter
@@ possible.html.ep
Possible!
12 changes: 0 additions & 12 deletions t/mojolicious/lib/MojoliciousTest.pm
Expand Up @@ -78,18 +78,6 @@ sub startup {
# /happy/fun/time
$r->route('/happy')->fun('/time')->to('foo#fun');

# /auth (authentication bridge)
my $auth = $r->bridge('/auth')->to(
cb => sub {
my $self = shift;
return 1 if $self->req->headers->header('X-Bender');
$self->render(text => 'Unauthorized!', status => 401) and return undef;
}
);

# /auth/authenticated
$auth->route('/authenticated')->to('foo#authenticated');

# /stash_config
$r->route('/stash_config')
->to(controller => 'foo', action => 'config', config => {test => 123});
Expand Down
5 changes: 0 additions & 5 deletions t/mojolicious/lib/MojoliciousTest/Foo.pm
@@ -1,11 +1,6 @@
package MojoliciousTest::Foo;
use Mojo::Base 'Mojolicious::Controller';

sub authenticated {
my $self = shift;
$self->render(text => $self->stash('action'));
}

sub config {
my $self = shift;
$self->render(text => $self->stash('config')->{test});
Expand Down
4 changes: 2 additions & 2 deletions t/mojolicious/production_app.t
Expand Up @@ -20,8 +20,8 @@ is $t->app->routes->find('something')->to_string, '/test4/:something',
'right pattern';
is $t->app->routes->find('test3')->pattern->defaults->{namespace},
'MojoliciousTestController', 'right namespace';
is $t->app->routes->find('authenticated')->pattern->defaults->{controller},
'foo', 'right controller';
is $t->app->routes->find('withblock')->pattern->defaults->{controller}, 'foo',
'right controller';
is ref $t->app->routes->find('something'), 'Mojolicious::Routes::Route',
'right class';
is ref $t->app->routes->find('something')->root, 'Mojolicious::Routes',
Expand Down

0 comments on commit 166d36a

Please sign in to comment.