forked from gpc/fields
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request gpc#62 from guspower/master
Functional Test And Small Documentation Update For Passing Params Through To Default Tags
- Loading branch information
Showing
8 changed files
with
127 additions
and
0 deletions.
There are no files selected for viewing
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
5 changes: 5 additions & 0 deletions
5
test/projects/scaffolding/grails-app/controllers/test/CaptainController.groovy
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,5 @@ | ||
package test | ||
|
||
class CaptainController { | ||
static scaffold = true | ||
} |
5 changes: 5 additions & 0 deletions
5
test/projects/scaffolding/grails-app/controllers/test/ShipController.groovy
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,5 @@ | ||
package test | ||
|
||
class ShipController { | ||
static scaffold = true | ||
} |
7 changes: 7 additions & 0 deletions
7
test/projects/scaffolding/grails-app/domain/test/Captain.groovy
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,7 @@ | ||
package test | ||
|
||
class Captain { | ||
|
||
String name | ||
|
||
} |
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,8 @@ | ||
package test | ||
|
||
class Ship { | ||
|
||
Captain captain | ||
String name | ||
|
||
} |
41 changes: 41 additions & 0 deletions
41
test/projects/scaffolding/grails-app/views/ship/create.gsp
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,41 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<meta name="layout" content="main"> | ||
<g:set var="entityName" value="Ship" /> | ||
<title><g:message code="default.create.label" args="[entityName]" /></title> | ||
</head> | ||
<body> | ||
<a href="#create-ship" class="skip" tabindex="-1"><g:message code="default.link.skip.label" default="Skip to content…"/></a> | ||
<div class="nav" role="navigation"> | ||
<ul> | ||
<li><a class="home" href="${createLink(uri: '/')}"><g:message code="default.home.label"/></a></li> | ||
<li><g:link class="list" action="list"><g:message code="default.list.label" args="[entityName]" /></g:link></li> | ||
</ul> | ||
</div> | ||
<div id="create-ship" class="content scaffold-create" role="main"> | ||
<h1><g:message code="default.create.label" args="[entityName]" /></h1> | ||
<g:if test="${flash.message}"> | ||
<div class="message" role="status">${flash.message}</div> | ||
</g:if> | ||
<g:hasErrors bean="${shipInstance}"> | ||
<ul class="errors" role="alert"> | ||
<g:eachError bean="${shipInstance}" var="error"> | ||
<li <g:if test="${error in org.springframework.validation.FieldError}">data-field-id="\${error.field}"</g:if>><g:message error="${error}"/></li> | ||
</g:eachError> | ||
</ul> | ||
</g:hasErrors> | ||
<g:form action="save"> | ||
<fieldset class="form"> | ||
<f:with bean="${shipInstance}"> | ||
<f:field property="captain" input-optionValue="name"/> | ||
<f:field property="name"/> | ||
</f:with> | ||
</fieldset> | ||
<fieldset class="buttons"> | ||
<g:submitButton name="create" class="save" value="${message(code: 'default.button.create.label', default: 'Create')}" /> | ||
</fieldset> | ||
</g:form> | ||
</div> | ||
</body> | ||
</html> |
50 changes: 50 additions & 0 deletions
50
...ojects/scaffolding/test/functional/grails/plugin/formfields/test/DefaultSelectSpec.groovy
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,50 @@ | ||
package grails.plugin.formfields.test | ||
|
||
import geb.spock.GebSpec | ||
import spock.lang.Stepwise | ||
|
||
@Stepwise | ||
class DefaultSelectSpec extends GebSpec { | ||
|
||
void 'create some captains'() { | ||
given: | ||
go 'captain/create' | ||
def form = $('form') | ||
|
||
when: | ||
form.name = name | ||
form.create().click() | ||
|
||
then: | ||
$('.message').text() ==~ /Captain \d+ created/ | ||
|
||
where: | ||
name << ["Kirk", "Khan"] | ||
} | ||
|
||
void 'captains are listed by name when creating ship'() { | ||
given: | ||
go 'ship/create' | ||
|
||
when: | ||
def options = $('select option') | ||
|
||
then: | ||
options*.text() == ["Khan", "Kirk"] | ||
} | ||
|
||
void 'kirk is captain of the enterprise'() { | ||
given: | ||
def form = $('form') | ||
|
||
when: | ||
form.'captain.id' = "Kirk" | ||
form.name = "Enterprise" | ||
|
||
form.create().click() | ||
|
||
then: | ||
$('.message').text() ==~ /Ship \d+ created/ | ||
} | ||
|
||
} |