diff options
author | Edmund von der Burg <evdb@mysociety.org> | 2011-04-07 15:41:59 +0100 |
---|---|---|
committer | Edmund von der Burg <evdb@mysociety.org> | 2011-04-07 15:44:01 +0100 |
commit | d0059b5b46bf16d5adbeddffc412699a8c815725 (patch) | |
tree | ea82bb7a7652e2bc8ab37058b7dee95fba19f064 /t/app/controller/auth.t | |
parent | a932cf24e53109204e304ba68263d55326bee78f (diff) |
Add the 'remember_me' checkbox on login
Diffstat (limited to 't/app/controller/auth.t')
-rw-r--r-- | t/app/controller/auth.t | 44 |
1 files changed, 27 insertions, 17 deletions
diff --git a/t/app/controller/auth.t b/t/app/controller/auth.t index 6e1e8d58d..78d3a5abf 100644 --- a/t/app/controller/auth.t +++ b/t/app/controller/auth.t @@ -1,7 +1,7 @@ use strict; use warnings; -use Test::More tests => 97; +use Test::More tests => 94; use FixMyStreet::TestMech; my $mech = FixMyStreet::TestMech->new; @@ -178,23 +178,33 @@ $mech->not_logged_in_ok; ok $user->password, "user now has a password"; } -# login using valid details -$mech->get_ok('/auth'); -$mech->submit_form_ok( - { - form_name => 'general_auth', - fields => { - email => $test_email, - password => $test_password, - }, - button => 'login', - }, - "login with '$test_email' & '$test_password" -); -is $mech->uri->path, '/my', "redirected to correct page"; +foreach my $remember_me ( '1', '0' ) { + subtest "login using valid details (remember_me => '$remember_me')" => sub { + $mech->get_ok('/auth'); + $mech->submit_form_ok( + { + form_name => 'general_auth', + fields => { + email => $test_email, + password => $test_password, + remember_me => ( $remember_me ? 1 : undef ), + }, + button => 'login', + }, + "login with '$test_email' & '$test_password" + ); + is $mech->uri->path, '/my', "redirected to correct page"; -# logout -$mech->log_out_ok; + # check that the cookie has no expiry set + my $expiry = $mech->session_cookie_expiry; + $remember_me + ? cmp_ok( $expiry, '>', 86400, "long expiry time" ) + : is( $expiry, 0, "no expiry time" ); + + # logout + $mech->log_out_ok; + }; +} # try to login with bad details $mech->get_ok('/auth'); |