[Cpan-forum-commit] rev 192 - in trunk: . lib/CPAN t/mech

svn at pti.co.il svn at pti.co.il
Tue Aug 29 15:15:52 IDT 2006


Author: gabor
Date: 2006-08-29 15:15:52 +0300 (Tue, 29 Aug 2006)
New Revision: 192

Modified:
   trunk/
   trunk/lib/CPAN/Forum.pm
   trunk/t/mech/100-auth.t
Log:
more tests
more docs
enable sending e-mail to PAUSEID subscriptions



Property changes on: trunk
___________________________________________________________________
Name: svk:merge
   - 8c4c90e1-83eb-0310-96eb-e7cb62807872:/local/cpan-forum:11043
   + 8c4c90e1-83eb-0310-96eb-e7cb62807872:/local/cpan-forum:11044

Modified: trunk/lib/CPAN/Forum.pm
===================================================================
--- trunk/lib/CPAN/Forum.pm	2006-08-29 12:15:48 UTC (rev 191)
+++ trunk/lib/CPAN/Forum.pm	2006-08-29 12:15:52 UTC (rev 192)
@@ -833,12 +833,16 @@
     return $t;
 }
 
+=head2 login
 
+Show the login form and possibly some error messages.
+
+=cut
 sub login {
     my ($self, $errs) = @_;
     my $q = $self->query;
 
-    $self->log->debug("Sending cookie using sid:  " . ($self->session->id() || ""));
+    $self->log->debug("Sending cookie using sid:  " . $self->session->id());
     $self->session_cookie();
     my $t = $self->load_tmpl(
             "login.tmpl",
@@ -942,9 +946,14 @@
 }
 
 
+=head2 register
+
+Show the registration page and possibly some error messages.
+
+=cut
+
 sub register {
-    my $self = shift;
-    my $errs = shift;
+    my ($self, $errs) = @_;
     my $q = $self->query;
 
     my $t = $self->load_tmpl(
@@ -957,6 +966,12 @@
 }
 
 
+=head2 register_process
+
+Process the registration form.
+
+=cut
+
 sub register_process {
     my ($self) = @_;
     my $q = $self->query;
@@ -974,20 +989,11 @@
     if ($q->param('email') !~ /^[a-z0-9_+ at .-]+$/) {  
         return $self->register({"bad_email" => 1});
     }
-
-    #if ($q->param('fname') !~ /^[a-zA-Z]*$/) {
-    #   return $self->register({"bad_fname" => 1});
-    #}
-    #if ($q->param('lname') !~ /^[a-zA-Z]*$/) {
-    #   return $self->register({"bad_lname" => 1});
-    #}
-    
+   
     my $user = eval {
         CPAN::Forum::Users->create({
                 username => $q->param('nickname'),
                 email    => $q->param('email'),
-    #           fname    => $q->param('fname'),
-    #           lname    => $q->param('lname'),
             });
     };
     if ($@) {
@@ -1027,6 +1033,12 @@
     $self->_my_sendmail(%mail);
 }
 
+=head2 notify_admin
+
+Notify the administrator about a new registration
+
+=cut
+
 sub notify_admin {
     my ($self, $user) = @_;
 
@@ -1046,6 +1058,11 @@
     $self->_my_sendmail(%mail);
 }
 
+=head2 pwreminder
+
+Show form to ask for password reminder e-mail
+
+=cut
 sub pwreminder {
     my ($self, $errs) = @_;
     my $q = $self->query;
@@ -1061,6 +1078,12 @@
 }
 
 
+=head2 pwreminder_process
+
+Process the request to get a reminder about the password.
+
+=cut
+
 sub pwreminder_process {
     my ($self) = @_;
     my $q = $self->query;
@@ -1148,10 +1171,22 @@
 }
 
 
+=head2 new_post
+
+Showing the new post page. (Alias of C<posts()>)
+
+=cut
+
 sub new_post {
     posts(@_);
 }
 
+=head2 response_form
+
+Showing the response form. (Alias of C<posts()>)
+
+=cut
+
 sub response_form {
     posts(@_);
 }
@@ -2324,8 +2359,8 @@
     $self->_sendmail($it, $mail, \%to);
 
     # People who asked for all the posts in this PAUSEID
-    #$it = CPAN::Forum::Subscriptions_pauseid->search(allposts => 1, pauseid => $post->gid->pauseid);
-    #$self->_sendmail($it, $mail, \%to);
+    $it = CPAN::Forum::Subscriptions_pauseid->search(allposts => 1, pauseid => $post->gid->pauseid);
+    $self->_sendmail($it, $mail, \%to);
 
     if ($post->thread == $post->id) { 
         $self->log->debug("Processing messages for thread starter");
@@ -2339,8 +2374,8 @@
         $self->_sendmail($it, $mail, \%to);
 
         # People who are subscribed to the thread startes of this PAUSEID
-        #$it = CPAN::Forum::Subscriptions_pauseid->search(starters => 1, pauseid => $post->gid->pauseid);
-        #$self->_sendmail($it, $mail, \%to);
+        $it = CPAN::Forum::Subscriptions_pauseid->search(starters => 1, pauseid => $post->gid->pauseid);
+        $self->_sendmail($it, $mail, \%to);
     }
     else {
         $self->log->debug("Processing messages for followups");
@@ -2359,8 +2394,8 @@
         $it = CPAN::Forum::Subscriptions->search(followups => 1, gid => $post->gid->id);
         $self->_sendmail($it, $mail, \%to, \%uids);
         
-        #$it = CPAN::Forum::Subscriptions_pauseid->search(followups => 1, pauseid => $post->gid->pauseid);
-        #$self->_sendmail($it, $mail, \%to);
+        $it = CPAN::Forum::Subscriptions_pauseid->search(followups => 1, pauseid => $post->gid->pauseid);
+        $self->_sendmail($it, $mail, \%to);
     }
 }
 

Modified: trunk/t/mech/100-auth.t
===================================================================
--- trunk/t/mech/100-auth.t	2006-08-29 12:15:48 UTC (rev 191)
+++ trunk/t/mech/100-auth.t	2006-08-29 12:15:52 UTC (rev 192)
@@ -62,23 +62,52 @@
     }
     is($session_files[0], "/tmp/cgisess_$cookie");
 
+    # submit form without values
+    $w_admin->submit_form();
+    $w_admin->content_like(qr{Need both nickname and password.});
+
+    is($w_admin->cookie_jar->as_string, $cookie_jar);
+    #diag $w_admin->cookie_jar->as_string;
+
+    # submit form without password
     $w_admin->submit_form(
         fields => {
             nickname => $config{username},
+        },
+    );
+    $w_admin->content_like(qr{Need both nickname and password.});
+    $w_admin->content_like(qr{$config{username}});
+
+    # submit form with bad password
+    $w_admin->submit_form(
+        fields => {
+            nickname => $config{username},
+            password => 'bad_assword',
+        },
+    );
+    $w_admin->content_like(qr{Login failed.});
+    $w_admin->content_like(qr{$config{username}});
+    $w_admin->content_unlike(qr{bad_password});
+
+
+    $w_admin->submit_form(
+        fields => {
+            nickname => $config{username},
             password => $config{password},
         },
     );
     $w_admin->content_like(qr{You are logged in as.*$config{username}});
-    is($w_admin->cookie_jar->as_string, $cookie_jar);
-    #diag $w_admin->cookie_jar->as_string;
-    BEGIN { $tests += 10; }
+    BEGIN { $tests += 16; }
 }
+
+
 {
     my @session_files = glob "/tmp/cgisess_*";
     is (@session_files, 1);
     BEGIN { $tests += 1; }
 }
 
+
 {
     my $user = CPAN::Forum::Test::register_user(0);
     $w_user->get_ok($url);
@@ -249,7 +278,7 @@
     check_form($form, $input_ref2);
     # TODO: check it in the database as well....    
 
-    BEGIN { $tests += (4 + (@input_fields+3)*2) }
+    BEGIN { $tests += (4 + (@input_fields+6)*2) }
 }
 
 



More information about the Cpan-forum-commit mailing list