Permalink
Browse files

Merge branch 'review/gh_763' into devel

  • Loading branch information...
2 parents 16c83c8 + 7026821 commit 7385570898171e2f5ca7b81f253dca2f9d112182 @dams dams committed Mar 27, 2012
Showing with 20 additions and 3 deletions.
  1. +1 −0 CHANGES
  2. +8 −1 lib/Dancer/Plugin/Ajax.pm
  3. +11 −2 t/03_route_handler/21_ajax.t
View
@@ -1,6 +1,7 @@
{{$NEXT}}
[ BUG FIXES ]
+ * GH #763: Fix exceptions in ajax routes clobbering layout (ilmari)
* GH #748 & GH 647: Don't force override environment from PLACK_ENV (jwittkoski)
* GH #762: fix param parsing lacking limit on split (leejo)
* GH #758: Fix Dancer::Test: make sure the request is properly converted to
@@ -4,6 +4,7 @@ use strict;
use warnings;
use Dancer ':syntax';
+use Dancer::Exception ':all';
use Dancer::Plugin;
our $VERSION = '1.00';
@@ -31,7 +32,13 @@ sub ajax {
# disable layout
my $layout = setting('layout');
setting('layout' => undef);
- my $response = $code->();
+ my $response = try {
+ $code->();
+ } catch {
+ my $e = $_;
+ setting('layout' => $layout);
+ die $e;
+ };
setting('layout' => $layout);
return $response;
};
@@ -10,7 +10,7 @@ plan skip_all => 'Test::TCP is needed to run this test'
use LWP::UserAgent;
-plan tests => 32;
+plan tests => 43;
ok(Dancer::App->current->registry->is_empty,
"registry is empty");
@@ -30,6 +30,9 @@ Test::TCP::test_tcp(
{ path => 'foo', ajax => 0, success => 1, content => 'not ajax' },
{ path => 'bar', ajax => 1, success => 1, content => 'ajax' },
{ path => 'bar', ajax => 0, success => 1, content => 'not ajax' },
+ { path => 'layout', ajax => 0, success => 1, content => 'wibble' },
+ { path => 'die', ajax => 1, success => 0 },
+ { path => 'layout', ajax => 0, success => 1, content => 'wibble' },
);
foreach my $query (@queries) {
@@ -65,7 +68,7 @@ Test::TCP::test_tcp(
use Dancer;
use Dancer::Plugin::Ajax;
- set startup_info => 0, port => $port;
+ set startup_info => 0, port => $port, layout => 'wibble';
ajax '/req' => sub {
return 1;
@@ -86,6 +89,12 @@ Test::TCP::test_tcp(
content_type('application/json');
return '{"foo":"bar"}';
};
+ ajax '/die' => sub {
+ die;
+ };
+ get '/layout' => sub {
+ return setting 'layout';
+ };
start();
},
);

0 comments on commit 7385570

Please sign in to comment.