Discussion:
Testing model change of filter
Martin Hauner
2014-01-05 18:43:22 UTC
Permalink
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
Loading...