Testing model change of filter

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Testing model change of filter

Martin Hauner
Hi,

while looking at
http://stackoverflow.com/questions/20928797/how-to-unit-test-a-grails-after-filter-that-updates-the-model

and the withFilter method here

https://github.com/grails/grails-core/blob/master/grails-plugin-testing/src/main/groovy/grails/test/mixin/web/FiltersUnitTestMixin.groovy

final controller = request.getAttribute(GrailsApplicationAttributes.CONTROLLER)
def modelAndView = controller?.modelAndView
if (modelAndView == null && (result instanceof Map)) {
     modelAndView = new ModelAndView('/', result)
     controller?.modelAndView = new ModelAndView(controller.actionUri ?:
"/${webRequest.controllerName}/${webRequest.actionName}", result)
}
interceptor.postHandle(request, response, this, modelAndView)


I wonder why there are two ModelAndViews?  Shouldn't controller?.modelAndView be
passed to postHandle so we can get at the model passed to the filter?


--
Martin

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email