Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#280 layout() method in controller does not override getLayout() in c…
…ontrollers
- Loading branch information
Igor Polevoy
committed
May 13, 2016
1 parent
0cdc1c4
commit bb3e090
Showing
7 changed files
with
77 additions
and
2 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
activeweb-testing/src/test/java/app/controllers/OverrideLayoutController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package app.controllers; | ||
|
||
import org.javalite.activeweb.AppController; | ||
|
||
/** | ||
* @author Igor Polevoy on 5/13/16. | ||
*/ | ||
public class OverrideLayoutController extends AppController { | ||
|
||
public void index(){} | ||
|
||
public void action(){ | ||
render().layout("/layouts/default_layout"); | ||
} | ||
|
||
|
||
@Override | ||
protected String getLayout() { | ||
return "/layouts/override_layout"; | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
activeweb-testing/src/test/java/app/controllers/OverrideLayoutControllerSpec.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
Copyright 2009-2014 Igor Polevoy | ||
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. | ||
*/ | ||
|
||
package app.controllers; | ||
|
||
import org.javalite.activeweb.ControllerSpec; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
/** | ||
* @author Igor Polevoy | ||
*/ | ||
public class OverrideLayoutControllerSpec extends ControllerSpec { | ||
|
||
@Before | ||
public void before(){ | ||
setTemplateLocation("src/test/views"); | ||
} | ||
|
||
@Test | ||
public void shouldUseControllerLayout(){ | ||
request().get("index"); | ||
a(responseContent()).shouldBeEqual("Override layout top Index Override layout bottom"); | ||
a(layout()).shouldBeEqual("/layouts/override_layout"); | ||
} | ||
|
||
@Test | ||
public void shouldUseDefaultLayoutFromAction(){ | ||
request().get("action"); | ||
a(responseContent()).shouldBeEqual("override"); | ||
a(layout()).shouldBeEqual("/layouts/default_layout"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Override layout top ${page_content} Override layout bottom |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
override |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Index |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters