[Rt-commit] rt branch, 4.4/queue-create-sla, created. rt-4.4.0-113-g76b52c9

Shawn Moore shawn at bestpractical.com
Wed May 11 16:21:16 EDT 2016


The branch, 4.4/queue-create-sla has been created
        at  76b52c98666697b75a96803015f5e68b1100ced8 (commit)

- Log -----------------------------------------------------------------
commit bb98a591f2219f566a074d7c4a89264ffba07208
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Wed Oct 24 23:24:36 2012 +0800

    remove the unnecessary "\" because browsers ignore the first newline
    
    see also #21152

diff --git a/share/html/Elements/MessageBox b/share/html/Elements/MessageBox
index df858b1..9e98f8b 100644
--- a/share/html/Elements/MessageBox
+++ b/share/html/Elements/MessageBox
@@ -45,7 +45,7 @@
 %# those contributions and any derivatives thereof.
 %#
 %# END BPS TAGGED BLOCK }}}
-<textarea autocomplete="off" class="messagebox <% $Type eq 'text/html' ? 'richtext' : '' %>" <% $width_attr %>="<% $Width %>" rows="<% $Height %>" <% $wrap_type |n %> name="<% $Name %>" id="<% $Name %>">\
+<textarea autocomplete="off" class="messagebox <% $Type eq 'text/html' ? 'richtext' : '' %>" <% $width_attr %>="<% $Width %>" rows="<% $Height %>" <% $wrap_type |n %> name="<% $Name %>" id="<% $Name %>">
 % $m->comp('/Articles/Elements/IncludeArticle', %ARGS) if $IncludeArticle;
 % $m->callback( %ARGS, SignatureRef => \$signature, DefaultRef => \$Default, MessageRef => $message );
 % if (RT->Config->Get("SignatureAboveQuote", $session{'CurrentUser'})) {

commit c139f25ee5d5f1fd5ff8a80cde20dc38afe20eda
Author: Alex Vandiver <alex at chmrr.net>
Date:   Fri May 6 01:59:27 2016 -0700

    Tweak spaces around signature to provide useful default whitespace
    
    Most signatures don't have trailing newlines, additional newlines are
    necessary after the signature to give whitespace before showing the
    quote.  Additionally, having a blank line (or two) before the "-- \n"
    means there's an obvious place to click and start typing.  With
    signature-before-quote, this now gives (all examples use "." for a blank
    line):
        .
        .
         --
         Foo
         Bar
        .
         On Oct 18, you wrote:
         > ...
    
    This provides a blank line to click on and begin to type, as well as a
    blank line thereafter to separate the quote from the signature.
    
    With the standard signature-after setting, this now gives:
         On Oct 18, you wrote:
         > ...
        .
        .
        .
         --
         Foo
         Bar
    
    ...providing three blank lines in the middle.  This allows the user to
    click on the second one and start typing, but leave whitespace before
    and after their response.  Finally, if there's nothing to quote,
    regardless of the preference:
        .
        .
         --
         Foo
         Bar
    
    ..with a similar click-on-the-first-line use case as described above.
    All of the same behavior is preserved when HTML editing is enabled.

diff --git a/lib/RT/Transaction.pm b/lib/RT/Transaction.pm
index 9fc3211..9afdedf 100644
--- a/lib/RT/Transaction.pm
+++ b/lib/RT/Transaction.pm
@@ -400,12 +400,12 @@ sub Content {
                 . $self->QuoteHeader
                 . '<br /><blockquote class="gmail_quote" type="cite">'
                 . $content
-                . '</blockquote></div><br /><br />';
+                . '</blockquote></div>';
         } else {
             $content = $self->ApplyQuoteWrap(content => $content,
                                              cols    => $args{'Wrap'} );
 
-            $content = $self->QuoteHeader . "\n$content\n\n";
+            $content = $self->QuoteHeader . "\n$content";
         }
     }
 
diff --git a/share/html/Elements/MessageBox b/share/html/Elements/MessageBox
index 9e98f8b..78753ab 100644
--- a/share/html/Elements/MessageBox
+++ b/share/html/Elements/MessageBox
@@ -74,9 +74,10 @@ if ( $QuoteTransaction ) {
     $message = $transaction->Content( Quote => 1, Type  => $Type );
 }
 
