Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug with default parameters in embedded app (test) #319

Closed
alexbyk opened this issue Apr 17, 2012 · 2 comments
Closed

Bug with default parameters in embedded app (test) #319

alexbyk opened this issue Apr 17, 2012 · 2 comments

Comments

@alexbyk
Copy link

alexbyk commented Apr 17, 2012

#!/usr/bin/env perl
use Mojo::Base -strict;
use Test::More 'no_plan';
use Mojolicious;
use Test::Mojo;

sub e_app {

  # Embedded app
  my $eapp = Mojolicious->new();
  my $r    = $eapp->routes;

  # !Stash
  $r->route('/foo')->route('')->to(fe => 'beee');

  $r->route('/foo/welcome')->to(
    cb => sub {
      my $self = shift;

      # stash must be empty, because '/foo' isn't our parent
      my $fe = $self->stash('fe') || '';
      $self->render_text("hello$fe");
    }
  );
  return $eapp;
}

sub p_app {

  # Parent app with embedded on /emb
  my $app = Mojolicious->new();
  $app->routes->route('/emb')->detour(e_app());
  return $app;
}

my $EXPECT = 'hello';

# /foo/welcome route in e_app, p_app is our proxy. BAD!!!
Test::Mojo->new()->app(p_app)->get_ok("/emb/foo/welcome")
  ->content_is($EXPECT);

# /foo/welcome route in e_app directly. GOOD
Test::Mojo->new()->app(e_app)->get_ok("/foo/welcome")->content_is($EXPECT);
@alexbyk
Copy link
Author

alexbyk commented Apr 17, 2012

The main problem is when we have

$r->route('/')->to(cb => sub { ... }); 

All other routers became broken

@kraih kraih closed this as completed in be9521d Apr 18, 2012
@kraih
Copy link
Member

kraih commented Apr 18, 2012

Thanks for the clean test case, made it very easy to fix the bug. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants