Implement tests for Bump feature; tweak some tests a bit; begin initial bump feature stuff
This commit is contained in:
parent
7ac2688c32
commit
c7e2445c37
|
@ -67,7 +67,8 @@ sub startup($self) {
|
|||
->name('threads_list');
|
||||
|
||||
my $post_thread = $r->under;
|
||||
$post_thread->any([qw{GET POST}], '/post')->to('thread#create')
|
||||
$post_thread->any([qw{GET POST}], '/post')
|
||||
->to('thread#create')
|
||||
->name('post_thread');
|
||||
|
||||
my $single_thread =
|
||||
|
@ -88,6 +89,12 @@ sub startup($self) {
|
|||
$single_remark->get('/:remark_id', [remark_id => qr/[0-9]+/])
|
||||
->to('remark#by_id')
|
||||
->name('single_remark');
|
||||
|
||||
# Bump
|
||||
my $bump_thread = $r->under('/bump');
|
||||
$bump_thread->get('/:thread_id', [thread_id => qr/[0-9]+/])
|
||||
->to('bump#create')
|
||||
->name('bump_thread');
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
14
lib/PostText/Controller/Bump.pm
Normal file
14
lib/PostText/Controller/Bump.pm
Normal file
|
@ -0,0 +1,14 @@
|
|||
package PostText::Controller::Bump;
|
||||
|
||||
use Mojo::Base 'Mojolicious::Controller', -signatures;
|
||||
|
||||
sub create($self) {
|
||||
my $thread_id = $self->param('thread_id');
|
||||
|
||||
$self->thread->bump($thread_id);
|
||||
$self->flash(info => "Thread #$thread_id has been bumped.🔝");
|
||||
|
||||
$self->redirect_to('threads_list');
|
||||
}
|
||||
|
||||
1;
|
0
lib/PostText/Model/Bump.pm
Normal file
0
lib/PostText/Model/Bump.pm
Normal file
14
t/bump.t
Normal file
14
t/bump.t
Normal file
|
@ -0,0 +1,14 @@
|
|||
use Mojo::Base -strict;
|
||||
use Test::More;
|
||||
use Test::Mojo;
|
||||
|
||||
my $t = Test::Mojo->new('PostText');
|
||||
|
||||
subtest 'Bumping thread', sub {
|
||||
$t->get_ok('/list')->status_is(200)
|
||||
->element_exists('a[href~="bump"]')
|
||||
->text_like(h2 => qr/Threads List/);
|
||||
|
||||
$t->get_ok('/bump/1')->status_is(302)
|
||||
->header_like(Location => qr/list/);
|
||||
};
|
|
@ -1,5 +1,3 @@
|
|||
#!/usr/bin/env perl
|
||||
|
||||
use Mojo::Base -strict;
|
||||
use Test::More;
|
||||
use Test::Mojo;
|
||||
|
@ -19,9 +17,9 @@ subtest 'View single remark', sub {
|
|||
$t->get_ok('/remark/1')->status_is(200)->text_like(h2 => qr/Remark #1/);
|
||||
};
|
||||
|
||||
$t->ua->max_redirects(1);
|
||||
|
||||
subtest 'Post new remark', sub {
|
||||
$t->ua->max_redirects(1);
|
||||
|
||||
# GET
|
||||
$t->get_ok('/post/1')->status_is(200)
|
||||
->element_exists('form input[name="author"]' )
|
||||
|
|
2
t/root.t
2
t/root.t
|
@ -1,5 +1,3 @@
|
|||
#!/usr/bin/env perl
|
||||
|
||||
use Mojo::Base -strict;
|
||||
use Test::More;
|
||||
use Test::Mojo;
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#!/usr/bin/env perl
|
||||
|
||||
use Mojo::Base -strict;
|
||||
use Test::More;
|
||||
use Test::Mojo;
|
||||
|
@ -32,9 +30,9 @@ subtest 'View single thread', sub {
|
|||
$t->get_ok('/thread/1/1')->status_is(200)->text_like(h2 => qr/Thread #1/);
|
||||
};
|
||||
|
||||
$t->ua->max_redirects(1);
|
||||
|
||||
subtest 'Post new thread', sub {
|
||||
$t->ua->max_redirects(1);
|
||||
|
||||
# GET
|
||||
$t->get_ok('/post')->status_is(200)
|
||||
->element_exists('form input[name="author"]' )
|
||||
|
|
Loading…
Reference in a new issue