test for multiple chained attrs
Marcus Ramberg [Sun, 11 May 2008 09:08:43 +0000 (09:08 +0000)]
Changes
lib/Catalyst/DispatchType/Chained.pm
t/dead_load_multiple_chained_attributes.t [new file with mode: 0644]

diff --git a/Changes b/Changes
index c33aee5..c67dc21 100644 (file)
--- a/Changes
+++ b/Changes
@@ -10,7 +10,8 @@
         - Fix grammar on welcome page (RT #33236)
         - Fix for Path('0') handling (RT #29334)
         - Workaround for Win32 and c3_mro.t (RT #26452, tested by Kenichi Ishigaki)
-        - Fix for encoding query parameters (eden)
+        - Fix for encoding query parameters (edenc)
+        - Fix Chained multiple test (t0m)
 
 5.7012  2007-12-16 23:44:00
         - Fix uri_for()'s and uri_with()'s handling of multibyte chars
index 02f4c21..d436983 100644 (file)
@@ -208,7 +208,7 @@ sub register {
 
     return 0 unless @chained_attr;
 
-    if (@chained_attr > 2) {
+    if (@chained_attr > 1) {
         Catalyst::Exception->throw(
           "Multiple Chained attributes not supported registering ${action}"
         );
diff --git a/t/dead_load_multiple_chained_attributes.t b/t/dead_load_multiple_chained_attributes.t
new file mode 100644 (file)
index 0000000..7d1ad34
--- /dev/null
@@ -0,0 +1,31 @@
+#!perl
+
+use strict;
+use warnings;
+use lib 't/lib';
+
+use Test::More;
+
+plan tests => 4;
+
+use Catalyst::Test 'TestApp';
+
+eval q{  
+    package TestApp::Controller::Action::Chained;
+    sub should_fail : Chained('/') Chained('foo') Args(0) {}
+};
+ok(!$@);
+
+eval { TestApp->setup_actions; }; 
+ok($@, 'Multiple chained attributes make action setup fail');
+
+eval q{      
+    package TestApp::Controller::Action::Chained;
+    no warnings 'redefine';
+    sub should_fail {}
+};
+ok(!$@);
+
+eval { TestApp->setup_actions };
+ok(!$@, 'And ok again') or warn $@;
+