提交 b23b3cfa 编写于 作者: O Oleg Nenashev

Merge pull request #1612 from ikedam/feature/JENKINS-27505_TextareaStartsEmptyLine

[JENKINS-27505] Preserve an empty line at the beginning of a textarea
......@@ -89,6 +89,7 @@ THE SOFTWARE.
readonly="${attrs.readonly}"
codemirror-mode="${attrs['codemirror-mode']}"
codemirror-config="${attrs['codemirror-config']}">
<j:if test="${value != null &amp;&amp; !empty(value.toString()) &amp;&amp; (value.toString().codePointAt(0) == 10 || value.toString().codePointAt(0) == 13)}"><j:whitespace>&#10;</j:whitespace></j:if>
<st:out value="${value}" />
</textarea>
<j:if test="${customizedFields != null and attrs.field != null and value != default}">
......
......@@ -14,6 +14,8 @@ import org.kohsuke.stapler.QueryParameter
import javax.inject.Inject
import static org.junit.Assert.*
/**
*
*
......@@ -65,4 +67,62 @@ class TextAreaTest {
}
}
@Issue("JENKINS-27505")
@Test
public void testText() {
T1:{
def TEXT_TO_TEST = "some\nvalue\n";
def p = j.createFreeStyleProject();
def target = new TextareaTestBuilder(TEXT_TO_TEST);
p.buildersList.add(target);
j.configRoundtrip(p);
j.assertEqualDataBoundBeans(target, p.getBuildersList().get(TextareaTestBuilder.class));
}
// test for a textarea beginning with a empty line.
T2:{
def TEXT_TO_TEST = "\nbegin\n\nwith\nempty\nline\n\n";
def p = j.createFreeStyleProject();
def target = new TextareaTestBuilder(TEXT_TO_TEST);
p.buildersList.add(target);
j.configRoundtrip(p);
j.assertEqualDataBoundBeans(target, p.getBuildersList().get(TextareaTestBuilder.class));
}
// test for a textarea beginning with two empty lines.
T3:{
def TEXT_TO_TEST = "\n\nbegin\n\nwith\ntwo\nempty\nline\n\n";
def p = j.createFreeStyleProject();
def target = new TextareaTestBuilder(TEXT_TO_TEST);
p.buildersList.add(target);
j.configRoundtrip(p);
j.assertEqualDataBoundBeans(target, p.getBuildersList().get(TextareaTestBuilder.class));
}
}
public static class TextareaTestBuilder extends Builder {
private text;
@DataBoundConstructor
TextareaTestBuilder(String text) {
this.text = text;
}
public String getText() { return text; }
@TestExtension
public static class DescriptorImpl extends BuildStepDescriptor<Builder> {
@Override
boolean isApplicable(Class<? extends AbstractProject> jobType) {
return true;
}
@Override
String getDisplayName() {
return this.class.name;
}
}
}
}
<!-- no config -->
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
<f:entry field="text" title="${%Text}">
<f:textarea/>
</f:entry>
</j:jelly>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册