parent
04c970f13f
commit
4a95a107c5
1
lib/PostText/Controller/.#Thread.pm
Symbolic link
1
lib/PostText/Controller/.#Thread.pm
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
daniel@graymember.5691
|
|
@ -65,7 +65,6 @@ sub create($self) {
|
||||||
|
|
||||||
sub flag($self) {
|
sub flag($self) {
|
||||||
my $remark_id = $self->param('remark_id');
|
my $remark_id = $self->param('remark_id');
|
||||||
my $valid_id = $self->remark->by_id($remark_id) ? 1 : 0;
|
|
||||||
my $v = $self->validation;
|
my $v = $self->validation;
|
||||||
|
|
||||||
$v->optional(captcha => 'trim')->size(4, 4)->like(qr/flag/i);
|
$v->optional(captcha => 'trim')->size(4, 4)->like(qr/flag/i);
|
||||||
|
@ -87,11 +86,6 @@ sub flag($self) {
|
||||||
$self->stash(status => 400)
|
$self->stash(status => 400)
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->stash(status => 404, error => 'Remark not found 🤷')
|
|
||||||
unless $valid_id;
|
|
||||||
|
|
||||||
$self->stash(valid_id => $valid_id);
|
|
||||||
|
|
||||||
return $self->render;
|
return $self->render;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -140,7 +140,6 @@ sub feed($self) {
|
||||||
|
|
||||||
sub bump($self) {
|
sub bump($self) {
|
||||||
my $thread_id = $self->param('thread_id');
|
my $thread_id = $self->param('thread_id');
|
||||||
my $valid_id = $self->thread->by_id($thread_id) ? 1 : 0;
|
|
||||||
my $v = $self->validation;
|
my $v = $self->validation;
|
||||||
|
|
||||||
$v->optional(captcha => 'trim')->size(4, 4)->like(qr/bump/i);
|
$v->optional(captcha => 'trim')->size(4, 4)->like(qr/bump/i);
|
||||||
|
@ -158,17 +157,11 @@ sub bump($self) {
|
||||||
$self->stash(status => 400)
|
$self->stash(status => 400)
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->stash(status => 404, error => 'Thread not found 🤷')
|
|
||||||
unless $valid_id;
|
|
||||||
|
|
||||||
$self->stash(valid_id => $valid_id);
|
|
||||||
|
|
||||||
return $self->render;
|
return $self->render;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub flag($self) {
|
sub flag($self) {
|
||||||
my $thread_id = $self->param('thread_id');
|
my $thread_id = $self->param('thread_id');
|
||||||
my $valid_id = $self->thread->by_id($thread_id) ? 1 : 0;
|
|
||||||
my $v = $self->validation;
|
my $v = $self->validation;
|
||||||
|
|
||||||
$v->optional(captcha => 'trim')->size(4, 4)->like(qr/flag/i);
|
$v->optional(captcha => 'trim')->size(4, 4)->like(qr/flag/i);
|
||||||
|
@ -188,10 +181,7 @@ sub flag($self) {
|
||||||
$self->stash(status => 400)
|
$self->stash(status => 400)
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->stash(status => 404, error => 'Thread not found 🤷')
|
$self->stash(thread_id => $thread_id);
|
||||||
unless $valid_id;
|
|
||||||
|
|
||||||
$self->stash(valid_id => $valid_id);
|
|
||||||
|
|
||||||
return $self->render;
|
return $self->render;
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,8 +49,7 @@ subtest 'Flagging remark', sub {
|
||||||
->text_like(h2 => qr/Remark #1/);
|
->text_like(h2 => qr/Remark #1/);
|
||||||
|
|
||||||
$t->get_ok('/remark/flag/1' )->status_is(200);
|
$t->get_ok('/remark/flag/1' )->status_is(200);
|
||||||
$t->get_ok('/remark/flag/65536')->status_is(404)
|
$t->get_ok('/remark/flag/65536')->status_is(404);
|
||||||
->text_like(p => qr/Remark not found/);
|
|
||||||
$t->get_ok('/remark/flag/1', form => {captcha => 'flag'})->status_is(200);
|
$t->get_ok('/remark/flag/1', form => {captcha => 'flag'})->status_is(200);
|
||||||
$t->get_ok('/remark/flag/1', form => {captcha => 'aaaa'})->status_is(400);
|
$t->get_ok('/remark/flag/1', form => {captcha => 'aaaa'})->status_is(400);
|
||||||
};
|
};
|
||||||
|
|
10
t/thread.t
10
t/thread.t
|
@ -84,9 +84,12 @@ subtest 'Bumping thread', sub {
|
||||||
->element_exists('a[href*="bump"]')
|
->element_exists('a[href*="bump"]')
|
||||||
->text_like(h2 => qr/Thread #1/);
|
->text_like(h2 => qr/Thread #1/);
|
||||||
|
|
||||||
|
$t->get_ok('/thread/bump/1')->status_is(200)
|
||||||
|
->element_exists('p[class="stash-with-info"]')
|
||||||
|
->text_like(p => qr/Thread #1 has been bumped/);
|
||||||
|
|
||||||
$t->get_ok('/thread/bump/1' )->status_is(200);
|
$t->get_ok('/thread/bump/1' )->status_is(200);
|
||||||
$t->get_ok('/thread/bump/65536')->status_is(404)
|
$t->get_ok('/thread/bump/65536')->status_is(404);
|
||||||
->text_like(p => qr/Thread not found/);
|
|
||||||
$t->get_ok('/thread/bump/1', form => {captcha => 'bump'})->status_is(200);
|
$t->get_ok('/thread/bump/1', form => {captcha => 'bump'})->status_is(200);
|
||||||
$t->get_ok('/thread/bump/1', form => {captcha => 'aaaa'})->status_is(400);
|
$t->get_ok('/thread/bump/1', form => {captcha => 'aaaa'})->status_is(400);
|
||||||
};
|
};
|
||||||
|
@ -101,8 +104,7 @@ subtest 'Flagging thread', sub {
|
||||||
->text_like(h2 => qr/Thread #1/);
|
->text_like(h2 => qr/Thread #1/);
|
||||||
|
|
||||||
$t->get_ok('/thread/flag/1' )->status_is(200);
|
$t->get_ok('/thread/flag/1' )->status_is(200);
|
||||||
$t->get_ok('/thread/flag/65536')->status_is(404)
|
$t->get_ok('/thread/flag/65536')->status_is(404);
|
||||||
->text_like(p => qr/Thread not found/);
|
|
||||||
$t->get_ok('/thread/flag/1', form => {captcha => 'flag'})->status_is(200);
|
$t->get_ok('/thread/flag/1', form => {captcha => 'flag'})->status_is(200);
|
||||||
$t->get_ok('/thread/flag/1', form => {captcha => 'aaaa'})->status_is(400);
|
$t->get_ok('/thread/flag/1', form => {captcha => 'aaaa'})->status_is(400);
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
% layout 'default';
|
% layout 'default';
|
||||||
% title $valid_id ? "Flag Remark #$remark_id" : '?';
|
% title $remark_id ? "Flag Remark #$remark_id" : '?';
|
||||||
<h2 class="page-title"><%= title %></h2>
|
<h2 class="page-title"><%= title %></h2>
|
||||||
<% if ($valid_id) { =%>
|
<% if ($remark_id) { =%>
|
||||||
<form class="form-body">
|
<form class="form-body">
|
||||||
<div class="form-field">
|
<div class="form-field">
|
||||||
<% if (my $error = validation->error('captcha')) { =%>
|
<% if (my $error = validation->error('captcha')) { =%>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
% layout 'default';
|
% layout 'default';
|
||||||
% title $valid_id ? "Bump Thread #$thread_id" : '?';
|
% title $thread_id ? "Bump Thread #$thread_id" : '?';
|
||||||
<h2 class="page-title"><%= title %></h2>
|
<h2 class="page-title"><%= title %></h2>
|
||||||
<% if ($valid_id) { =%>
|
<% if ($thread_id) { =%>
|
||||||
<form class="form-body">
|
<form class="form-body">
|
||||||
<div class="form-field">
|
<div class="form-field">
|
||||||
<% if (my $error = validation->error('captcha')) { =%>
|
<% if (my $error = validation->error('captcha')) { =%>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
% layout 'default';
|
% layout 'default';
|
||||||
% title $valid_id ? "Flag Thread #$thread_id" : '?';
|
% title $thread_id ? "Flag Thread #$thread_id" : '?';
|
||||||
<h2 class="page-title"><%= title %></h2>
|
<h2 class="page-title"><%= title %></h2>
|
||||||
<% if ($valid_id) { =%>
|
<% if ($thread_id) { =%>
|
||||||
<form class="form-body">
|
<form class="form-body">
|
||||||
<div class="form-field">
|
<div class="form-field">
|
||||||
<% if (my $error = validation->error('captcha')) { =%>
|
<% if (my $error = validation->error('captcha')) { =%>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user