-my $signature = '';
-if ( $IncludeSignature and my $text = $session{'CurrentUser'}->UserObj->Signature ) {
-    $signature = "-- \n". $text;
+my $signature = $session{'CurrentUser'}->UserObj->Signature // "";
+if ( $IncludeSignature and $signature =~ /\S/ ) {
+    $signature =~ s/\n*$//;
+
     if ($Type eq 'text/html') {
         $signature =~ s/&/&/g;
         $signature =~ s/</</g;
@@ -84,8 +85,20 @@ if ( $IncludeSignature and my $text = $session{'CurrentUser'}->UserObj->Signatur
         $signature =~ s/"/"/g;  # "//;
         $signature =~ s/'/'/g;   # '//;
         $signature =~ s{\n}{<br />}g;
-        $signature = "<p>$signature</p>";
+        $signature = "<br /><p>-- <br />$signature</p>";
+    } else {
+        $signature = "\n\n-- \n". $signature . "\n";
+    }
+
+    if ($message =~ /\S/) {
+        if (RT->Config->Get('SignatureAboveQuote', $session{CurrentUser})) {
+            $signature .= $Type eq 'text/html' ? "<br />" : "\n";
+        } else {
+            $signature = ($Type eq 'text/html' ? "" : "\n") . $signature;
+        }
     }
+} else {
+    $signature = '';
 }
 
 # wrap="something" seems to really break IE + richtext
diff --git a/t/web/search_bulk_update_links.t b/t/web/search_bulk_update_links.t
index d9b477e..c272345 100644
--- a/t/web/search_bulk_update_links.t
+++ b/t/web/search_bulk_update_links.t
@@ -79,11 +79,13 @@ $m->content_lacks( 'DeleteLink--', 'no delete link stuff' );
 $m->form_name('BulkUpdate');
 my @fields = qw/Owner AddRequestor DeleteRequestor AddCc DeleteCc AddAdminCc
 DeleteAdminCc Subject Priority Queue Status Starts_Date Told_Date Due_Date
-UpdateSubject UpdateContent/;
+UpdateSubject/;
 for my $field ( @fields ) {
     is( $m->value($field), '', "default $field is empty" );
 }
 
+like( $m->value('UpdateContent'), qr/^\s*$/, "default UpdateContent is effectively empty" );
+
 # test DependsOn, MemberOf and RefersTo
 $m->submit_form(
     form_name => 'BulkUpdate',
diff --git a/t/web/signatures.t b/t/web/signatures.t
new file mode 100644
index 0000000..becc1f9
--- /dev/null
+++ b/t/web/signatures.t
@@ -0,0 +1,162 @@
+use strict;
+use warnings;
+
+use RT::Test tests => undef;
+use HTML::Entities qw/decode_entities/;
+
+# Remove the timestamp from the quote header
+{
+    no warnings 'redefine';
+    *RT::Transaction::QuoteHeader = sub { "Someone wrote:" };
+}
+
+my ($baseurl, $m) = RT::Test->started_ok;
+ok( $m->login, 'logged in' );
+
+my $root = RT::Test->load_or_create_user( Name => 'root' );
+my ($ok) = $root->SetSignature("Signature one\nSignature two\n");
+ok($ok, "Set signature");
+
+my $t = RT::Test->create_ticket(
+    Queue   => 'General',
+    Subject => 'Signature quoting',
+    Content => "First\nSecond\nThird\n",
+);
+
+my $initial = $t->Transactions->First->id;
+
+sub template_is {
+    my (%args) = (
+        HTML        => 0,
+        Quote       => 0,
+        BeforeQuote => 0,
+    );
+    my $expected = pop(@_);
+    $args{$_}++ for @_;
+
+    my $prefs = $root->Preferences($RT::System);
+    $prefs->{SignatureAboveQuote} = $args{BeforeQuote};
+    $prefs->{MessageBoxRichText}  = $args{HTML};
+    ($ok) = $root->SetPreferences($RT::System, $prefs);
+    ok($ok, "Preferences updated");
+
+    my $url = "/Ticket/Update.html?id=" . $t->id;
+    $url .= "&QuoteTransaction=$initial" if $args{Quote};
+    $m->get_ok($url);
+
+    $m->form_name('TicketUpdate');
+    my $value = $m->value("UpdateContent");
+
+    # Work around a bug in Mechanize, wherein it thinks newlines
+    # following textareas are significant -- browsers do not.
+    $value =~ s/^\n//;
+
+    # For ease of interpretation, replace blank lines with dots, and
+    # put a $ after trailing whitespace.
+    my $display = $value;
+    $display =~ s/^$/./mg;
+    $display =~ s/([ ]+)$/$1\$/mg;
+
+    is($display, $expected, "Content matches expected");
+
+    my $trim = RT::Interface::Web::StripContent(
+        CurrentUser    => RT::CurrentUser->new($root),
+        Content        => $value,
+        ContentType    => $args{HTML} ? "text/html" : "text/plain",
+        StripSignature => 1,
+    );
+    if ($args{Quote}) {
+        ok($trim, "Counts as not empty");
+    } else {
+        is($trim, '', "Counts as empty");
+    }
+}
+
+
+### Text
+
+subtest "Non-HTML, no reply" => sub {
+    template_is(<<'EOT') };
+.
+.
+-- $
+Signature one
+Signature two
+EOT
+
+
+subtest "Non-HTML, no reply, before quote (which is irrelevant)" => sub {
+    template_is(qw/BeforeQuote/, <<'EOT') };
+.
+.
+-- $
+Signature one
+Signature two
+EOT
+
+subtest "Non-HTML, reply" => sub {
+    template_is(qw/Quote/, <<'EOT') };
+Someone wrote:
+> First
+> Second
+> Third
+.
+.
+.
+-- $
+Signature one
+Signature two
+EOT
+
+subtest "Non-HTML, reply, before quote" => sub {
+    template_is(qw/Quote BeforeQuote/, <<'EOT') };
+.
+.
+-- $
+Signature one
+Signature two
+.
+Someone wrote:
+> First
+> Second
+> Third
+EOT
+
+
+
+### HTML
+
+my $quote = '<div class="gmail_quote">Someone wrote:<br />'
+    .'<blockquote class="gmail_quote" type="cite">'
+    .'<pre style="white-space: pre-wrap; font-family: monospace;">'
+    ."First\nSecond\nThird\n"
+    .'</pre></blockquote></div>';
+
+subtest "HTML, no reply" => sub {
+    template_is(
+        qw/HTML/,
+        '<br /><p>-- <br />Signature one<br />Signature two</p>',
+    ) };
+
+subtest "HTML, no reply, before quote (which is irrelevant)" => sub {
+    template_is(
+        qw/HTML BeforeQuote/,
+        '<br /><p>-- <br />Signature one<br />Signature two</p>',
+    ) };
+
+subtest "HTML, reply" => sub {
+    template_is(
+        qw/HTML Quote/,
+        $quote.'<br /><p>-- <br />Signature one<br />Signature two</p>',
+    ) };
+
+subtest "HTML, reply, before quote" => sub {
+    template_is(
+        qw/HTML Quote BeforeQuote/,
+        '<br /><p>-- <br />Signature one<br />Signature two</p>'
+            . "<br />" . $quote,
+    ) };
+
+
+undef $m;
+done_testing;

commit 1e9fbb6d0bbb806b48a15bb1574aab9a5864b2b8
Author: rachelkelly <rachel at bestpractical.com>
Date:   Thu May 5 07:05:25 2016 +0000

    Fix failing FastCGI tests by changing how timestamps are removed from quote header
    
        t/web/signatures.t, introduced in
        9df4d3387e22754f160a5aba91f2e25381309b45, overrode the
        RT::Transaction::QuoteHeader method to replace the quote header text "On
        $date at $time, $person wrote:" with "Someone wrote:" to simplify the
        test cases. This solution works in most development environments but
        fails in a client/server environment like FastCGI. By the time this
        method override happens, the server and client processes have already
        forked, so it's simply too late for the test file to redefine methods in
        the server. This led to the test failures because the server output the
        stock "On $date at $time, $person wrote:" instead of the
        simplified-for-tests "Someone wrote:" header.
    
        This commit fixes the test by removing the method override and instead
        replacing the "On $date at $time, $person wrote:" with a regex
        substitution on the output. In this way is not only agnostic to the test
        environment, it is also more insulated from future changes (such as
        RT::Transaction method QuoteHeader being refactored away).

diff --git a/t/web/signatures.t b/t/web/signatures.t
index becc1f9..919e1e6 100644
--- a/t/web/signatures.t
+++ b/t/web/signatures.t
@@ -4,12 +4,6 @@ use warnings;
 use RT::Test tests => undef;
 use HTML::Entities qw/decode_entities/;
 
-# Remove the timestamp from the quote header
-{
-    no warnings 'redefine';
-    *RT::Transaction::QuoteHeader = sub { "Someone wrote:" };
-}
-
 my ($baseurl, $m) = RT::Test->started_ok;
 ok( $m->login, 'logged in' );
 
@@ -57,6 +51,9 @@ sub template_is {
     $display =~ s/^$/./mg;
     $display =~ s/([ ]+)$/$1\$/mg;
 
+    # Remove the timestamp from the quote header
+    $display =~ s/On \w\w\w \w\w\w+ \d\d \d\d:\d\d:\d\d \d\d\d\d, \w+ wrote:/Someone wrote:/;
+
     is($display, $expected, "Content matches expected");
 
     my $trim = RT::Interface::Web::StripContent(

commit 0f4275471f75823460eea52a3105c05902ca5a10
Author: Shawn M Moore <shawn at bestpractical.com>
Date:   Wed May 11 20:18:57 2016 +0000

    Failing tests for setting SLA during RT::Queue->Create

diff --git a/t/api/queue.t b/t/api/queue.t
index 71efb4d..e3c4fd2 100644
--- a/t/api/queue.t
+++ b/t/api/queue.t
@@ -2,7 +2,21 @@
 use strict;
 use warnings;
 use RT;
-use RT::Test nodata => 1, tests => undef;
+use RT::Test nodata => 1, tests => undef, config => <<'CONFIG';
+Set( %ServiceAgreements, (
+    Default => 'standard',
+    Levels => {
+        'standard' => {
+            Starts => { RealMinutes => 0 },
+            Resolve => { RealMinutes => 8*60 },
+        },
+        'urgent' => {
+            Starts => { RealMinutes => 0 },
+            Resolve => { RealMinutes => 2*60 },
+        },
+    },
+));
+CONFIG
 
 
 {
@@ -86,4 +100,19 @@ ok ($group->Id, "Found the AdminCc object for this Queue");
 
 }
 
+{
+    my $NoSLA = RT::Queue->new(RT->SystemUser);
+    my ($id, $msg) = $NoSLA->Create(Name => "NoSLA");
+    ok($id, "created queue NoSLA");
+    is($NoSLA->SLA, undef, 'No SLA for NoSLA');
+
+    my $WithSLA = RT::Queue->new(RT->SystemUser);
+    ($id, $msg) = $WithSLA->Create(Name => "WithSLA", SLA => 'urgent');
+    ok($id, "created queue WithSLA");
+    is($WithSLA->SLA, 'urgent', 'SLA is set');
+
+    $WithSLA->SetSLA('standard');
+    is($WithSLA->SLA, 'standard', 'SLA is updated');
+}
+
 done_testing;

commit 76b52c98666697b75a96803015f5e68b1100ced8
Author: Shawn M Moore <shawn at bestpractical.com>
Date:   Wed May 11 20:14:58 2016 +0000

    Allow setting SLA in RT::Queue->Create
    
    Fixes: I#31823

diff --git a/lib/RT/Queue.pm b/lib/RT/Queue.pm
index b3940b3..2a80a6c 100644
--- a/lib/RT/Queue.pm
+++ b/lib/RT/Queue.pm
@@ -159,6 +159,7 @@ sub Create {
         Sign              => undef,
         SignAuto          => undef,
         Encrypt           => undef,
+        SLA               => undef,
         _RecordTransaction => 1,
         @_
     );
@@ -198,7 +199,7 @@ sub Create {
     }
     $RT::Handle->Commit;
 
-    for my $attr (qw/Sign SignAuto Encrypt/) {
+    for my $attr (qw/Sign SignAuto Encrypt SLA/) {
         next unless defined $args{$attr};
         my $set = "Set" . $attr;
         my ($status, $msg) = $self->$set( $args{$attr} );

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


More information about the rt-commit mailing list