Skip to content
Permalink
Browse files

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

…artsEmptyLine

[JENKINS-27505] Preserve an empty line at the beginning of a textarea
  • Loading branch information...
oleg-nenashev committed Nov 15, 2015
2 parents 0fe7c69 + f0a88e6 commit b23b3cfae4a03ede423389c84f0a5b56d07dc1da
@@ -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;
}
}

}
}
@@ -0,0 +1,7 @@
<!-- 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>

0 comments on commit b23b3cf

Please sign in to comment.
You can’t perform that action at this time.