[Yapcom checkin] rev 66 - t templates

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

From: svn
Subject: [Yapcom checkin] rev 66 - t templates
Date: 16:43 on 26 Nov 2003
Author: gabor
Date: 2003-11-26 16:43:21 +0200 (Wed, 26 Nov 2003)
New Revision: 66

Added:
   t/13-change-proposal.t
   templates/list_my_proposals.tmpl
Log:
user can list the titles of his own talks

Added: t/13-change-proposal.t
===================================================================
--- t/13-change-proposal.t	2003-11-26 14:42:51 UTC (rev 65)
+++ t/13-change-proposal.t	2003-11-26 14:43:21 UTC (rev 66)
@@ -0,0 +1,171 @@
+#!/usr/bin/perl 
+# -T
+
+# Testing how can a user change  a proposal
+# using the web interface
+
+
+use strict;
+use warnings;
+use Test::More qw(no_plan);
+use lib qw(lib);
+use lib qw(t/lib);
+use YAPC::Test 'init_db';
+use YAPC::Test::Data;
+
+use YAPC::Person;
+use CGI; # needed for some of the tests
+
+$ENV{CGI_APP_RETURN_ONLY} = 1; # to eliminate screen output
+
+# to avoid warning caused my lack of web server in the test environment
+$ENV{HTTP_HOST}     = 'test-host';
+# $ENV{REQUEST_URI}   = 'test-uri';   #should be set for each request as we are using it
+$ENV{YAPCOM_NOMAIL} = 1;
+$ENV{REQUEST_URI}   = '/';
+
+BEGIN { use_ok( 'YAPC::Organizer' ); }
+
+###### prepare the environment: create and validate users and make them login
+my @cookies;
+
+YAPC::Test::Data::register_user(0);
+YAPC::Test::Data::register_user(1);
+push @cookies, YAPC::Test::Data::login_user(0);
+push @cookies, YAPC::Test::Data::login_user(0);
+push @cookies, YAPC::Test::Data::login_user(1);
+isnt($cookies[0], $cookies[1], 'cookies are different');
+isnt($cookies[0], $cookies[2], 'cookies are different');
+isnt($cookies[1], $cookies[2], 'cookies are different');
+YAPC::Test::Data::submit_talk(0, $cookies[0]);
+
+
+
+# access the change personal_info page fails if not authenticated
+{
+   local $ENV{REQUEST_URI}   = '/list_my_proposals.html';
+   #local $ENV{HTTP_COOKIE} = "Yapcom=$cookies[0]";
+   my $q = CGI->new();
+   my $webapp = YAPC::Organizer->new;
+   $webapp->query($q);
+   my $result = $webapp->run();
+   like($result, qr@<h2>Login</h2>@, 'Redirected to login page');
+}
+
+
+# list proposals
+{
+   local $ENV{REQUEST_URI}   = '/list_my_proposals.html';
+   local $ENV{HTTP_COOKIE} = "Yapcom=$cookies[0]";
+   my $q = CGI->new();
+   my $webapp = YAPC::Organizer->new;
+   $webapp->query($q);
+   my $result = $webapp->run();
+   like($result, qr@<h2>My Proposals</h2>@, 'proposals listed');
+   like($result, qr@\Q<a href="edit_my_proposal.html?id=1">$talks[0]{subject}</a>@, '1st proposal listed');
+
+}
+ 
+
+
+
+__END__
+
+=pod
+# update personal_information fails if not authenticated
+{
+   local $ENV{REQUEST_URI}   = '/personal_info.html';
+   #local $ENV{HTTP_COOKIE} = "Yapcom=$cookies[0]";
+   my $q = CGI->new();
+   my $webapp = YAPC::Organizer->new;
+   $webapp->query($q);
+   my $result = $webapp->run();
+   like($result, qr@<h2>Login</h2>@, 'Redirected to login page');
+   like($result, qr@$talks[0]{title}
+}
+=cut
+
+
+# access to personl_info page is successful when authenticated
+{
+   local $ENV{REQUEST_URI}   = '/personal_info.html';
+   local $ENV{HTTP_COOKIE} = "Yapcom=$cookies[0]";
+   my $q = CGI->new();
+   my $webapp = YAPC::Organizer->new;
+   $webapp->query($q);
+   my $result = $webapp->run();
+   like($result, qr@<h2>Change Personal Information</h2>@, 'personal_info page accessed');
+   like($result, qr@\Q<tr><td>First Name:</td><td><input size=40 name="fname" value="$people[0]{fname}" /> *</td></tr>@, 'old fname filled in correclty');
+   like($result, qr@\Q<tr><td>Last Name:</td><td><input size=40 name="lname" value="$people[0]{lname}" /> *</td></tr>@, 'old lname filled in correclty');
+   like($result, qr@\Q<tr><td>Phone:</td><td><input  size=40 name="phone" value="$people[0]{phone}" /> *</td></tr>@, 'old phone filled in correclty');
+   like($result, qr@\Q<tr><td>Company:</td><td><input  size=40 name="company" value="" /></td></tr>@, 'old company filled in correclty');
+             # $people[0]{company}
+}
+
+
+# submit change to personl_info page when not authenticated
+# no value submitted:
+{
+   local $ENV{REQUEST_URI}   = '/personal_info.html';
+#   local $ENV{HTTP_COOKIE} = "Yapcom=$cookies[0]";
+   my $q = CGI->new({submit => 1});
+   my $webapp = YAPC::Organizer->new;
+   $webapp->query($q);
+   my $result = $webapp->run();
+   like($result, qr@<h2>Login</h2>@, 'Redirected to login page');
+}
+
+
+#   like($result, qr@<h2>Change Personal Information</h2>@, 'personal_info page accessed');
+
+# submit change to personl_info page gives error when authenticated but not enough data provided.
+{
+   local $ENV{REQUEST_URI}   = '/personal_info.html';
+   local $ENV{HTTP_COOKIE} = "Yapcom=$cookies[0]";
+   my $q = CGI->new({submit => 1});
+   my $webapp = YAPC::Organizer->new;
+   $webapp->query($q);
+   my $result = $webapp->run();
+   like($result, qr@Error@, 'Error');
+   like($result, qr@<h2>Change Personal Information</h2>@, 'personal_info page accessed');
+   like($result, qr@\Q<tr><td>First Name:</td><td><input size=40 name="fname" value="" /> *</td></tr>@, 'old fname filled in correclty');
+   like($result, qr@\Q<tr><td>Last Name:</td><td><input size=40 name="lname" value="" /> *</td></tr>@, 'old lname filled in correclty');
+   like($result, qr@\Q<tr><td>Phone:</td><td><input  size=40 name="phone" value="" /> *</td></tr>@, 'old phone filled in correclty');
+   like($result, qr@\Q<tr><td>Company:</td><td><input  size=40 name="company" value="" /></td></tr>@, 'old company filled in correclty');
+}
+{
+   local $ENV{REQUEST_URI}   = '/personal_info.html';
+   local $ENV{HTTP_COOKIE} = "Yapcom=$cookies[0]";
+   my $q = CGI->new({submit => 1, fname => $people[3]{fname}, lname => $people[3]{lname}, company=>$people[3]{company}});
+   my $webapp = YAPC::Organizer->new;
+   $webapp->query($q);
+   my $result = $webapp->run();
+   like($result, qr@Error@, 'Error');
+   like($result, qr@<h2>Change Personal Information</h2>@, 'personal_info page accessed');
+   like($result, qr@\Q<tr><td>First Name:</td><td><input size=40 name="fname" value="$people[3]{fname}" /> *</td></tr>@, 'old fname filled in correclty');
+   like($result, qr@\Q<tr><td>Last Name:</td><td><input size=40 name="lname" value="$people[3]{lname}" /> *</td></tr>@, 'old lname filled in correclty');
+   like($result, qr@\Q<tr><td>Phone:</td><td><input  size=40 name="phone" value="" /> *</td></tr>@, 'old phone filled in correclty');
+   like($result, qr@\Q<tr><td>Company:</td><td><input  size=40 name="company" value="$people[3]{company}" /></td></tr>@, 'old company filled in correclty');
+}
+
+##### submitted data gets updated in the database
+{
+   local $ENV{REQUEST_URI}   = '/personal_info.html';
+   local $ENV{HTTP_COOKIE} = "Yapcom=$cookies[0]";
+   my $q = CGI->new({submit => 1, fname => $people[3]{fname}, lname => $people[3]{lname}, phone => $people[3]{phone}, company=>$people[3]{company}});
+   my $webapp = YAPC::Organizer->new;
+   $webapp->query($q);
+   my $result = $webapp->run();
+   like($result, qr@Your personal information has been successfully updated.@, 'updated');
+
+   # check data in database
+   my ($p) = YAPC::Person->search(email => $people[0]->{email});  # we did not change the e-mail so it is still the same e-mail address 
+   is($p->get('fname'), $people[3]{fname}, 'fname was updated correctly');
+}
+
+
+
+
+
+
+


Property changes on: t/13-change-proposal.t
___________________________________________________________________
Name: svn:executable
   + *

Added: templates/list_my_proposals.tmpl
===================================================================
--- templates/list_my_proposals.tmpl	2003-11-26 14:42:51 UTC (rev 65)
+++ templates/list_my_proposals.tmpl	2003-11-26 14:43:21 UTC (rev 66)
@@ -0,0 +1,25 @@
+<TMPL_VALUE NAME="title" VALUE="My Proposals">
+<TMPL_INCLUDE NAME="header.tmpl">
+     <td valign="top">
+
+<p>
+<font color="red"><TMPL_VAR NAME="MESSAGE"></font>
+<p>
+<table>
+<TMPL_LOOP NAME=talks>
+  <tr><td><a href="edit_my_proposal.html?id=<TMPL_VAR NAME=id>"><TMPL_VAR NAME=title></a></td></tr>
+</TMPL_LOOP>
+</table>
+</form>
+
+         <br />&nbsp;<br /><br />&nbsp;<br /><br />&nbsp;<br /><br />&nbsp;<br /><br />&nbsp;<br />
+         <hr />
+
+         <p class="bottomtext">
+            Please send comments, questions etc. to
+            <a href="mailto:yapc-organizers@xxxx.xxx.xx">yapc-organizers@xxxx.xxx.xx</a>;
+         </p>
+
+      </td>
+<TMPL_INCLUDE NAME="footer.tmpl">
+

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