Tests for Moderator
This commit is contained in:
parent
82dae0cf89
commit
9f51c4dad9
|
@ -33,7 +33,6 @@ Run the tests locally (against development environment):
|
|||
## TODOs
|
||||
|
||||
1. Actions for creating moderators and resetting passwords
|
||||
1. Tests for Moderator
|
||||
1. CSS
|
||||
|
||||
## Crazy future ideas
|
||||
|
|
|
@ -26,10 +26,10 @@ sub login($self) {
|
|||
$email = $self->param('email' );
|
||||
$password = $self->param('password');
|
||||
|
||||
if ($self->moderator->check($email, $password)) {
|
||||
$mod_id = $self->moderator->get_id($email);
|
||||
$mod_name = $self->moderator->get_name($mod_id);
|
||||
|
||||
if ($self->moderator->check($email, $password)) {
|
||||
$self->session(mod_id => $mod_id);
|
||||
$self->flash(info => "Hello, $mod_name 😎");
|
||||
|
||||
|
|
29
t/moderator.t
Normal file
29
t/moderator.t
Normal file
|
@ -0,0 +1,29 @@
|
|||
use Mojo::Base -strict;
|
||||
use Test::More;
|
||||
use Test::Mojo;
|
||||
|
||||
my $t = Test::Mojo->new('PostText');
|
||||
|
||||
my %valid_login = (
|
||||
email => 'swaggboi@slackware.uk',
|
||||
password => 'i like to party'
|
||||
);
|
||||
|
||||
my %invalid_login = (
|
||||
email => 'fuck@example.com',
|
||||
password => 'ah fuck'
|
||||
);
|
||||
|
||||
subtest Login => sub {
|
||||
$t->post_ok('/login', form => \%invalid_login)->status_is(403);
|
||||
|
||||
$t->post_ok('/login', form => \%valid_login)
|
||||
->status_is(302)
|
||||
->header_like(Location => qr{moderator/list});
|
||||
|
||||
$t->get_ok('/logout')
|
||||
->status_is(302)
|
||||
->header_like(Location => qr{thread/list});
|
||||
};
|
||||
|
||||
done_testing();
|
Loading…
Reference in New Issue
Block a user