From: Errietta Kostala Date: Thu, 22 Jan 2015 16:01:32 +0000 (+0000) Subject: Register test X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=bf3397df6718ccece2e0aaa0bb002b3b2669ab3f;p=scpubgit%2Fstemmaweb.git Register test --- diff --git a/lib/stemmaweb/Controller/Users.pm b/lib/stemmaweb/Controller/Users.pm index 96516a7..fc4e7c7 100644 --- a/lib/stemmaweb/Controller/Users.pm +++ b/lib/stemmaweb/Controller/Users.pm @@ -83,8 +83,6 @@ form with an error message. before register => sub { my ($self, $c) = @_; - warn $c->config->{'Registration'}->{'no_recaptcha'}; - ## Puts HTML into stash in "recaptcha" key. if (!$c->config->{'Registration'}->{'no_recaptcha'}) { $c->forward('captcha_get'); diff --git a/t/05register.t b/t/05register.t index 57e5b59..37ea333 100644 --- a/t/05register.t +++ b/t/05register.t @@ -1,6 +1,11 @@ use warnings; use strict; +use FindBin; +use lib ("$FindBin::Bin/lib"); + +use stemmaweb::Test::Common; + use stemmaweb; use LWP::Protocol::PSGI; use Test::WWW::Mechanize; @@ -9,17 +14,12 @@ use Test::More; use HTML::TreeBuilder; use Data::Dumper; -use FindBin; -use lib ("$FindBin::Bin/lib"); - use stemmaweb::Test::DB; stemmaweb::Test::DB->new_db; LWP::Protocol::PSGI->register(stemmaweb->psgi_app); -use stemmaweb::Test::Common; - my $ua = Test::WWW::Mechanize->new; $ua->get_ok('http://localhost/register'); @@ -31,15 +31,38 @@ my $response = $ua->submit_form( confirm_password => 'UserPass', }); -warn $ua->content; +$ua->content_contains('You are now registered.', 'Registration worked'); + +$ua->get('/'); +$ua->content_contains('Hello! user2@example.org', 'We are logged in.'); + +$ua->get('/logout'); + +$ua->get_ok('http://localhost/login'); +$response = $ua->submit_form( + fields => { + username => 'user2@example.org', + password => 'UserPass' + }); + +$ua->content_contains('Stemmaweb - Logged in', 'Log in with new account works'); + +$ua->get('/'); +$ua->content_contains('Hello! user2@example.org', 'We are logged in with new account'); + +$ua->get('/logout'); -=cut +$ua->get_ok('http://localhost/register'); -$ua->content_contains('Stemmaweb - Logged in', 'Log in successful.'); +$response = $ua->submit_form( + fields => { + username => 'user2@example.org', + password => 'UserPass', + confirm_password => 'UserPass', + }); -my $content = $ua->get('/'); -$ua->content_contains('Hello! user@example.org', 'We are logged in.'); +$ua->content_contains('That username already exists.', 'We cannot register an already + existing username'); -=cut done_testing; diff --git a/t/lib/stemmaweb/Test/DB.pm b/t/lib/stemmaweb/Test/DB.pm index 6bad659..2094ee4 100644 --- a/t/lib/stemmaweb/Test/DB.pm +++ b/t/lib/stemmaweb/Test/DB.pm @@ -6,7 +6,7 @@ use strict; use FindBin; sub new_db { - my $DBDIR = "$FindBin::Bin/db"; + my $DBDIR = "$FindBin::Bin/../db"; my $DBNAME = 'traditions.db'; my $DBEXT = 'test';