[Rt-commit] rt branch, 4.0/preserve-leading-template-newlines, created. rt-4.0.8-293-g3878a73

Todd Wade todd at bestpractical.com
Thu Dec 20 15:24:42 EST 2012


The branch, 4.0/preserve-leading-template-newlines has been created
        at  3878a73e493aecc3d48e4a11f701bef418358a41 (commit)

- Log -----------------------------------------------------------------
commit 3878a73e493aecc3d48e4a11f701bef418358a41
Author: Todd Wade <todd at bestpractical.com>
Date:   Thu Dec 20 13:46:47 2012 -0500

    Ensure that leading newlines in templates are preserved on submit
    
    2d96251 removed a newline after the opening <textarea> -- however, browsers
    assume that the first newline in a <textarea> is for formatting, and do not
    include it in their submitted value.  This lead to the first newline
     of templates being removed on submit.  See [issues #21152].
    
    The part of the spec that says this is how browsers should behave is
    http://www.w3.org/TR/html4/appendix/notes.html#h-B.3.1
    
    The failing tests included with this commit are TODOed. Current versions of
    WWW::Mechanize do not act as browsers do in this regard.

diff --git a/share/html/Admin/Elements/ModifyTemplate b/share/html/Admin/Elements/ModifyTemplate
index 5746c06..ffb9158 100644
--- a/share/html/Admin/Elements/ModifyTemplate
+++ b/share/html/Admin/Elements/ModifyTemplate
@@ -63,7 +63,8 @@
 </tr>
 <tr>
 <td class="label" valign="top"><&|/l&>Content</&>:</td>
-<td class="value"><textarea name="Content" rows="25" cols="80" wrap="soft"><%$Content||''%></textarea></td>
+<td class="value"><textarea name="Content" rows="25" cols="80" wrap="soft">
+<%$Content||''%></textarea></td>
 </tr>
 </table>
 
diff --git a/t/web/template.t b/t/web/template.t
index a24f741..4a2e6c1 100644
--- a/t/web/template.t
+++ b/t/web/template.t
@@ -1,7 +1,7 @@
 use strict;
 use warnings;
 
-use RT::Test tests => 19;
+use RT::Test tests => 22;
 
 my $user_a = RT::Test->load_or_create_user(
     Name => 'user_a', Password => 'password',
@@ -59,3 +59,35 @@ $m->title_is(q{Modify template Resolved}, 'modifying the Resolved template');
 $m->form_name('ModifyTemplate');
 is($m->value('Type'), 'Perl', 'now that we have ExecuteCode we can update Type to Perl');
 
+{ # 21152: Each time you save a Template a newline is chopped off the front
+  $m->form_name('ModifyTemplate');
+  my $content;
+
+
+  TODO: {
+
+    local $TODO = "WWW::Mechanize doesn't strip newline following <textarea> tag like browsers do";
+    # this test fails because earlier tests add newlines when using Mech
+    like($content = $m->value('Content'), qr/^Subject: Resolved/, 'got expected Content');
+
+  }
+
+  $content = "\n\n\n" . $content;
+  $m->field(Content => $content);
+  $m->submit;
+
+  $m->content_contains('Template Resolved: Content updated');
+
+  # next submit should not result in an update
+  $m->form_name('ModifyTemplate');
+  $m->submit;
+
+  TODO: {
+
+    local $TODO = "WWW::Mechanize doesn't strip newline following <textarea> tag like browsers do";
+    # this test fails because the template change makes Mech continuously add newlines where browsers dont
+    $m->content_lacks('Template Resolved: Content updated');
+
+  }
+}
+

-----------------------------------------------------------------------


More information about the Rt-commit mailing list