CatalystX-Resource
view release on metacpan or search on metacpan
t/07_sortable.t view on Meta::CPAN
#!/usr/bin/env perl
use FindBin qw/$Bin/;
use lib "$Bin/lib";
use CatalystX::Resource::TestKit;
use Test::Exception;
use HTTP::Request::Common;
use URI;
use Catalyst::Test qw/TestApp/;
my ($res, $c) = ctx_request('/');
my $schema = $c->model('DB')->schema;
ok(defined $schema, 'got a schema');
lives_ok(sub { $schema->deploy }, 'deploy schema');
# populate DB
my $artist;
lives_ok(
sub {
$artist = $schema->resultset('Resource::Artist')->create(
{ id => 1,
name => 'davewood',
password => 'asdf',
}
);
},
'create artist davewood'
);
lives_ok(
sub {
$schema->resultset('Resource::Artist')->create(
{ id => 2,
name => 'flipper',
password => 'asdf'
}
);
},
'create artist flipper'
);
my $album;
lives_ok(sub { $album = $artist->albums->create({ id => 1, name => 'Mach et einfach!' }); }, 'create album');
lives_ok(sub { $album->songs->create({ id => 1, name => 'smack my bitch up' }); }, 'create song 1');
lives_ok(sub { $album->songs->create({ id => 2, name => 'hit me baby one more time' }); }, 'create song 2');
lives_ok(sub { $album->songs->create({ id => 3, name => "drop it like it's hot" }); }, 'create song 3');
lives_ok(sub { $album->artworks->create({ id => 1, name => 'album coverfrontside' }); }, 'create artwork 1');
lives_ok(sub { $album->artworks->create({ id => 2, name => 'album coverbackside' }); }, 'create artwork 2');
lives_ok(sub { $album->artworks->create({ id => 3, name => "bonus pictures" }); }, 'create artwork 3');
lives_ok(sub { $album->lyrics->create({ id => 1, name => "lyric1" }); }, 'create lyric1');
lives_ok(sub { $album->lyrics->create({ id => 2, name => "lyric2" }); }, 'create lyric2');
lives_ok(sub { $album->lyrics->create({ id => 3, name => "lyric3" }); }, 'create lyric3');
# move_next
{
my $path ='/artists/1/move_next';
my $res = request($path);
ok($res->is_error, "GET $path returns HTTP 404");
$res = request(POST $path, Referer => '/artists/list');
ok($res->is_redirect, "POST $path returns HTTP 302");
my $uri = URI->new($res->header('location'));
is($uri->path, '/artists/list', 'redirect location is correct');
my $cookie = $res->header('Set-Cookie');
( run in 0.997 second using v1.01-cache-2.11-cpan-39bf76dae61 )