Did test and routing fixes and dependency fix
This commit is contained in:
parent
2acee95d86
commit
a4ce60407e
12 changed files with 116 additions and 116 deletions
|
@ -1,29 +1,12 @@
|
|||
use strict;
|
||||
use warnings;
|
||||
use Mojo::Base -strict;
|
||||
|
||||
use FindBin qw/ $Bin /;
|
||||
use lib "$Bin/../../lib";
|
||||
|
||||
use File::Temp;
|
||||
use Test::More;
|
||||
use Test::Mojo;
|
||||
use DateTime;
|
||||
my $file = File::Temp->new;
|
||||
use Mojo::JSON;
|
||||
use Test::Pear::LocalLoop;
|
||||
|
||||
print $file <<'END';
|
||||
{
|
||||
dsn => "dbi:SQLite::memory:",
|
||||
user => undef,
|
||||
pass => undef,
|
||||
}
|
||||
END
|
||||
$file->seek( 0, SEEK_END );
|
||||
|
||||
$ENV{MOJO_CONFIG} = $file->filename;
|
||||
|
||||
my $t = Test::Mojo->new('Pear::LocalLoop');
|
||||
my $framework = Test::Pear::LocalLoop->new;
|
||||
my $t = $framework->framework;
|
||||
my $schema = $t->app->schema;
|
||||
$schema->deploy;
|
||||
|
||||
$schema->resultset('User')->create({
|
||||
email => 'admin@example.com',
|
||||
|
@ -47,46 +30,42 @@ my $location_is = sub {
|
|||
};
|
||||
|
||||
$t->get_ok('/admin')
|
||||
->status_is(302)
|
||||
->$location_is('/');
|
||||
->status_is(200)->or($framework->dump_error);
|
||||
|
||||
$t->ua->max_redirects(10);
|
||||
$t->post_ok('/', form => {
|
||||
$t->post_ok('/admin', form => {
|
||||
email => 'user@example.com',
|
||||
password => 'abc123',
|
||||
})->status_is(200);
|
||||
|
||||
$t->ua->max_redirects(0);
|
||||
$t->get_ok('/admin')
|
||||
->status_is(302)
|
||||
->$location_is('/home');
|
||||
->status_is(200);
|
||||
|
||||
$t->get_ok('/logout')
|
||||
$t->get_ok('/admin/logout')
|
||||
->status_is(302)
|
||||
->$location_is('/');
|
||||
->$location_is('/admin');
|
||||
|
||||
$t->get_ok('/admin')
|
||||
->status_is(302)
|
||||
->$location_is('/', 'Logged out');
|
||||
->status_is(200);
|
||||
|
||||
$t->ua->max_redirects(10);
|
||||
$t->post_ok('/', form => {
|
||||
$t->post_ok('/admin', form => {
|
||||
email => 'admin@example.com',
|
||||
password => 'abc123',
|
||||
})->status_is(200);
|
||||
|
||||
$t->ua->max_redirects(0);
|
||||
$t->get_ok('/admin')
|
||||
$t->get_ok('/admin/home')
|
||||
->status_is(200)
|
||||
->content_like(qr/Admin/);
|
||||
|
||||
$t->get_ok('/logout')
|
||||
$t->get_ok('/admin/logout')
|
||||
->status_is(302)
|
||||
->$location_is('/');
|
||||
->$location_is('/admin');
|
||||
|
||||
$t->get_ok('/admin')
|
||||
->status_is(302)
|
||||
->$location_is('/', 'Logged out');
|
||||
->status_is(200);
|
||||
|
||||
done_testing;
|
||||
|
||||
|
|
|
@ -10,6 +10,6 @@ BEGIN {
|
|||
}
|
||||
|
||||
my $t = Test::Mojo->new("Pear::LocalLoop");
|
||||
$t->get_ok('/')->status_is(200)->content_like(qr/login/i);
|
||||
$t->get_ok('/')->status_is(200);
|
||||
|
||||
done_testing();
|
||||
|
|
|
@ -38,7 +38,7 @@ my $testJson = {
|
|||
'age_range' => 1
|
||||
};
|
||||
$t->post_ok('/api/register' => json => $testJson)
|
||||
->status_is(200)->or($dump_error)
|
||||
->status_is(200)->or($framework->dump_error)
|
||||
->json_is('/success', Mojo::JSON->true);
|
||||
|
||||
#test with an organisation.
|
||||
|
|
Reference in a new issue