[Yapcom checkin] rev 62 - lib/YAPC t

[prev] [thread] [next] [lurker] [Date index for 2003/11/26]

From: svn
Subject: [Yapcom checkin] rev 62 - lib/YAPC t
Date: 15:35 on 26 Nov 2003
Author: jon
Date: 2003-11-26 15:35:25 +0200 (Wed, 26 Nov 2003)
New Revision: 62

Modified:
   lib/YAPC/Person.pm
   t/03-web-adduser.t
Log:
can now register, disregarding all bad fields

Modified: lib/YAPC/Person.pm
===================================================================
--- lib/YAPC/Person.pm	2003-11-26 12:49:20 UTC (rev 61)
+++ lib/YAPC/Person.pm	2003-11-26 13:35:25 UTC (rev 62)
@@ -8,17 +8,12 @@
 __PACKAGE__->set_sql(total => qq{SELECT COUNT(*) total FROM people});
 __PACKAGE__->set_sql(validated => qq{SELECT COUNT(*) validated FROM people WHERE acked=1});
 
-
-
-
-
-
 sub new {
     my $self = shift;
     my %arg = @_;        
-    delete $arg{run};    # was added for CGI::Application  
-    delete $arg{submit};    # was added for CGI::Application  
-    delete $arg{submitbtn};    # was added for CGI::Application  
+#    delete $arg{run};    # was added for CGI::Application  
+#    delete $arg{submit};    # was added for CGI::Application  
+#    delete $arg{submitbtn};    # was added for CGI::Application  
 
     croak("acked should not be defined\n") if defined $arg{acked};
     croak("authcode should not be defined\n") if defined $arg{authcode};
@@ -28,6 +23,8 @@
     croak("No lname provided\n") if not $arg{lname};
     croak("No phone provided\n") if not $arg{phone};
 
+    my @valid_args = qw(fname lname phone email password company pauseid url mongers bio);
+
     if (not defined $arg{email}  or
         $arg{email} !~ /^[\w\d+=@.-]{5,}$/ or
         $arg{email} !~ /@/) {
@@ -36,8 +33,10 @@
     }
     if ($arg{password} and $arg{password2} and 
         $arg{password} eq  $arg{password2}) {
-       delete $arg{password2};
-       __PACKAGE__->create(\%arg);  # could be $self->   also
+#       delete $arg{password2};
+       my %passed_args;
+       @passed_args{@valid_args}= @arg{@valid_args};
+       __PACKAGE__->create(\%passed_args);  # could be $self->   also
     } else {
        croak("Bad password pair given\n");
     }

Modified: t/03-web-adduser.t
===================================================================
--- t/03-web-adduser.t	2003-11-26 12:49:20 UTC (rev 61)
+++ t/03-web-adduser.t	2003-11-26 13:35:25 UTC (rev 62)
@@ -72,7 +72,6 @@
    like($result, qr@<h2>Registration Form</h2>@, 'no error message');
 }
 
-
 ##### register a user
 {
    local $ENV{REQUEST_URI}   = '/registration.html';
@@ -96,8 +95,7 @@
 }
 
 
-################ try to register with some data missing
-# supply not-existing field
+# try to register with not-existing field
 {
    local $ENV{REQUEST_URI}   = '/registration.html';
    my %user = %user1;
@@ -109,7 +107,7 @@
    my $webapp = YAPC::Organizer->new;
    $webapp->query($q);
    my $result = $webapp->run();
-   like($result, qr/There was an error in the provided data/, 'User registered');
+   like($result, qr@Location: http://test-host/validation.html@, 'User registered with extra fields, page redirected');
 }
 
 

Generated at 16:06 on 26 Nov 2003 by mariachi 0.51