Skip to content

Commit 7152b96

Browse files
committed
Revert "Fixed defaultAction in controllers to be url converter aware. Removed addViewPrefix that was not url converter aware"
This reverts commit 4f69eda.
1 parent 40a93ca commit 7152b96

File tree

5 files changed

+6
-43
lines changed

5 files changed

+6
-43
lines changed

grails-core/src/main/groovy/org/grails/core/DefaultGrailsControllerClass.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,6 @@ public void registerUrlConverter(UrlConverter urlConverter) {
169169
actionUriToViewName.put(urlConverter.toUrlElement(actionName), actionName);
170170
actions.put( urlConverter.toUrlElement(actionName), actions.remove(actionName));
171171
}
172-
defaultActionName = urlConverter.toUrlElement(defaultActionName);
173172
}
174173

175174
/**

grails-test-suite-web/src/test/groovy/org/grails/web/taglib/CoreTagsTests.groovy

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@ class CoreTagsTests extends AbstractGrailsTagTests {
1313

1414
@Override
1515
protected void onSetUp() {
16-
System.setProperty(Environment.KEY, "dev")
17-
}
18-
19-
@Override
20-
protected void onDestroy() {
2116
System.setProperty(Environment.KEY, "")
2217
}
2318

grails-web-common/src/main/groovy/org/grails/web/util/WebUtils.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,6 @@ public static View resolveView(HttpServletRequest request, String viewName, Stri
191191
/**
192192
* @deprecated Does not take into account the url converter
193193
*/
194-
@Deprecated
195194
public static String addViewPrefix(String viewName) {
196195
GrailsWebRequest webRequest = GrailsWebRequest.lookup();
197196
return addViewPrefix(viewName, webRequest != null ? webRequest.getControllerName() : null);

grails-web-gsp/src/main/groovy/org/grails/web/servlet/view/GroovyPageViewResolver.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@ public GroovyPageViewResolver(GroovyPagesTemplateEngine templateEngine,
8282
public void setGroovyPageLocator(GrailsConventionGroovyPageLocator groovyPageLocator) {
8383
this.groovyPageLocator = groovyPageLocator;
8484
}
85+
86+
@Override
87+
public View resolveViewName(String viewName, Locale locale) throws Exception {
88+
return super.resolveViewName(WebUtils.addViewPrefix(viewName), locale);
89+
}
8590

8691
@Override
8792
protected View loadView(String viewName, Locale locale) throws Exception {

grails-web-url-mappings/src/test/groovy/org/grails/web/mapping/mvc/UrlMappingsHandlerMappingSpec.groovy

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -158,43 +158,11 @@ class UrlMappingsHandlerMappingSpec extends AbstractUrlMappingsSpec {
158158
def result = handlerAdapter.handle(request, webRequest.response, handlerChain.handler)
159159

160160
then:"The model and view is correct"
161-
result.viewName == 'fooBar'
161+
result.viewName == '/foo/fooBar'
162162
!result.model
163-
}
164-
165-
void "Test that a matched URL returns a URLMappingInfo with controller with defaultAction"() {
166-
167-
given:
168-
def grailsApplication = new DefaultGrailsApplication(FooController)
169-
grailsApplication.initialise()
170-
def holder = getUrlMappingsHolder {
171-
"/foo"(controller:"foo")
172-
}
173-
def urlConverter = new HyphenatedUrlConverter()
174-
holder = new GrailsControllerUrlMappings(grailsApplication, holder, urlConverter)
175-
def handler = new UrlMappingsHandlerMapping(holder)
176-
177-
when:"A URI is matched"
178-
179-
def webRequest = GrailsWebMockUtil.bindMockWebRequest()
180-
webRequest.renderView = true
181-
def request = webRequest.request
182-
request.setRequestURI("/foo")
183-
def handlerChain = handler.getHandler(request)
184-
185-
then:"A handlerChain is created"
186-
handlerChain != null
187163

188-
when:"A HandlerAdapter is used with a hyphenated url converter"
189-
def handlerAdapter = new UrlMappingsInfoHandlerAdapter()
190-
def result = handlerAdapter.handle(request, webRequest.response, handlerChain.handler)
191-
192-
then:"The model and view is correct"
193-
result.viewName == 'fooBar'
194-
!result.model
195164
}
196165

197-
198166
void "test modelAndView is returned for URI"() {
199167
given:
200168
def grailsApplication = new DefaultGrailsApplication(FooController)
@@ -218,9 +186,6 @@ class UrlMappingsHandlerMappingSpec extends AbstractUrlMappingsSpec {
218186

219187
@Artefact('Controller')
220188
class FooController {
221-
222-
static defaultAction = 'fooBar'
223-
224189
@Action
225190
def bar() {
226191
[foo:"bar"]

0 commit comments

Comments
 (0)