Permalink
Browse files

Merge branch '3.1.x' into 3.2.x

  • Loading branch information...
2 parents 6671893 + 841f4df commit 2b589e0a15f541025db6e066228d819a15452417 @graemerocher graemerocher committed Oct 25, 2016
@@ -13,20 +13,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package grails.async;
+package grails.async
+import grails.async.decorator.PromiseDecorator
+import groovy.transform.CompileStatic
+import org.grails.async.factory.SynchronousPromiseFactory
+import org.grails.async.factory.gpars.GparsPromiseFactory
-import groovy.lang.Closure
-import groovy.transform.CompileStatic;
-
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.TimeUnit;
-
-import grails.async.decorator.PromiseDecorator;
-import org.grails.async.factory.SynchronousPromiseFactory;
-import org.grails.async.factory.gpars.GparsPromiseFactory;
-import org.grails.async.factory.reactor.ReactorPromiseFactory;
+import java.util.concurrent.TimeUnit
/**
* Factory class for working with {@link Promise} instances
@@ -31,8 +31,11 @@ import java.util.concurrent.TimeoutException
*
* @author Graeme Rocher
* @since 3.0
+ *
+ * @deprecated Reactor promise integration is deprecated and will be removed in a future version of Grails
*/
@CompileStatic
+@Deprecated
class ReactorPromise<T> implements Promise<T> {
reactor.rx.Promise<T> internalPromise
@@ -31,8 +31,11 @@ import java.util.concurrent.TimeUnit
*
* @author Graeme Rocher
* @since 3.0
+ *
+ * @deprecated Reactor promise integration is deprecated and will be removed in a future version of Grails
*/
@CompileStatic
+@Deprecated
class ReactorPromiseFactory extends AbstractPromiseFactory {
static final boolean REACTOR_PRESENT
static {
@@ -35,17 +35,11 @@ class ControllersAsyncGrailsPlugin extends Plugin {
Closure doWithSpring() {{->
asyncPromiseResponseActionResultTransformer(AsyncActionResultTransformer)
-
}}
@Override
@CompileStatic
void doWithDynamicMethods() {
- try {
- Promises.promiseFactory = new ReactorPromiseFactory(applicationContext.getBean(Environment))
- } catch (NoSuchBeanDefinitionException e) {
- // Reactor not configured
- }
Promises.promiseFactory.addPromiseDecoratorLookupStrategy(new WebRequestPromiseDecoratorLookupStrategy())
}
@@ -775,12 +775,13 @@ private String establishFullURI(String uri, List<ConstrainedProperty> constraine
if(!isInCollection) {
uriBuilder.append(SLASH).append(CAPTURING_WILD_CARD);
- constrainedList.add(new ConstrainedProperty(UrlMapping.class, parentResource.controllerName + "Id", String.class));
}
}
}
- uriBuilder.append(uri);
+ if(!SLASH.equals(uri)) {
+ uriBuilder.append(uri);
+ }
return uriBuilder.toString();
}
@@ -1197,6 +1198,12 @@ protected MetaMappingInfo pushNewMetaMappingInfo() {
if (parentMappingConstraints != null) {
mappingInfo.getConstraints().addAll(parentMappingConstraints);
}
+ ParentResource parentResource = parentResources.peek();
+ if(parentResource != null && !parentResource.isSingle) {
+ if(!isInCollection) {
+ mappingInfo.getConstraints().add(new ConstrainedProperty(UrlMapping.class, parentResource.controllerName + "Id", String.class));
+ }
+ }
}
if (previousConstraints.size() > 0) {
mappingInfo.getConstraints().addAll(previousConstraints);
@@ -0,0 +1,27 @@
+package org.grails.web.mapping
+
+import org.codehaus.groovy.grails.web.mapping.AbstractUrlMappingsSpec
+import spock.lang.Issue
+
+/**
+ * Created by graemerocher on 25/10/16.
+ */
+class NestedMappingWithinGroupSpec extends AbstractUrlMappingsSpec {
+
+ @Issue('https://github.com/grails/grails-core/issues/10246')
+ void "test nested mapping within group"() {
+ given:"A link generator with nested mappings withihn a group"
+ def linkGenerator = getLinkGenerator {
+ group("/api") {
+ "/customer-stores"(resources: 'store') {
+ "/catalogs"(controller: 'catalog', action: 'index', method: 'GET')
+ "/catalogs/$catalogId/items"(controller: 'catalog', action: 'getItems', method: 'GET')
+ }
+ }
+ }
+
+ expect:"The generated links to be correct"
+ linkGenerator.link(controller:"catalog", action:"index", method:"GET", params:[storeId:'1']) == 'http://localhost/api/customer-stores/1/catalogs'
+ linkGenerator.link(controller:"catalog", action:"getItems", method:"GET", params:[storeId:'1', catalogId:'2']) == 'http://localhost/api/customer-stores/1/catalogs/2/items'
+ }
+}
@@ -0,0 +1,28 @@
+package org.grails.web.mapping
+
+import grails.web.mapping.LinkGenerator
+import org.codehaus.groovy.grails.web.mapping.AbstractUrlMappingsSpec
+import spock.lang.Issue
+
+/**
+ * Created by graemerocher on 25/10/16.
+ */
+class ResourcesWithSingleSlashSpec extends AbstractUrlMappingsSpec {
+
+ @Issue('https://github.com/grails/grails-core/issues/10210')
+ void "test that resources expressed with a single slash product the correct URI"() {
+ given:"url mappings within groups with resources expressed with a single slash"
+ LinkGenerator linkGenerator = getLinkGenerator {
+ group "/api", {
+ group "/v1", {
+ group "/books", {
+ "/" resources:"book"
+ }
+ }
+ }
+ }
+
+ expect:
+ linkGenerator.link(resource:"book", id:1L, method:"GET") == 'http://localhost/api/v1/books/1'
+ }
+}

0 comments on commit 2b589e0

Please sign in to comment.