Skip to content

Commit 93461ec

Browse files
author
marcpalmer
committed
Whitespace issues and lack of tests for actionSubmit and actionSubmitImage - GRAILS-680
git-svn-id: https://svn.codehaus.org/grails/trunk@2959 1cfb16fd-6d17-0410-8ff1-b7e8e1e2867d
1 parent 29e1db4 commit 93461ec

File tree

2 files changed

+30
-6
lines changed

2 files changed

+30
-6
lines changed

src/grails/grails-app/taglib/FormTagLib.groovy

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -150,13 +150,13 @@ class FormTagLib {
150150
out << '<input type="submit" name="_action" '
151151
def value = attrs.remove('value')
152152
if(value) {
153-
out << "value=\"${value}\""
153+
out << "value=\"${value}\" "
154154
}
155155
// process remaining attributes
156156
outputAttributes(attrs)
157157

158158
// close tag
159-
out.println '/>'
159+
out << '/>'
160160

161161
}
162162
/**
@@ -171,17 +171,17 @@ class FormTagLib {
171171
out << '<input type="image" name="_action" '
172172
def value = attrs.remove('value')
173173
if(value) {
174-
out << "value=\"${value}\""
174+
out << "value=\"${value}\" "
175175
}
176176
def src = attrs.remove('src')
177177
if(src) {
178-
out << "src=\"${src}\""
178+
out << "src=\"${src}\" "
179179
}
180180
// process remaining attributes
181181
outputAttributes(attrs)
182182

183183
// close tag
184-
out.println '/>'
184+
out << '/>'
185185

186186
}
187187

test/groovy/org/codehaus/groovy/grails/web/taglib/FormTagLibTests.groovy

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,35 @@ public class FormTagLibTests extends AbstractGrailsTagTests {
4646
// use sorted map to be able to predict the order in which tag attributes are generated
4747
def attributes = new TreeMap([url:[controller:'con', action:'action'], id:'formElementId'])
4848
tag.call(attributes, { })
49-
println sw.toString()
5049
assertEquals '<form action="/con/action" method="post" id="formElementId" ></form>', sw.toString().trim()
5150
}
5251
}
5352

53+
void testActionSubmitWhitespace() {
54+
final StringWriter sw = new StringWriter();
55+
final PrintWriter pw = new PrintWriter(sw);
56+
57+
withTag("actionSubmit", pw) { tag ->
58+
// use sorted map to be able to predict the order in which tag attributes are generated
59+
def attributes = new TreeMap([value:'Go'])
60+
tag.call(attributes)
61+
println sw.toString()
62+
assertEquals '<input type="submit" name="_action" value="Go" />', sw.toString() // NO TRIM, TEST WS!
63+
}
64+
}
65+
66+
void testActionSubmitImageWhitespace() {
67+
final StringWriter sw = new StringWriter();
68+
final PrintWriter pw = new PrintWriter(sw);
69+
70+
withTag("actionSubmitImage", pw) { tag ->
71+
// use sorted map to be able to predict the order in which tag attributes are generated
72+
def attributes = new TreeMap([src:'button.gif', value:'Go'])
73+
tag.call(attributes)
74+
assertEquals '<input type="image" name="_action" value="Go" src="button.gif" />', sw.toString() // NO TRIM, TEST WS!
75+
}
76+
}
77+
5478
public void testHtmlEscapingTextAreaTag() {
5579
final StringWriter sw = new StringWriter();
5680
final PrintWriter pw = new PrintWriter(sw);

0 commit comments

Comments
 (0)