s/post/body/ for consistency

This commit is contained in:
swag 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) { if ($v && $v->has_data) {
my $thread_author = $c->param('author'); my $thread_author = $c->param('author');
my $thread_title = $c->param('title' ); 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('author')->size(1, 63 );
$v->required('title' )->size(1, 127 ); $v->required('title' )->size(1, 127 );
$v->required('post' )->size(2, 4000); $v->required('body' )->size(2, 4000);
if ($v->has_error) { if ($v->has_error) {
$c->stash(status => 400) $c->stash(status => 400)
@ -110,10 +110,10 @@ sub startup($self) {
if ($v && $v->has_data) { if ($v && $v->has_data) {
my $remark_author = $c->param('author'); 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('author')->size(1, 63 );
$v->required('post' )->size(2, 4000); $v->required('body' )->size(2, 4000);
if ($v->has_error) { if ($v->has_error) {
$c->stash(status => 400) $c->stash(status => 400)

View File

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

View File

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

View File

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