Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 48 lines (36 sloc) 1.322 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
use Modern::Perl;
use Test::More;
use Test::Mojo;
use Schema;
use Test::Database;

my $schema = Test::Database->new->create(Schema => 'test.db');

my $t = Test::Mojo->new('MojoFull');
$t->app->schema($schema);

# Photo not found
$t->get_ok('/photos/bad_title')->status_is(302);

# Photoset not found
$t->get_ok('/photos/12345678912345678')->status_is(302);

# All sets
$t->get_ok('/photos')->status_is(200)
  ->element_exists('div#photosets[class*="thumbnails"]')
  ->content_like(qr/\d+\s+photos in\s+\d+\s+albums/i);

ok my $set_id =
  $t->tx->res->dom('div#photosets > div.photo')->[0]->attrs('id'),
  'set id';
ok my $set_url =
  $t->tx->res->dom('div#photosets > div.photo > a')->[0]->attrs('href'),
  'set url';
ok my $set_title =
  $t->tx->res->dom('div#photosets > div.photo > a div.title')->[0]->text,
  'set title';

is length $set_id => 17;

# Show set
$t->get_ok($set_url)->status_is(200)->text_is(h1 => $set_title);
$t->get_ok("/photos/$set_id")->status_is(200)->text_is(h1 => $set_title);
$t->get_ok("/photos/$set_title")->status_is(200)->text_is(h1 => $set_title);

ok my $photo_url =
  $t->tx->res->dom('div.photoset a.slide')->[0]->attrs('href'), 'photo url';
like $photo_url => qr|^/photos/\d+$|;

# Photo
$t->get_ok($photo_url)->status_is(200)->text_like('h1 a.title' => qr/$set_title/);

done_testing;
Something went wrong with that request. Please try again.