From 18515197df754d0153570d01e21f6b31298e19d9 Mon Sep 17 00:00:00 2001 From: swag Date: Sat, 17 Sep 2022 02:39:49 -0400 Subject: [PATCH] s/name/author/g --- README.md | 1 - lib/PostText.pm | 24 ++++++++++++------------ t/post.t | 10 +++++----- 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 6b14773..8aa996d 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,6 @@ Run the tests locally (against development environment) ## TODOs -1. Should replace all reference to 'name' to 'author', getting confused 1. Grow into full blown Mojo? 1. More granular tests 1. Document post_text.conf (whoopsie) diff --git a/lib/PostText.pm b/lib/PostText.pm index 60b3d22..f710829 100644 --- a/lib/PostText.pm +++ b/lib/PostText.pm @@ -76,13 +76,13 @@ sub startup($self) { $v = $c->validation if $c->req->method eq 'POST'; if ($v && $v->has_data) { - my $thread_author = $c->param('name' ); - my $thread_title = $c->param('title'); - my $thread_body = $c->param('post' ); + my $thread_author = $c->param('author'); + my $thread_title = $c->param('title' ); + my $thread_body = $c->param('post' ); - $v->required('name' )->size(1, 63 ); - $v->required('title')->size(1, 127 ); - $v->required('post' )->size(2, 4000); + $v->required('author')->size(1, 63 ); + $v->required('title' )->size(1, 127 ); + $v->required('post' )->size(2, 4000); if ($v->has_error) { $c->stash(status => 400) @@ -109,11 +109,11 @@ sub startup($self) { $v = $c->validation if $c->req->method eq 'POST'; if ($v && $v->has_data) { - my $remark_name = $c->param('name'); - my $remark_body = $c->param('post'); + my $remark_author = $c->param('author'); + my $remark_body = $c->param('post' ); - $v->required('name')->size(1, 63 ); - $v->required('post')->size(2, 4000); + $v->required('author')->size(1, 63 ); + $v->required('post' )->size(2, 4000); if ($v->has_error) { $c->stash(status => 400) @@ -121,11 +121,11 @@ sub startup($self) { else { $c->remark->create( $thread_id, - $remark_name, + $remark_author, $remark_body ); - $c->session(author => $remark_name); + $c->session(author => $remark_author); return $c->redirect_to( 'thread_page', diff --git a/t/post.t b/t/post.t index e376fd8..a33b890 100644 --- a/t/post.t +++ b/t/post.t @@ -9,26 +9,26 @@ use Test::Mojo; my $script = curfile->dirname->sibling('PostText.pl'); my $t = Test::Mojo->new($script); my %valid_params = ( - name => 'Anonymous', + author => 'Anonymous', title => 'hi', post => 'ayy... lmao' ); my %invalid_title = ( - name => 'Anonymous', + author => 'Anonymous', title => '', post => 'ayy... lmao' ); my %invalid_post = ( - name => 'Anonymous', + author => 'Anonymous', title => 'hi', post => 'a' ); my %valid_remark = ( - name => 'Anonymous', + author => 'Anonymous', post => 'hi' ); my %invalid_remark = ( - name => 'Anonymous', + author => 'Anonymous', post => 'a' );