Permalink
Browse files

Test chaining to namespaced controllers

  • Loading branch information...
1 parent 70d3666 commit f3d84911767f622ae808e05f8e940f95c657ca5c @jeffbrown jeffbrown committed Jul 3, 2015
@@ -54,6 +54,9 @@ class UrlMappings {
"/anotherRouteToNonNamespacedController"(controller: 'namespaced')
+ "/alphaDemo"(namespace: 'alpha', controller: 'demo', action: 'doit')
+ "/betaDemo"(namespace: 'beta', controller: 'demo', action: 'doit')
+
"/numberOne"(redirect: [controller: 'redirect', action: 'one'])
"/numberTwo"(redirect: [controller: 'redirect', action: 'two'])
"/anotherNumberOne"(redirect: [uri: '/redirect/one'])
@@ -0,0 +1,8 @@
+package demo.chain
+
+class ChainHomeController {
+
+ def demoChain(String ns) {
+ chain controller: 'demo', action: 'doit', namespace: ns
+ }
+}
@@ -0,0 +1,10 @@
+package demo.chain.alpha
+
+class DemoController {
+
+ static namespace = 'alpha'
+
+ def doit() {
+ render 'render from the DemoController in the alpha namespace'
+ }
+}
@@ -0,0 +1,10 @@
+package demo.chain.beta
+
+class DemoController {
+
+ static namespace = 'beta'
+
+ def doit() {
+ render 'render from the DemoController in the beta namespace'
+ }
+}
@@ -0,0 +1,27 @@
+package chaining
+
+class NamespacedControllerChainingFunctionalTests extends functionaltestplugin.FunctionalTestCase {
+
+ void testChainingToNamespacedController() {
+ get '/chainHome/demoChain?ns=alpha'
+ assertStatus 200
+ assertContentContains 'render from the DemoController in the alpha namespace'
+
+ get '/chainHome/demoChain?ns=beta'
+ assertStatus 200
+ assertContentContains 'render from the DemoController in the beta namespace'
+ }
+
+
+ void testRedirectUrlWhenChainingToNamespacedController() {
+ redirectEnabled = false
+ get '/chainHome/demoChain?ns=alpha'
+ assertStatus 302
+ assertRedirectUrlContains '/alphaDemo'
+
+ get '/chainHome/demoChain?ns=beta'
+ assertStatus 302
+ assertRedirectUrlContains '/betaDemo'
+ }
+
+}

0 comments on commit f3d8491

Please sign in to comment.