[Jifty-commit] r1282 - in jifty: .
trunk/t/Continuations/lib/Continuations trunk/t/Continuations/t
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Wed Jun 14 11:07:09 EDT 2006
Author: nelhage
Date: Wed Jun 14 11:06:55 2006
New Revision: 1282
Modified:
jifty/ (props changed)
jifty/trunk/t/Continuations/lib/Continuations/Dispatcher.pm
jifty/trunk/t/Continuations/share/web/templates/index-help.html
jifty/trunk/t/Continuations/share/web/templates/index.html
jifty/trunk/t/Continuations/t/04-before-blocks.t
Log:
r12616 at phanatique: nelhage | 2006-06-14 11:03:09 -0400
Adding actual tests for the continuations/dispatcher interaction issue
Modified: jifty/trunk/t/Continuations/lib/Continuations/Dispatcher.pm
==============================================================================
--- jifty/trunk/t/Continuations/lib/Continuations/Dispatcher.pm (original)
+++ jifty/trunk/t/Continuations/lib/Continuations/Dispatcher.pm Wed Jun 14 11:06:55 2006
@@ -2,12 +2,15 @@
use Jifty::Dispatcher -base;
-before '/help' => run {
- Jifty->web->tangent(url => '/index-help.html');
+before '/tutorial' => run {
+ unless (Jifty->web->session->get('got_help')) {
+ Jifty->web->tangent(url => '/index-help.html');
+ }
+ set been_helped => 1;
}
-before '/index-help.html' => run {
- set 'getting_help' => 1;
+on '/tutorial' => run {
+ show '/index.html';
}
on '*' => show;
Modified: jifty/trunk/t/Continuations/share/web/templates/index-help.html
==============================================================================
--- jifty/trunk/t/Continuations/share/web/templates/index-help.html (original)
+++ jifty/trunk/t/Continuations/share/web/templates/index-help.html Wed Jun 14 11:06:55 2006
@@ -1,8 +1,2 @@
-<%args>
-$getting_help => undef
-</%args>
Help about the index. <% Jifty->web->return(label => "Done") %>
<% Jifty->web->tangent(label => "Get help", url => "/help-help.html") %>
-% if($getting_help) {
-<p>You're getting help!</p>
-% }
Modified: jifty/trunk/t/Continuations/share/web/templates/index.html
==============================================================================
--- jifty/trunk/t/Continuations/share/web/templates/index.html (original)
+++ jifty/trunk/t/Continuations/share/web/templates/index.html Wed Jun 14 11:06:55 2006
@@ -1,3 +1,7 @@
+<%args>
+$been_helped => 0
+</%args>
+
<% Jifty->web->form->start %>
% my $action = Jifty->web->form->add_action( class => 'GetGrail', moniker => 'grail');
@@ -8,3 +12,7 @@
<% Jifty->web->tangent(label => "Help as button", url => "/index-help.html", submit => $action) %>
<% Jifty->web->form->end %>
+
+% if($been_helped) {
+<p>Congratulations on being helped.</p>
+% }
Modified: jifty/trunk/t/Continuations/t/04-before-blocks.t
==============================================================================
--- jifty/trunk/t/Continuations/t/04-before-blocks.t (original)
+++ jifty/trunk/t/Continuations/t/04-before-blocks.t Wed Jun 14 11:06:55 2006
@@ -5,7 +5,8 @@
=head1 DESCRIPTION
-This is a template for your own tests. Copy it and modify it.
+Test the interactions between continuations and dispatcher BEFORE
+blocks
=cut
@@ -19,9 +20,14 @@
my $URL = $server->started_ok;
my $mech = Jifty::Test::WWW::Mechanize->new;
-$mech->get($URL . '/help');
-like($mech->uri, qr'index-help\.html', '/help redirected to /index-help.html');
-$mech->content_contains('getting help', 'before blocks got run properly');
+$mech->get($URL . '/tutorial');
+like($mech->uri, qr'index-help\.html', '/tutorial redirected to /index-help.html');
+$mech->follow_link_ok(text => 'Done');
+like($mech->uri, qr'/tutorial', 'Continuation call worked properly');
+$mech->content_contains('Congratulations', 'before blocks got run properly on continuation call');
+
+$mech->get($URL . '/tutorial');
+$mech->content_contains('Congratulations', 'before blocks got run properly');
1;
More information about the Jifty-commit
mailing list