[Jifty-commit] r4963 - in jifty/branches/jquery: t/TestApp-JiftyJS/lib/TestApp/JiftyJS t/TestApp-JiftyJS/lib/TestApp/JiftyJS/Action t/TestApp-JiftyJS/t

Jifty commits jifty-commit at lists.jifty.org
Wed Jan 30 05:23:44 EST 2008


Author: gugod
Date: Wed Jan 30 05:23:40 2008
New Revision: 4963

Added:
   jifty/branches/jquery/t/TestApp-JiftyJS/lib/TestApp/JiftyJS/Action/Play2.pm
   jifty/branches/jquery/t/TestApp-JiftyJS/t/00-action-Play2.t
   jifty/branches/jquery/t/TestApp-JiftyJS/t/7-redirect.t
Modified:
   jifty/branches/jquery/share/web/static/js/jifty.js
   jifty/branches/jquery/t/TestApp-JiftyJS/lib/TestApp/JiftyJS/View.pm
   jifty/branches/jquery/t/TestApp-JiftyJS/t/00-model-Offer.t

Log:
Add a test to test redirect action.



Modified: jifty/branches/jquery/share/web/static/js/jifty.js
==============================================================================
--- jifty/branches/jquery/share/web/static/js/jifty.js	(original)
+++ jifty/branches/jquery/share/web/static/js/jifty.js	Wed Jan 30 05:23:40 2008
@@ -162,9 +162,9 @@
     fields: function() {
         if(!this.cached_fields) {
             var elements = new Array;
-            var possible = jQuery(":input", this.form).get();
+            var possible = Form.getElements(this.form);
             // Also pull from extra query parameters
-            for (var i = 0; i < this.extras.length; i++)
+            for (var i = 0, l = this.extras.length; i < l; i++)
                 possible.push(this.extras[i]);
 
             for (var i = 0, l = possible.length; i < l; i++) {
@@ -218,7 +218,7 @@
     // Returns true if there is a file upload form as one of our elements
     hasUpload: function() {
         var fields = this.fields();
-        for (var i = 0; i < fields.length; i++) {
+        for (var i = 0, l = fields.length; i < l; i++) {
             if ((fields[i].getAttribute("type") == "file") && fields[i].value)
                 return true;
         }
@@ -540,7 +540,7 @@
     // Takes an element or an element id
     getMoniker: function (element) {
         element = Jifty.$(element);
-
+        
         if (/^J:A(:F)+-[^-]+-.+$/.test(element.name)) {
             var bits = element.name.match(/^J:A(?::F)+-[^-]+-(.+)$/);
             return bits[1];

Added: jifty/branches/jquery/t/TestApp-JiftyJS/lib/TestApp/JiftyJS/Action/Play2.pm
==============================================================================
--- (empty file)
+++ jifty/branches/jquery/t/TestApp-JiftyJS/lib/TestApp/JiftyJS/Action/Play2.pm	Wed Jan 30 05:23:40 2008
@@ -0,0 +1,40 @@
+use strict;
+use warnings;
+
+=head1 NAME
+
+TestApp::JiftyJS::Action::Play2
+
+=cut
+
+package TestApp::JiftyJS::Action::Play2;
+use base qw/TestApp::JiftyJS::Action Jifty::Action/;
+
+use Jifty::Param::Schema;
+use Jifty::Action schema {
+    param bogus => type is 'text';
+};
+
+=head2 take_action
+
+=cut
+
+sub take_action {
+    my $self = shift;
+    # Custom action code
+    $self->report_success if not $self->result->failure;
+    return 1;
+}
+
+=head2 report_success
+
+=cut
+
+sub report_success {
+    my $self = shift;
+    # Your success message here
+    $self->result->message('Success');
+}
+
+1;
+

Modified: jifty/branches/jquery/t/TestApp-JiftyJS/lib/TestApp/JiftyJS/View.pm
==============================================================================
--- jifty/branches/jquery/t/TestApp-JiftyJS/lib/TestApp/JiftyJS/View.pm	(original)
+++ jifty/branches/jquery/t/TestApp-JiftyJS/lib/TestApp/JiftyJS/View.pm	Wed Jan 30 05:23:40 2008
@@ -217,5 +217,17 @@
     render_region( name => 'content', path => "hello_world" );
 };
 
+template '/act/play2' => page {
+    my $action = new_action(class => 'Play2');
+    form {
+        render_action($action);
+        form_next_page( url => "/redirected");
+        form_submit( label => "Submit" );
+    };
+};
+
+template '/redirected' => page {
+    p { "Redirected!" }
+};
 
 1;

Added: jifty/branches/jquery/t/TestApp-JiftyJS/t/00-action-Play2.t
==============================================================================
--- (empty file)
+++ jifty/branches/jquery/t/TestApp-JiftyJS/t/00-action-Play2.t	Wed Jan 30 05:23:40 2008
@@ -0,0 +1,15 @@
+#!/usr/bin/env perl
+use warnings;
+use strict;
+
+=head1 DESCRIPTION
+
+A (very) basic test harness for the Play2 action.
+
+=cut
+
+use Jifty::Test tests => 1;
+
+# Make sure we can load the action
+use_ok('TestApp::JiftyJS::Action::Play2');
+

Modified: jifty/branches/jquery/t/TestApp-JiftyJS/t/00-model-Offer.t
==============================================================================
--- jifty/branches/jquery/t/TestApp-JiftyJS/t/00-model-Offer.t	(original)
+++ jifty/branches/jquery/t/TestApp-JiftyJS/t/00-model-Offer.t	Wed Jan 30 05:23:40 2008
@@ -8,6 +8,8 @@
 
 =cut
 
+use lib 't/lib';
+use Jifty::SubTest;
 use Jifty::Test tests => 11;
 
 # Make sure we can load the model

Added: jifty/branches/jquery/t/TestApp-JiftyJS/t/7-redirect.t
==============================================================================
--- (empty file)
+++ jifty/branches/jquery/t/TestApp-JiftyJS/t/7-redirect.t	Wed Jan 30 05:23:40 2008
@@ -0,0 +1,50 @@
+# This test is for testing Jifty.update() javascript function.
+
+use strict;
+use warnings;
+use lib 't/lib';
+use Jifty::SubTest;
+use Jifty::Test;;
+use Jifty::Test::WWW::Selenium;
+use utf8;
+
+$/ = undef;
+
+my $data = <DATA>;
+$data =~ s/^#.*$//gm;
+
+my @commands = split /\n\n+/, $data;
+
+plan tests => 2+ at commands;
+
+my $server = Jifty::Test->make_server;
+my $sel    = Jifty::Test::WWW::Selenium->rc_ok($server);
+my $URL    = $server->started_ok;
+
+for (@commands) {
+    my ($cmd, $arg1, $arg2) = (split(/\n\s*/, $_, 3), "", "");
+    $cmd =~ s{^ *}{}g;
+    $cmd =~ s{ *$}{}g;
+    $arg1 =~ s{\s*$}{};
+    $arg2 =~ s{\s*$}{};
+
+    $cmd .= "_ok";
+    $sel->$cmd($arg1, $arg2);
+
+}
+$sel->stop;
+
+__DATA__
+open
+    /act/play2
+
+type
+    xpath=//input[@type='text']
+    Not A Job Offer
+
+click
+    xpath=//input[@type='submit']
+
+wait_for_text_present
+    Redirected!
+


More information about the Jifty-commit mailing list