[Jifty-commit] r4686 - in jifty/trunk/t/TestApp-JiftyJS: lib/TestApp/JiftyJS t

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Fri Dec 14 02:38:57 EST 2007


Author: gugod
Date: Fri Dec 14 02:38:57 2007
New Revision: 4686

Added:
   jifty/trunk/t/TestApp-JiftyJS/lib/TestApp/JiftyJS/Action/AddTwoNumbers.pm
   jifty/trunk/t/TestApp-JiftyJS/t/00-action-AddTwoNumbers.t
Modified:
   jifty/trunk/t/TestApp-JiftyJS/lib/TestApp/JiftyJS/View.pm

Log:
For testing continuation, add a "AddTwoNumber" wizard like the one in
Jifty::Manual::Continuations, only it's written with TD rather then
mason template.

To manually test it, goto /c/page1 first. Type some number and hit
enter. You sholud then visit /c/page2. Type some other number and hit
enter. You should return to /c/page1 with the result of AddTwoNumber
action shown in the message box.


Added: jifty/trunk/t/TestApp-JiftyJS/lib/TestApp/JiftyJS/Action/AddTwoNumbers.pm
==============================================================================
--- (empty file)
+++ jifty/trunk/t/TestApp-JiftyJS/lib/TestApp/JiftyJS/Action/AddTwoNumbers.pm	Fri Dec 14 02:38:57 2007
@@ -0,0 +1,31 @@
+use strict;
+use warnings;
+
+=head1 NAME
+
+TestApp::JiftyJS::Action::AddTwoNumbers
+
+=cut
+
+package TestApp::JiftyJS::Action::AddTwoNumbers;
+use base qw/TestApp::JiftyJS::Action Jifty::Action/;
+
+use Jifty::Param::Schema;
+use Jifty::Action schema {
+    param first_number  => type is 'integer', render as 'Text';
+    param second_number => type is 'integer', render as 'Text';
+};
+
+=head2 take_action
+
+=cut
+
+sub take_action {
+    my $self = shift;
+    my $one = $self->argument_value("first_number");
+    my $two = $self->argument_value("second_number");
+    $self->result->message("Got " . ($one + $two));
+    return 1;
+}
+
+1;

Modified: jifty/trunk/t/TestApp-JiftyJS/lib/TestApp/JiftyJS/View.pm
==============================================================================
--- jifty/trunk/t/TestApp-JiftyJS/lib/TestApp/JiftyJS/View.pm	(original)
+++ jifty/trunk/t/TestApp-JiftyJS/lib/TestApp/JiftyJS/View.pm	Fri Dec 14 02:38:57 2007
@@ -61,4 +61,31 @@
     p { "Region Two" }
 };
 
+
+# Templtes for testing continuation. Using the example in Jifty::Manual::Continuations
+template '/c/page1' => page {
+    my $action = new_action(class => 'AddTwoNumbers');
+    form {
+        $action->form_field( 'first_number' )->render;
+        $action->form_field( 'second_number',
+                             default_value => {
+                                 request_argument => "number",
+                             }
+                         )->render;
+        tangent(
+            url => '/c/page2',
+            submit => $action,
+            label => "Enter a second number"
+        );
+    };
+};
+
+template '/c/page2' => page {
+    form {
+        label { "Second Number" };
+        outs_raw('<input type="text" name="number" />');
+        form_return( label => "Pick", as_button => 1);
+    }
+};
+##
 1;

Added: jifty/trunk/t/TestApp-JiftyJS/t/00-action-AddTwoNumbers.t
==============================================================================
--- (empty file)
+++ jifty/trunk/t/TestApp-JiftyJS/t/00-action-AddTwoNumbers.t	Fri Dec 14 02:38:57 2007
@@ -0,0 +1,15 @@
+#!/usr/bin/env perl
+use warnings;
+use strict;
+
+=head1 DESCRIPTION
+
+A (very) basic test harness for the AddTwoNumbers action.
+
+=cut
+
+use Jifty::Test tests => 1;
+
+# Make sure we can load the action
+use_ok('TestApp::JiftyJS::Action::AddTwoNumbers');
+


More information about the Jifty-commit mailing list