Fix test; clean up the author name stuff a lil
This commit is contained in:
parent
0aea30fd1c
commit
ff93fa1d2b
|
@ -43,6 +43,8 @@ sub startup($self) {
|
||||||
my $r = $self->routes->under(sub ($c) {
|
my $r = $self->routes->under(sub ($c) {
|
||||||
$c->session(expires => time + 31536000);
|
$c->session(expires => time + 31536000);
|
||||||
|
|
||||||
|
$c->session(author => 'Anonymous') unless $c->session('author');
|
||||||
|
|
||||||
1;
|
1;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
2
t/post.t
2
t/post.t
|
@ -61,7 +61,7 @@ $t->post_ok('/post', form => \%invalid_title)->status_is(400)
|
||||||
$t->post_ok('/post', form => \%invalid_post)->status_is(400)
|
$t->post_ok('/post', form => \%invalid_post)->status_is(400)
|
||||||
->text_like(p => qr/Invalid text/);
|
->text_like(p => qr/Invalid text/);
|
||||||
$t->post_ok('/post', form => \%valid_params)->status_is(200)
|
$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)
|
$t->post_ok('/post/1')->status_is(200)
|
||||||
->element_exists('form input[name="author"]' )
|
->element_exists('form input[name="author"]' )
|
||||||
|
|
|
@ -4,11 +4,10 @@
|
||||||
<form method="post">
|
<form method="post">
|
||||||
<div class="author field">
|
<div class="author field">
|
||||||
<%= label_for author => 'Author' %>
|
<%= label_for author => 'Author' %>
|
||||||
<% if (my $previous_author = session->{'author'}) { =%>
|
<%= text_field author => session->{'author'}, (
|
||||||
<%= text_field author => $previous_author, maxlength => 63, minlength => 1 %>
|
maxlength => 63,
|
||||||
<% } else { =%>
|
minlength => 1
|
||||||
<%= text_field author => 'Anonymous', maxlength => 63, minlength => 1 %>
|
) %>
|
||||||
<% } =%>
|
|
||||||
<% if (my $error = validation->error('author')) { =%>
|
<% if (my $error = validation->error('author')) { =%>
|
||||||
<p class="field-with-error">Invalid author: 1 to 63 characters please.</p>
|
<p class="field-with-error">Invalid author: 1 to 63 characters please.</p>
|
||||||
<% } =%>
|
<% } =%>
|
||||||
|
|
|
@ -4,11 +4,10 @@
|
||||||
<form method="post">
|
<form method="post">
|
||||||
<div class="author field">
|
<div class="author field">
|
||||||
<%= label_for author => 'Author' %>
|
<%= label_for author => 'Author' %>
|
||||||
<% if (my $previous_author = session->{'author'}) { =%>
|
<%= text_field author => session->{'author'}, (
|
||||||
<%= text_field author => $previous_author, maxlength => 63, minlength => 1 %>
|
maxlength => 63,
|
||||||
<% } else { =%>
|
minlength => 1
|
||||||
<%= text_field author => 'Anonymous', maxlength => 63, minlength => 1 %>
|
) %>
|
||||||
<% } =%>
|
|
||||||
<% if (my $error = validation->error('author')) { =%>
|
<% if (my $error = validation->error('author')) { =%>
|
||||||
<p class="field-with-error">Invalid author: 1 to 63 characters please.</p>
|
<p class="field-with-error">Invalid author: 1 to 63 characters please.</p>
|
||||||
<% } =%>
|
<% } =%>
|
||||||
|
|
Loading…
Reference in a new issue