Skip to content

Commit

Permalink
Fixes #9138 - Grouped URL mappings don't include group part parameter…
Browse files Browse the repository at this point in the history
…s in grails 3.0.3
  • Loading branch information
graemerocher committed Sep 24, 2015
1 parent e79ae06 commit b26390b
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 2 deletions.
Expand Up @@ -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();

}
}

Expand Down Expand Up @@ -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);
Expand All @@ -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)) {
Expand Down
@@ -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'
}
}

0 comments on commit b26390b

Please sign in to comment.