More tests
This commit is contained in:
parent
e4aad2ccbd
commit
d7c0f715d2
|
@ -49,6 +49,5 @@ Add the `-v` option for more verbose output
|
||||||
|
|
||||||
## TODOs
|
## TODOs
|
||||||
|
|
||||||
1. More tests
|
|
||||||
1. /spam route would be interesting
|
1. /spam route would be interesting
|
||||||
1. Include the total number of visitors or messages
|
1. Include the total number of visitors or messages
|
||||||
|
|
|
@ -46,8 +46,7 @@ under sub ($c) {
|
||||||
|
|
||||||
$c->session(expiration => 604800);
|
$c->session(expiration => 604800);
|
||||||
|
|
||||||
$c->stash(status => 403)
|
$c->stash(status => 403) if $c->flash('error');
|
||||||
if $c->flash('error') eq 'This message was flagged as spam';
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
};
|
};
|
||||||
|
|
|
@ -15,9 +15,11 @@ my %form = (
|
||||||
answer => 'false'
|
answer => 'false'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$t->ua->max_redirects(1);
|
||||||
|
|
||||||
$t->get_ok('/')->status_is(200)
|
$t->get_ok('/')->status_is(200)
|
||||||
->text_is(h2 => 'Messages from the World Wide Web');
|
->text_is(h2 => 'Messages from the World Wide Web');
|
||||||
$t->get_ok('/sign')->status_is(200)->text_is(h2 => 'Sign the Guestbook');
|
$t->get_ok('/sign')->status_is(200)->text_is(h2 => 'Sign the Guestbook');
|
||||||
$t->post_ok('/sign', form => \%form)->status_is(302);
|
$t->post_ok('/sign', form => \%form)->status_is(200);
|
||||||
|
|
||||||
done_testing();
|
done_testing();
|
||||||
|
|
35
t/validation.t
Normal file
35
t/validation.t
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
#!/usr/bin/env perl
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use Test::More;
|
||||||
|
use Mojo::File qw{curfile};
|
||||||
|
use Test::Mojo;
|
||||||
|
|
||||||
|
my $script = curfile->dirname->sibling('guestbook-ng.pl');
|
||||||
|
my $t = Test::Mojo->new($script);
|
||||||
|
my %invalid_form = (
|
||||||
|
name => 'swagg boi',
|
||||||
|
url => 'INVALID://',
|
||||||
|
message => '',
|
||||||
|
answer => 'false'
|
||||||
|
);
|
||||||
|
my %spam_form = (
|
||||||
|
name => 'swagg boi',
|
||||||
|
url => 'http://localhost/',
|
||||||
|
message => 'hi',
|
||||||
|
answer => 0
|
||||||
|
);
|
||||||
|
|
||||||
|
$t->ua->max_redirects(1);
|
||||||
|
|
||||||
|
# Invalid input
|
||||||
|
$t->post_ok('/sign', form => \%invalid_form)->status_is(200)
|
||||||
|
->content_like(qr/cannot be blank/);
|
||||||
|
$t->post_ok('/sign', form => \%invalid_form)->status_is(200)
|
||||||
|
->content_like(qr/URL does not appear to be/);
|
||||||
|
|
||||||
|
# Spam test
|
||||||
|
$t->post_ok('/sign', form => \%spam_form)->status_is(403);
|
||||||
|
|
||||||
|
done_testing();
|
Loading…
Reference in a new issue