diff --git a/lib/PostText.pm b/lib/PostText.pm index f710829..12b7c99 100644 --- a/lib/PostText.pm +++ b/lib/PostText.pm @@ -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) diff --git a/t/post.t b/t/post.t index 6e7b1c5..34f90ac 100644 --- a/t/post.t +++ b/t/post.t @@ -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(); diff --git a/templates/post.html.ep b/templates/post.html.ep index f94ba0e..0c48b5e 100644 --- a/templates/post.html.ep +++ b/templates/post.html.ep @@ -21,15 +21,15 @@ <% } =%>
- <%= 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')) { =%> -

Invalid post: Up to 4,000 characters only.

+ <% if (my $error = validation->error('body')) { =%> +

Invalid text: Up to 4,000 characters only.

<% } =%>
<%= submit_button 'Post', class => 'post button' %> diff --git a/templates/thread_id.html.ep b/templates/thread_id.html.ep index d593ac3..12939e5 100644 --- a/templates/thread_id.html.ep +++ b/templates/thread_id.html.ep @@ -14,15 +14,15 @@ <% } =%>
- <%= 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')) { =%> -

Invalid post: Up to 4,000 characters only.

+ <% if (my $error = validation->error('body')) { =%> +

Invalid text: Up to 4,000 characters only.

<% } =%>
<%= submit_button 'Post', class => 'post button' %>