@@ -121,6 +121,41 @@ class InterceptorSpec extends Specification {
121121
122122 }
123123
124+ void " Test the match all interceptor mappings exception an exact controller action pair" () {
125+ given :" A test interceptor"
126+ def i = new Test4Interceptor ()
127+ def webRequest = GrailsWebMockUtil . bindMockWebRequest()
128+ def request = webRequest. request
129+
130+ when :" The current request is for a controller called test"
131+ request. setAttribute(UrlMappingsHandlerMapping . MATCHED_REQUEST , new ForwardUrlMappingInfo (controllerName : " test" ))
132+ then :" We match"
133+ i. doesMatch()
134+
135+ when :" The current request is for a controller called test and action called bar"
136+ clearMatch(i,request)
137+ request. setAttribute(UrlMappingsHandlerMapping . MATCHED_REQUEST , new ForwardUrlMappingInfo (controllerName : " test" , actionName : " bar" ))
138+ then :" We match"
139+ i. doesMatch()
140+
141+ when :" The current request is for a controller called test and action called bar"
142+ clearMatch(i,request)
143+ request. setAttribute(UrlMappingsHandlerMapping . MATCHED_REQUEST , new ForwardUrlMappingInfo (controllerName : " foo" , actionName : " bar" ))
144+ then :" We match"
145+ ! i. doesMatch()
146+
147+ when :" The current request is for another controller"
148+ clearMatch(i,request)
149+ request. setAttribute(UrlMappingsHandlerMapping . MATCHED_REQUEST , new ForwardUrlMappingInfo (controllerName : " other" ))
150+ then :" We match"
151+ i. doesMatch()
152+
153+ when :" The current request is for an excluded controller controller"
154+ clearMatch(i,request)
155+ request. setAttribute(UrlMappingsHandlerMapping . MATCHED_REQUEST , new ForwardUrlMappingInfo (controllerName : " foo" ))
156+ then :" We don't match"
157+ i. doesMatch()
158+ }
124159 void clearMatch (i , HttpServletRequest request ) {
125160 request. removeAttribute(i. getClass(). name + InterceptorArtefactHandler . MATCH_SUFFIX )
126161 }
@@ -155,4 +190,11 @@ class Test3Interceptor implements Interceptor {
155190 matchAll()
156191 .excludes(controller :" foo" )
157192 }
193+ }
194+
195+ class Test4Interceptor implements Interceptor {
196+ Test4Interceptor () {
197+ matchAll()
198+ .excludes(controller :" foo" , action :" bar" )
199+ }
158200}
0 commit comments