You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@grails.apache.org by jd...@apache.org on 2026/04/08 04:24:27 UTC

(grails-core) branch expandedTests/issue-10844_take2 created (now 6c252f0ca2)

This is an automated email from the ASF dual-hosted git repository.

jdaugherty pushed a change to branch expandedTests/issue-10844_take2
in repository https://gitbox.apache.org/repos/asf/grails-core.git


      at 6c252f0ca2 WIP

This branch includes the following new commits:

     new 6c252f0ca2 WIP

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(grails-core) 01/01: WIP

Posted by jd...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jdaugherty pushed a commit to branch expandedTests/issue-10844_take2
in repository https://gitbox.apache.org/repos/asf/grails-core.git

commit 6c252f0ca2d42ae5a7012cd9bf341c07d4151d1d
Author: Iván López <lo...@gmail.com>
AuthorDate: Thu Nov 5 10:51:53 2020 +0100

    WIP
---
 .../web/mapping/DefaultUrlMappingEvaluator.java    |  1 +
 .../web/mapping/GroupedUrlMappingSpec.groovy       | 75 +++++++++++++++++++++-
 2 files changed, 73 insertions(+), 3 deletions(-)

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 146f67b2dd..5834b6cff1 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
@@ -578,6 +578,7 @@ public class DefaultUrlMappingEvaluator implements UrlMappingEvaluator, ClassLoa
             this.isInCollection = true;
             try {
                 callable.setDelegate(this);
+//                callable.setResolveStrategy(Closure.DELEGATE_FIRST);
                 callable.call();
             } finally {
                 isInCollection = previousState ;
diff --git a/grails-web-url-mappings/src/test/groovy/grails/web/mapping/GroupedUrlMappingSpec.groovy b/grails-web-url-mappings/src/test/groovy/grails/web/mapping/GroupedUrlMappingSpec.groovy
index 8a1cdab1ed..37d996fdda 100644
--- a/grails-web-url-mappings/src/test/groovy/grails/web/mapping/GroupedUrlMappingSpec.groovy
+++ b/grails-web-url-mappings/src/test/groovy/grails/web/mapping/GroupedUrlMappingSpec.groovy
@@ -3,6 +3,7 @@ package grails.web.mapping
 import grails.util.GrailsWebMockUtil
 import grails.web.http.HttpHeaders
 import org.springframework.web.context.request.RequestContextHolder
+import spock.lang.IgnoreRest
 import spock.lang.Issue
 
 import javax.servlet.http.HttpServletRequest
@@ -29,27 +30,95 @@ import javax.servlet.http.HttpServletResponse
  */
 class GroupedUrlMappingSpec extends AbstractUrlMappingsSpec {
 
+    @IgnoreRest
     @Issue('#10308')
     void "Test mapping with group and nested collection"() {
         given:
         def linkGenerator = getLinkGenerator {
             "/foos"(resources: 'foo') {
                 collection {
-                    '/baz'(controller: 'foo', action: 'baz')
+                    '/baz'(controller: 'foo1', action: 'baz')
                 }
             }
 
             group "/g", {
                 "/bars"(resources: 'bar') {
                     collection {
-                        '/baz'(controller: 'bar', action: 'baz')
+//                        '/baz'(controller: 'bar1', action: 'baz')
+                        '/baz'(resources: 'baz')
                     }
                 }
             }
         }
 
         expect:
-        linkGenerator.link(controller:'bar', action:'baz', params:[barId:1]) == 'http://localhost/g/bars/1/baz'
+        linkGenerator.link(controller:'bar1', action:'baz', params:[barId:1, bazId:2]) == 'http://localhost/g/bars/1/baz' //http://localhost/g/bars/baz?barId=1
+        linkGenerator.link(controller:'foo1', action:'baz', params:[fooId:1]) == 'http://localhost/foos/baz?fooId=1'
+
+//        http://localhost/bar/baz?userId=1
+    }
+
+    @IgnoreRest
+    void "Test mapping with group and nested collection....."() {
+        given:
+        def linkGenerator = getLinkGenerator {
+            "/books"(resources: 'book') {
+                collection {
+                    "/authors"(resources: 'author')
+                }
+            }
+        }
+
+        expect:
+        linkGenerator.link(controller:'author', action:'show', method:'GET', params:[bookId:1, id:2]) == 'http://localhost/books/authors/2?bookId=1'
+
+        //'http://localhost/books/authors/2?bookId=1'
+    }
+
+//    https://github.com/grails/grails-core/issues/10308
+//    https://github.com/grails/grails-core/issues/10844
+
+    @IgnoreRest
+    @Issue('#10844')
+    void "Test mapping with group and nested collection (II)"() {
+        given:
+        def linkGenerator = getLinkGenerator {
+            '/api1/employees'(resources: 'employeea') {
+                collection {
+                    '/search'(controller: 'employee1', action: 'search1', method: 'GET')
+                }
+            }
+
+            group '/api2', {
+                '/employees'(resources: 'employeeb') {
+                    collection {
+                        '/search'(controller: 'employee2', action: 'search2', method: 'GET')
+                    }
+                }
+            }
+
+//            get "/$controller/$id(.$format)?"(action:"show")
+//
+//            "/$controller/$action?/$id?(.$format)?"{
+//                constraints {
+//                    // apply constraints here
+//                }
+//            }
+        }
+
+        expect:
+        linkGenerator.link(controller: 'employee1', action: 'search1', method: 'GET', params: [employeeaId: 1]) == 'http://localhost/api1/employees/search?userId=1'
+        linkGenerator.link(controller: 'employee2', action: 'search2', method: 'GET', params: [employeebId: 1]) == 'http://localhost/api2/employees/search?userId=1'
+
+//        http://localhost/employee2/search2?userId=1
+
+//        and:
+        linkGenerator.link(resource: 'employeea', method: 'PUT', params: [id: 1]) == 'http://localhost/api1/employees/1'
+        linkGenerator.link(resource: 'employeeb', method: 'PUT', params: [id: 1]) == 'http://localhost/api2/employees/1'
+
+        and:
+        linkGenerator.link(resource: 'employeea', method: 'POST', params: [employeeaId: 1]) == 'http://localhost/api1/employees?employeeaId=1'
+        linkGenerator.link(resource: 'employeeb', method: 'POST', params: [employeebId: 1]) == 'http://localhost/api2/employees?employeebId=1'
     }
 
     @Issue('#9417')