Skip to content

Commit

Permalink
render_steps does not behave differently based on context anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Jun 30, 2014
1 parent bedb49f commit cc4b447
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 25 deletions.
8 changes: 2 additions & 6 deletions lib/Mojolicious/Controller.pm
Expand Up @@ -189,15 +189,11 @@ sub render_static {
sub render_steps {
my $self = shift;

$self->render_later->stash->{'mojo.steps'}++;
my $delay = Mojo::IOLoop->delay(@_);
my $tx = $self->tx;
my $tx = $self->render_later->tx;
$delay->on(
finish => sub {
--$self->stash->{'mojo.steps'}
or $self->res->code
or $self->render_maybe
or $self->render_not_found;
$self->res->code or $self->render_maybe or $self->render_not_found;
undef $tx;
}
);
Expand Down
26 changes: 7 additions & 19 deletions t/mojolicious/steps_lite_app.t
Expand Up @@ -10,14 +10,9 @@ use Mojolicious::Lite;
use Test::Mojo;

helper steps => sub {
my ($c, $cb) = @_;
$c->render_steps(
sub { Mojo::IOLoop->next_tick(shift->begin) },
sub {
$c->stash(text => 'helper', steps => 'action');
Mojo::IOLoop->next_tick($cb);
}
);
my $c = shift;
$c->render_steps(sub { Mojo::IOLoop->next_tick(shift->begin) },
sub { $c->stash(text => 'helper') });
};

get '/steps' => sub {
Expand All @@ -29,14 +24,7 @@ get '/steps' => sub {
);
};

get '/nested' => sub {
my $c = shift;
$c->render_steps(
sub { Mojo::IOLoop->next_tick(shift->begin) },
sub { $c->steps(shift->begin) },
sub { $c->stash(text => $c->stash('steps')) }
);
};
get '/helper' => sub { shift->steps };

my $early;
get '/early' => sub {
Expand Down Expand Up @@ -73,7 +61,7 @@ my $t = Test::Mojo->new;

# Event loop is automatically started
my $c = app->build_controller;
$c->steps(sub { });
$c->steps;
is $c->res->body, 'helper', 'right content';

# Three steps with manual rendering
Expand All @@ -83,8 +71,8 @@ $t->get_ok('/steps')->status_is(200)->content_is('three steps');
$t->get_ok('/steps?auto=1')->status_is(200)
->content_is("three steps (template)\n");

# Nested steps
$t->get_ok('/nested')->status_is(200)->content_is('action');
# Steps in helper
$t->get_ok('/helper')->status_is(200)->content_is('helper');

# Transaction is available after rendering early
$t->get_ok('/early')->status_is(200)->content_is('second');
Expand Down

0 comments on commit cc4b447

Please sign in to comment.