[Jifty-commit] r1138 - in jifty/trunk/t/TestApp: t
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Fri Jun 2 05:37:33 EDT 2006
Author: seanmil
Date: Fri Jun 2 05:37:27 2006
New Revision: 1138
Added:
jifty/trunk/t/TestApp/share/web/templates/editform
jifty/trunk/t/TestApp/t/05-editactions-Cachable.pm
jifty/trunk/t/TestApp/t/05-editactions-Record.pm
jifty/trunk/t/TestApp/t/config-Cachable
jifty/trunk/t/TestApp/t/config-Record
Log:
* Add tests for a simple form update using both Jifty::DBI::Record and
Jifty::DBI::Record::Cachable
Added: jifty/trunk/t/TestApp/share/web/templates/editform
==============================================================================
--- (empty file)
+++ jifty/trunk/t/TestApp/share/web/templates/editform Fri Jun 2 05:37:27 2006
@@ -0,0 +1,18 @@
+<%init>
+my $superuser = TestApp::CurrentUser->superuser;
+my $user = TestApp::Model::User->new( current_user => $superuser );
+$user->load('1');
+my $action = Jifty->web->new_action(
+ class => 'UpdateUser',
+ moniker => 'updateuser',
+ record => $user,
+);
+</%init>
+<&| /_elements/wrapper, title => "Test of simple form for editing" &>
+ Basic test of a simple form for editing.
+<% Jifty->web->form->start() %>
+<% $action->form_field('name') %>
+<% $action->form_field('email') %>
+<% Jifty->web->form->submit %>
+<% Jifty->web->form->end %>
+</&>
Added: jifty/trunk/t/TestApp/t/05-editactions-Cachable.pm
==============================================================================
--- (empty file)
+++ jifty/trunk/t/TestApp/t/05-editactions-Cachable.pm Fri Jun 2 05:37:27 2006
@@ -0,0 +1,43 @@
+#!/usr/bin/perl
+
+use warnings;
+use strict;
+
+BEGIN {
+chdir "t/TestApp";
+$ENV{'JIFTY_CONFIG'} = 't/config-Cachable';
+}
+use lib '../../lib';
+use Jifty::Test tests => 8;
+use Jifty::Test::WWW::Mechanize;
+
+# Make sure we can load the model
+use_ok('TestApp::Model::User');
+
+# Grab a system use
+my $system_user = TestApp::CurrentUser->superuser;
+ok($system_user, "Found a system user");
+
+# Create a user
+my $o = TestApp::Model::User->new(current_user => $system_user);
+my ($id) = $o->create( name => 'edituser', email => 'someone at domain.com' );
+ok($id, "User create returned success");
+
+my $server = Jifty::Test->make_server;
+
+isa_ok($server, 'Jifty::Server');
+
+my $URL = $server->started_ok;
+my $mech = Jifty::Test::WWW::Mechanize->new();
+
+# Test action to update
+$mech->get_ok("$URL/editform?J:A-updateuser=TestApp::Action::UpdateUser&J:A:F:F:F-id-updateuser=1&J:A:F-name-updateuser=edituser&J:A:F-email-updateuser=newemail", "Form submitted");
+undef $o;
+$o = TestApp::Model::User->new(current_user => $system_user);
+$o->load($id);
+ok($id, "Load returned success");
+
+is($o->email, 'newemail', "Email was updated by form");
+
+1;
+
Added: jifty/trunk/t/TestApp/t/05-editactions-Record.pm
==============================================================================
--- (empty file)
+++ jifty/trunk/t/TestApp/t/05-editactions-Record.pm Fri Jun 2 05:37:27 2006
@@ -0,0 +1,44 @@
+#!/usr/bin/perl
+
+use warnings;
+use strict;
+
+BEGIN {
+chdir "t/TestApp";
+$ENV{'JIFTY_CONFIG'} = 't/config-Record';
+}
+use lib '../../lib';
+
+use Jifty::Test tests => 8;
+use Jifty::Test::WWW::Mechanize;
+
+# Make sure we can load the model
+use_ok('TestApp::Model::User');
+
+# Grab a system use
+my $system_user = TestApp::CurrentUser->superuser;
+ok($system_user, "Found a system user");
+
+# Create a user
+my $o = TestApp::Model::User->new(current_user => $system_user);
+my ($id) = $o->create( name => 'edituser', email => 'someone at domain.com' );
+ok($id, "User create returned success");
+
+my $server = Jifty::Test->make_server;
+
+isa_ok($server, 'Jifty::Server');
+
+my $URL = $server->started_ok;
+my $mech = Jifty::Test::WWW::Mechanize->new();
+
+# Test action to update
+$mech->get_ok("$URL/editform?J:A-updateuser=TestApp::Action::UpdateUser&J:A:F:F:F-id-updateuser=1&J:A:F-name-updateuser=edituser&J:A:F-email-updateuser=newemail", "Form submitted");
+undef $o;
+my $o = TestApp::Model::User->new(current_user => $system_user);
+$o->load($id);
+ok($id, "Load returned success");
+
+is($o->email, 'newemail', "Email was updated by form");
+
+1;
+
Added: jifty/trunk/t/TestApp/t/config-Cachable
==============================================================================
--- (empty file)
+++ jifty/trunk/t/TestApp/t/config-Cachable Fri Jun 2 05:37:27 2006
@@ -0,0 +1,4 @@
+---
+framework:
+ Database:
+ RecordBaseClass: Jifty::DBI::Record::Cachable
Added: jifty/trunk/t/TestApp/t/config-Record
==============================================================================
--- (empty file)
+++ jifty/trunk/t/TestApp/t/config-Record Fri Jun 2 05:37:27 2006
@@ -0,0 +1,4 @@
+---
+framework:
+ Database:
+ RecordBaseClass: Jifty::DBI::Record
More information about the Jifty-commit
mailing list