[Jifty-commit] r3549 - in jifty/trunk: . lib/Jifty/Request t/Mapper/lib/Mapper/Action t/Mapper/t

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Sun Jun 24 17:19:48 EDT 2007


Author: alexmv
Date: Sun Jun 24 17:19:47 2007
New Revision: 3549

Modified:
   jifty/trunk/   (props changed)
   jifty/trunk/lib/Jifty/Request/Mapper.pm
   jifty/trunk/t/Mapper/lib/Mapper/Action/CrossBridge.pm
   jifty/trunk/t/Mapper/share/web/templates/index.html
   jifty/trunk/t/Mapper/t/02-api.t

Log:
 r19898 at zoq-fot-pik:  chmrr | 2007-06-24 17:17:51 -0400
  * Mapper edge case failure (when no 'name' was given)


Modified: jifty/trunk/lib/Jifty/Request/Mapper.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Request/Mapper.pm	(original)
+++ jifty/trunk/lib/Jifty/Request/Mapper.pm	Sun Jun 24 17:19:47 2007
@@ -87,7 +87,11 @@
             for (grep {/^(result(_of)?|argument(_to)?)$/} keys %mapping) {
                 my $action  = $mapping{$_};
                 my $moniker = ref $action ? $action->moniker : $action;
-                my $name = $mapping{name} || $key;
+                # If $key is for an argument of an action, we want to
+                # extract only the argument's name, and not just use
+                # the whole encoded J:A:F-... string.
+                my (undef, $a, undef) = Jifty::Request->parse_form_field_name($key);
+                my $name = $mapping{name} || $a || $key;
 
                 my $type = ($_ =~ /result/) ? "R" : "A";
 

Modified: jifty/trunk/t/Mapper/lib/Mapper/Action/CrossBridge.pm
==============================================================================
--- jifty/trunk/t/Mapper/lib/Mapper/Action/CrossBridge.pm	(original)
+++ jifty/trunk/t/Mapper/lib/Mapper/Action/CrossBridge.pm	Sun Jun 24 17:19:47 2007
@@ -6,6 +6,7 @@
 param name      => default is 'something';
 param 'quest';
 param colour    => valid are ("Blue, I mean greeeeeen!", "Green");
+param 'castle';
 
 };
 

Modified: jifty/trunk/t/Mapper/share/web/templates/index.html
==============================================================================
--- jifty/trunk/t/Mapper/share/web/templates/index.html	(original)
+++ jifty/trunk/t/Mapper/share/web/templates/index.html	Sun Jun 24 17:19:47 2007
@@ -11,6 +11,7 @@
 % my $grail_1  = Jifty->web->form->add_action( class => 'GetGrail', order => 1 );
 % my $bridge_1 = Jifty->web->new_action( class => 'CrossBridge',    order => 2 );
 <% $bridge_1->form_field( 'quest',  default_value => { result_of => $grail_1, name => 'castle' } ) %>
+<% $bridge_1->form_field( 'castle', default_value => { result_of => $grail_1 } ) %>
 <% $bridge_1->form_field( 'colour', default_value => 'Green' ) %>
 <% Jifty->web->form->submit( label => 'Do both') %>
 <% Jifty->web->form->end %>

Modified: jifty/trunk/t/Mapper/t/02-api.t
==============================================================================
--- jifty/trunk/t/Mapper/t/02-api.t	(original)
+++ jifty/trunk/t/Mapper/t/02-api.t	Sun Jun 24 17:19:47 2007
@@ -12,7 +12,7 @@
 use lib 't/lib';
 use Jifty::SubTest;
 
-use Jifty::Test tests => 11;
+use Jifty::Test tests => 13;
 
 use_ok('Jifty::Test::WWW::Mechanize');
 
@@ -38,6 +38,11 @@
 $mech->content_like(qr/got the grail/i, "Got the grail");
 $mech->content_like(qr/crossed the bridge/i, "And crossed the bridge");
 
+# Tests for proper generation of default "name" parameter to
+# argument_of and result_to
+$mech->content_unlike(qr/R`[^']+`J:A:F/, "Doesn't have full argument name");
+$mech->content_like(qr/J:A:F-castle-(\S+): Aaaaaargh/, "Has the right value name");
+
 # And then, the same, but via default_values on the form field
 $mech->form_number(3);
 ok($mech->click_button(value => "Do both"));


More information about the Jifty-commit mailing list