Permalink
Browse files

Applied Luis Arias' commit 9b43c3ba7f10864566f8 and added a unit test.

  • Loading branch information...
1 parent 3b4455d commit 6c997be99deb3af0dd192950075f7336279d3589 @pledbrook pledbrook committed Sep 6, 2010
@@ -70,6 +70,10 @@ class ChainMethod {
UrlMappingsHolder mappings = appCtx.getBean(UrlMappingsHolder.BEAN_ID)
+ // Make sure that if an ID was given, it is used to evaluate
+ // the reverse URL mapping.
+ if (id) params.id = id
+
UrlCreator creator = mappings.getReverseMapping(controller, action, params)
def response = webRequest.getCurrentResponse()
@@ -23,6 +23,10 @@ class TestChainController {
chain(action:'create',model:[book:book])
}
}
+
+ def testId = {
+ chain action: 'show', id: 5, model: [str: "Test param"]
+ }
}
class TestChainBook {
Long id
@@ -51,4 +55,12 @@ class TestChainBook {
assertEquals '/testChain/create', response.redirectedUrl
}
+
+ void testChainMethodWithId() {
+ def controller = ga.getControllerClass("TestChainController").newInstance()
+ controller.testId()
+
+ assertEquals "Test param", controller.flash.chainModel.str
+ assertEquals "/testChain/show/5", response.redirectedUrl
+ }
}

0 comments on commit 6c997be

Please sign in to comment.