Skip to content

Commit

Permalink
fix for GRAILS-10820 "Group UrlMappings Producing null Params"
Browse files Browse the repository at this point in the history
  • Loading branch information
graemerocher committed Nov 28, 2013
1 parent 7ee51f6 commit efc0b05
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,9 @@ private Object _invoke(String methodName, Object arg, Object delegate) {
parameterValues = new HashMap<String, Object>();
Map variables = binding != null ? binding.getVariables() : null;
try {
urlDefiningMode = false;
if( parentResources.isEmpty() ) {
urlDefiningMode = false;
}
args = args != null && args.length > 0 ? args : new Object[]{Collections.EMPTY_MAP};
if (args[0] instanceof Closure) {
UrlMappingData urlData = createUrlMappingData(mappedURI, isResponseCode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,39 @@ import spock.lang.Specification
*/
class RestfulResourceMappingSpec extends Specification{

@Issue('GRAILS-10820')
void 'Test that grouped params with dynamic variables product the correct mappings'() {
given: 'A resource mapping with child mappings'
def urlMappingsHolder = getUrlMappingsHolder {
"/report"(controller: 'blah', action: 'report')
group "/foo", {
"/blah/$foo/$action?"(controller: 'blah')
"/$foo/$action?"(controller: 'blah')
}
"/$foo?"(controller: 'blah', action: 'index')
}

when:"The URL mappings are obtained"
def urlMappings = urlMappingsHolder.urlMappings

then:"There are eight of them in total"
urlMappings.size() == 4

expect:
urlMappingsHolder.matchAll('/report', 'GET')[0].controllerName == 'blah'
urlMappingsHolder.matchAll('/report', 'GET')[0].actionName == 'report'
urlMappingsHolder.matchAll('/foo/blah/stuff/go', 'GET')[0].controllerName == 'blah'
urlMappingsHolder.matchAll('/foo/blah/stuff/go', 'GET')[0].parameters.action == 'go'
urlMappingsHolder.matchAll('/foo/blah/stuff/go', 'GET')[0].parameters.foo == 'stuff'

urlMappingsHolder.matchAll('/foo/stuff/go', 'GET')[0].controllerName == 'blah'
urlMappingsHolder.matchAll('/foo/stuff/go', 'GET')[0].parameters.action == 'go'
urlMappingsHolder.matchAll('/foo/stuff/go', 'GET')[0].parameters.foo == 'stuff'

urlMappingsHolder.matchAll('/home', 'GET')[0].controllerName == 'blah'
urlMappingsHolder.matchAll('/home', 'GET')[0].actionName == 'index'

}
@Issue('GRAILS-10835')
void 'Test multiple nested mappings have correct constrained properties'() {
given: 'A resource mapping with child mappings'
Expand Down

0 comments on commit efc0b05

Please sign in to comment.