Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 48 lines (36 sloc) 1.307 kB
ea8805d @tempire removed 5.14 requirement (Modern::Perl +2012), added SQL::Translator …
authored
1 use Modern::Perl;
b1107bf @tempire initial commit
authored
2 use Test::More;
3 use Test::Mojo;
4 use Schema;
5 use Test::Database;
6
68fe8fa @tempire cleaner
authored
7 my $schema = Test::Database->new->create(Schema => 'test.db');
ac8fb54 @tempire test db connection set through attribute (worked in Mojolicious >=3.0…
authored
8
9 my $t = Test::Mojo->new('MojoFull');
10 $t->app->schema($schema);
b1107bf @tempire initial commit
authored
11
12 # Photo not found
13 $t->get_ok('/photos/bad_title')->status_is(302);
14
15 # Photoset not found
16 $t->get_ok('/photos/12345678912345678')->status_is(302);
17
18 # All sets
19 $t->get_ok('/photos')->status_is(200)
20 ->element_exists('div#photosets[class*="thumbnails"]')
21 ->content_like(qr/\d+\s+photos in\s+\d+\s+albums/i);
22
23 ok my $set_id =
6f9f795 @jberger fixed use of attrs in photos.t
jberger authored
24 $t->tx->res->dom('div#photosets > div.photo')->[0]->{'id'},
b1107bf @tempire initial commit
authored
25 'set id';
26 ok my $set_url =
6f9f795 @jberger fixed use of attrs in photos.t
jberger authored
27 $t->tx->res->dom('div#photosets > div.photo > a')->[0]->{'href'},
b1107bf @tempire initial commit
authored
28 'set url';
29 ok my $set_title =
30 $t->tx->res->dom('div#photosets > div.photo > a div.title')->[0]->text,
31 'set title';
32
33 is length $set_id => 17;
34
35 # Show set
36 $t->get_ok($set_url)->status_is(200)->text_is(h1 => $set_title);
37 $t->get_ok("/photos/$set_id")->status_is(200)->text_is(h1 => $set_title);
38 $t->get_ok("/photos/$set_title")->status_is(200)->text_is(h1 => $set_title);
39
40 ok my $photo_url =
6f9f795 @jberger fixed use of attrs in photos.t
jberger authored
41 $t->tx->res->dom('div.photoset a.slide')->[0]->{'href'}, 'photo url';
b1107bf @tempire initial commit
authored
42 like $photo_url => qr|^/photos/\d+$|;
43
44 # Photo
45 $t->get_ok($photo_url)->status_is(200)->text_like('h1 a.title' => qr/$set_title/);
46
47 done_testing;
Something went wrong with that request. Please try again.