s/post/body/ for consistency

This commit is contained in:
swagg boi 2022-09-21 00:12:16 -04:00
parent bb47eb82a4
commit ad00f26824
4 changed files with 23 additions and 23 deletions

View file

@ -78,11 +78,11 @@ sub startup($self) {
if ($v && $v->has_data) {
my $thread_author = $c->param('author');
my $thread_title = $c->param('title' );
my $thread_body = $c->param('post' );
my $thread_body = $c->param('body' );
$v->required('author')->size(1, 63 );
$v->required('title' )->size(1, 127 );
$v->required('post' )->size(2, 4000);
$v->required('body' )->size(2, 4000);
if ($v->has_error) {
$c->stash(status => 400)
@ -110,10 +110,10 @@ sub startup($self) {
if ($v && $v->has_data) {
my $remark_author = $c->param('author');
my $remark_body = $c->param('post' );
my $remark_body = $c->param('body' );
$v->required('author')->size(1, 63 );
$v->required('post' )->size(2, 4000);
$v->required('body' )->size(2, 4000);
if ($v->has_error) {
$c->stash(status => 400)

View file

@ -11,25 +11,25 @@ my $t = Test::Mojo->new($script);
my %valid_params = (
author => 'Anonymous',
title => 'hi',
post => 'ayy... lmao'
body => 'ayy... lmao'
);
my %invalid_title = (
author => 'Anonymous',
title => '',
post => 'ayy... lmao'
body => 'ayy... lmao'
);
my %invalid_post = (
author => 'Anonymous',
title => 'hi',
post => 'a'
body => 'a'
);
my %valid_remark = (
author => 'Anonymous',
post => 'hi'
body => 'hi'
);
my %invalid_remark = (
author => 'Anonymous',
post => 'a'
body => 'a'
);
$t->ua->max_redirects(1);
@ -38,13 +38,13 @@ $t->ua->max_redirects(1);
$t->get_ok('/post')->status_is(200)
->element_exists('form input[name="author"]' )
->element_exists('form input[name="title"]' )
->element_exists('form textarea[name="post"]')
->element_exists('form textarea[name="body"]')
->element_exists('form input[type="submit"]' )
->text_like(h2 => qr/New Thread/);
$t->get_ok('/post/1')->status_is(200)
->element_exists('form input[name="author"]' )
->element_exists('form textarea[name="post"]')
->element_exists('form textarea[name="body"]')
->element_exists('form input[type="submit"]' )
->text_like(h2 => qr/New Remark/);
@ -52,26 +52,26 @@ $t->get_ok('/post/1')->status_is(200)
$t->post_ok('/post')->status_is(200)
->element_exists('form input[name="author"]' )
->element_exists('form input[name="title"]' )
->element_exists('form textarea[name="post"]')
->element_exists('form textarea[name="body"]')
->element_exists('form input[type="submit"]' )
->text_like(h2 => qr/New Thread/);
$t->post_ok('/post', form => \%invalid_title)->status_is(400)
->text_like(p => qr/Invalid title/);
$t->post_ok('/post', form => \%invalid_post)->status_is(400)
->text_like(p => qr/Invalid post/);
->text_like(p => qr/Invalid text/);
$t->post_ok('/post', form => \%valid_params)->status_is(200)
->text_like(h2 => qr/Threads List/);
$t->post_ok('/post/1')->status_is(200)
->element_exists('form input[name="author"]' )
->element_exists('form textarea[name="post"]')
->element_exists('form textarea[name="body"]')
->element_exists('form input[type="submit"]' )
->text_like(h2 => qr/New Remark/);
$t->post_ok('/post/1', form => \%valid_remark)->status_is(200)
->text_like(h2 => qr/Thread #1/);
$t->post_ok('/post/1', form => \%invalid_remark)->status_is(400)
->text_like(h2 => qr/New Remark/);
->text_like(p => qr/Invalid text/);
done_testing();

View file

@ -21,15 +21,15 @@
<% } =%>
</div>
<div class="text field">
<%= label_for post => 'Text' %>
<%= text_area 'post', (
<%= label_for body => 'Text' %>
<%= text_area body => (
maxlength => 4000,
minlength => 2,
required => 'true',
rows => 6
) %>
<% if (my $error = validation->error('post')) { =%>
<p class="field-with-error">Invalid post: Up to 4,000 characters only.</p>
<% if (my $error = validation->error('body')) { =%>
<p class="field-with-error">Invalid text: Up to 4,000 characters only.</p>
<% } =%>
</div>
<%= submit_button 'Post', class => 'post button' %>

View file

@ -14,15 +14,15 @@
<% } =%>
</div>
<div class="text field">
<%= label_for post => 'Text' %>
<%= text_area 'post', (
<%= label_for body => 'Text' %>
<%= text_area body => (
maxlength => 4000,
minlength => 2,
required => 'true',
rows => 6
) %>
<% if (my $error = validation->error('post')) { =%>
<p class="field-with-error">Invalid post: Up to 4,000 characters only.</p>
<% if (my $error = validation->error('body')) { =%>
<p class="field-with-error">Invalid text: Up to 4,000 characters only.</p>
<% } =%>
</div>
<%= submit_button 'Post', class => 'post button' %>