Fix test; clean up the author name stuff a lil

This commit is contained in:
swagg boi 2022-09-27 13:20:30 -04:00
parent 0aea30fd1c
commit ff93fa1d2b
4 changed files with 11 additions and 11 deletions

View file

@ -43,6 +43,8 @@ sub startup($self) {
my $r = $self->routes->under(sub ($c) {
$c->session(expires => time + 31536000);
$c->session(author => 'Anonymous') unless $c->session('author');
1;
});

View file

@ -61,7 +61,7 @@ $t->post_ok('/post', form => \%invalid_title)->status_is(400)
$t->post_ok('/post', form => \%invalid_post)->status_is(400)
->text_like(p => qr/Invalid text/);
$t->post_ok('/post', form => \%valid_params)->status_is(200)
->text_like(h2 => qr/Threads List/);
->text_like(h2 => qr/Thread #[0-9]+/);
$t->post_ok('/post/1')->status_is(200)
->element_exists('form input[name="author"]' )

View file

@ -4,11 +4,10 @@
<form method="post">
<div class="author field">
<%= label_for author => 'Author' %>
<% if (my $previous_author = session->{'author'}) { =%>
<%= text_field author => $previous_author, maxlength => 63, minlength => 1 %>
<% } else { =%>
<%= text_field author => 'Anonymous', maxlength => 63, minlength => 1 %>
<% } =%>
<%= text_field author => session->{'author'}, (
maxlength => 63,
minlength => 1
) %>
<% if (my $error = validation->error('author')) { =%>
<p class="field-with-error">Invalid author: 1 to 63 characters please.</p>
<% } =%>

View file

@ -4,11 +4,10 @@
<form method="post">
<div class="author field">
<%= label_for author => 'Author' %>
<% if (my $previous_author = session->{'author'}) { =%>
<%= text_field author => $previous_author, maxlength => 63, minlength => 1 %>
<% } else { =%>
<%= text_field author => 'Anonymous', maxlength => 63, minlength => 1 %>
<% } =%>
<%= text_field author => session->{'author'}, (
maxlength => 63,
minlength => 1
) %>
<% if (my $error = validation->error('author')) { =%>
<p class="field-with-error">Invalid author: 1 to 63 characters please.</p>
<% } =%>