diff --git a/grails-web-url-mappings/src/main/groovy/org/grails/web/mapping/DefaultUrlMappingEvaluator.java b/grails-web-url-mappings/src/main/groovy/org/grails/web/mapping/DefaultUrlMappingEvaluator.java index 08fb839aa8b..ecb3c28aac8 100644 --- a/grails-web-url-mappings/src/main/groovy/org/grails/web/mapping/DefaultUrlMappingEvaluator.java +++ b/grails-web-url-mappings/src/main/groovy/org/grails/web/mapping/DefaultUrlMappingEvaluator.java @@ -347,9 +347,12 @@ public void group(String uri, Closure mappings) { try { parentResources.push(new ParentResource(null, uri, true)); + pushNewMetaMappingInfo(); mappings.call(); } finally { + mappingInfoDeque.pop(); parentResources.pop(); + } } @@ -425,7 +428,7 @@ private Object _invoke(String methodName, Object arg, Object delegate) { } else { urlMapping = createURLMapping(urlData, isResponseCode, mappingInfo.getRedirectInfo(), mappingInfo.getController(), mappingInfo.getAction(), mappingInfo.getNamespace(), mappingInfo.getPlugin(), mappingInfo.getView(), mappingInfo.getHttpMethod(), null, constraints); } - + if (binding != null) { Map bindingVariables = variables; Object parse = getParseRequest(Collections.EMPTY_MAP, bindingVariables); @@ -452,7 +455,7 @@ private Object _invoke(String methodName, Object arg, Object delegate) { if (namedArguments.containsKey(UrlMapping.PLUGIN)) { mappingInfo.setPlugin(namedArguments.get(UrlMapping.PLUGIN).toString()); } - + UrlMappingData urlData = createUrlMappingData(uri, isResponseCode); if (namedArguments.containsKey(RESOURCE)) { diff --git a/grails-web-url-mappings/src/test/groovy/org/codehaus/groovy/grails/web/mapping/GroupedUrlMappingSpec.groovy b/grails-web-url-mappings/src/test/groovy/org/codehaus/groovy/grails/web/mapping/GroupedUrlMappingSpec.groovy new file mode 100644 index 00000000000..f151bc846c6 --- /dev/null +++ b/grails-web-url-mappings/src/test/groovy/org/codehaus/groovy/grails/web/mapping/GroupedUrlMappingSpec.groovy @@ -0,0 +1,40 @@ +package org.codehaus.groovy.grails.web.mapping + +import spock.lang.Issue + +/* + * Copyright 2014 original authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @author graemerocher + */ +class GroupedUrlMappingSpec extends AbstractUrlMappingsSpec { + + @Issue('#9138') + void "Test that group parameters are included in generated links"() { + given:"A link generator with a dynamic URL mapping" + def linkGenerator = getLinkGenerator { + group "/events/$alias", { + "/" (controller: 'test', action: 'index') + "/orders/$id" (controller: 'test', action: 'show') + } + } + + expect: + linkGenerator.link(controller:"test", action: 'index', params:[alias:'foo']) == 'http://localhost/events/foo' + linkGenerator.link(controller:"test", action: 'show', id:1, params:[alias:'foo']) == 'http://localhost/events/foo/orders/1' + } +}