diff --git a/guestbook-ng.pl b/guestbook-ng.pl index 14500b4..ca1a01c 100755 --- a/guestbook-ng.pl +++ b/guestbook-ng.pl @@ -6,7 +6,6 @@ use Mojolicious::Lite -signatures; use Mojo::Pg; use lib 'lib'; -use GuestbookNg::Model::Test; use GuestbookNg::Model::Message; use Data::Dumper; # Uncomment for debugging @@ -30,10 +29,6 @@ helper pg => sub { ); }; -helper test => sub { - state $test = GuestbookNg::Model::Test->new(pg => shift->pg) -}; - helper message => sub { state $message = GuestbookNg::Model::Message->new(pg => shift->pg) }; @@ -48,20 +43,7 @@ get '/' => sub ($c) { $c->render(posts => $posts); } => 'index'; -any '/test' => sub ($c) { - my $method = $c->req->method(); - my $time = $c->test->now(); - my $string = - $method eq 'POST' ? $c->test->test_model($c->param('string')) : undef; - - $c->render( - method => $method, - string => $string, - time => $time - ); -}; - -any '/post' => sub ($c) { +any '/sign' => sub ($c) { if ($c->req->method() eq 'POST') { my $name = $c->param('name'); my $message = $c->param('message'); diff --git a/lib/GuestbookNg/Model/Test.pm b/lib/GuestbookNg/Model/Test.pm deleted file mode 100644 index 8a9823a..0000000 --- a/lib/GuestbookNg/Model/Test.pm +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env perl - -package GuestbookNg::Model::Test; - -use Mojo::Base -base, -signatures; - -has 'pg'; - -sub new($class, $pg, $object) { - bless {$pg => $object} -} - -sub test_model($self, $string) { - "you've supplied: $string" -} - -sub now($self) { - $self->pg->db->query('SELECT NOW() AS now')->text() -} - -1; diff --git a/t/basic.t b/t/basic.t index 8b926f8..13e1dbe 100644 --- a/t/basic.t +++ b/t/basic.t @@ -6,10 +6,15 @@ use Test::Mojo; my $script = curfile->dirname->sibling('guestbook-ng.pl'); my $t = Test::Mojo->new($script); +my %form = ( + name => 'swagg boi', + message => 'Ayy... lmao' + ); + +$t->ua->max_redirects(10); -# Just make sure we get a 200 OK for now $t->get_ok('/')->status_is(200); -$t->get_ok('/test')->status_is(200); -$t->post_ok('/test', form => {string => 'a'})->status_is(200); +$t->get_ok('/sign')->status_is(200); +$t->post_ok('/sign', form => \%form)->status_is(200); done_testing(); diff --git a/templates/layouts/default.html.ep b/templates/layouts/default.html.ep index 0916ebb..1d8cb48 100644 --- a/templates/layouts/default.html.ep +++ b/templates/layouts/default.html.ep @@ -9,11 +9,9 @@ - + - - - +
<%= link_to Home => 'index' %><%= link_to View => 'index' %>  <%= link_to Test => 'test' %> <%= link_to Sign => 'post' %><%= link_to Sign => 'sign' %>
<%= content %> diff --git a/templates/post.html.ep b/templates/sign.html.ep similarity index 92% rename from templates/post.html.ep rename to templates/sign.html.ep index cf6032f..e6152c2 100644 --- a/templates/post.html.ep +++ b/templates/sign.html.ep @@ -1,6 +1,6 @@ % layout 'default'; % title 'New Post'; -

Create a New Post

+

Sign the Guestbook

diff --git a/templates/test.html.ep b/templates/test.html.ep deleted file mode 100644 index 770fd8c..0000000 --- a/templates/test.html.ep +++ /dev/null @@ -1,13 +0,0 @@ -% layout 'default'; -% title 'Test'; -

test page

-<% if ($method eq 'POST') { %> -

<%= $string %> at <%= $time =>

-<% } else { %> - -
-
- - -<% } %>