[Rt-commit] rt branch, 4.2/hasentry-for-largecontent, created. rt-4.2.7-8-g6b407b4

Todd Wade todd at bestpractical.com
Thu Sep 11 17:47:51 EDT 2014


The branch, 4.2/hasentry-for-largecontent has been created
        at  6b407b4c426e8a65af5655152cb3f491220ffd58 (commit)

- Log -----------------------------------------------------------------
commit 299dbf2527fb4c6eabf6333da982654b5b9929cf
Author: Todd Wade <todd at bestpractical.com>
Date:   Thu Sep 11 17:00:37 2014 -0400

    add a basic textarea cf test (cf type Text) for issues#30378

diff --git a/t/web/cf_textarea.t b/t/web/cf_textarea.t
new file mode 100644
index 0000000..d11bda4
--- /dev/null
+++ b/t/web/cf_textarea.t
@@ -0,0 +1,75 @@
+use strict;
+use warnings;
+
+use RT::Test tests => 'no_declare';
+
+my $content = join ' ', ('The quick brown fox jumps over the lazy dog.') x 5;
+$content = join "\n\n", $content, $content, $content;
+
+my ($base, $m) = RT::Test->started_ok;
+
+$m->login;
+
+my $ticket = RT::Test->create_ticket(
+    Queue   => 1,
+    Subject => 'a test ticket',
+);
+ok $ticket && $ticket->id, "Created ticket";
+
+my $EditUrl = "/Ticket/Modify.html?id=" . $ticket->id;
+
+my $cfs = {
+    area => {
+        type => 'Text',
+        name => 'TheTextarea',
+    },
+    text => {
+        type => 'FreeformSingle',
+        name => 'TheControlField',
+    },
+};
+
+while ( my( $label, $data ) = each %$cfs ) {
+    my $cf = $data->{obj} = RT::Test->load_or_create_custom_field(
+        Name        => $data->{name},
+        Type        => $data->{type},
+        Queue       => 0,
+        LookupType  => 'RT::Queue-RT::Ticket',
+    );
+    ok $cf && $cf->id, "Created $data->{type} CF";
+
+    # get cf input field name
+    $data->{input} = RT::Interface::Web::GetCustomFieldInputName(
+        Object      => $ticket,
+        CustomField => $cf,
+    );
+}
+
+# open ticket "Basics" page
+$m->get_ok($EditUrl, "Fetched $EditUrl");
+$m->content_contains($_->{name} . ':') for ( values %$cfs );
+
+$m->submit_form_ok({
+    with_fields => {
+        $cfs->{area}{input}            => $content,
+        $cfs->{area}{input} . '-Magic' => "1",
+        $cfs->{text}{input}            => 'value a',
+        $cfs->{text}{input} . '-Magic' => "1",
+    },
+}, 'submitted form to initially set CFs');
+$m->content_contains('<li>TheControlField value a added</li>');
+$m->content_contains("<li>TheTextarea $content added</li>", 'content found');
+
+# http://issues.bestpractical.com/Ticket/Display.html?id=30378
+# #30378: RT 4.2.6 - Very long text fields get updated even when they haven't changed
+$m->submit_form_ok({
+    with_fields => {
+        $cfs->{text}{input}            => 'value b',
+        $cfs->{text}{input} . '-Magic' => "1",
+    },
+}, 'submitted form to initially set CFs');
+$m->content_contains('<li>TheControlField value a changed to value b</li>');
+$m->content_lacks("<li>TheTextarea $content changed to $content</li>", 'textarea wasnt updated');
+
+undef $m;
+done_testing;

commit 6b407b4c426e8a65af5655152cb3f491220ffd58
Author: Todd Wade <todd at bestpractical.com>
Date:   Thu Sep 11 17:31:16 2014 -0400

    Rewite HasEntry logic that determines if new custom field value matches existing value.
    
    _ProcessObjectCustomFieldUpdates calls AddCustomFieldValue with a 'Value'
    parameter unconditionally instead of deciding if it should pass 'LargeContent'
    instead when the content is long enough, so HasEntry always returns false
    for LargeContent data.
    
    This commit makes HasEntry check $value against LargeContent instead of
    expecting $large_content to be passed.
    
    fixes issues#30378

diff --git a/lib/RT/ObjectCustomFieldValues.pm b/lib/RT/ObjectCustomFieldValues.pm
index ec3155d..a33a688 100644
--- a/lib/RT/ObjectCustomFieldValues.pm
+++ b/lib/RT/ObjectCustomFieldValues.pm
@@ -145,15 +145,8 @@ sub HasEntry {
             return $item if lc $item->Content eq lc $args->{Content};
         }
         else {
-            if ( $item->_Value('Content') eq $args->{Content} ) {
-                if ( defined $item->LargeContent ) {
-                    return $item
-                      if defined $args->{LargeContent}
-                      && $item->LargeContent eq $args->{LargeContent};
-                }
-                else {
-                    return $item unless defined $args->{LargeContent};
-                }
+            if ( grep $_ eq $args->{Content}, grep $_, $item->_Value('Content'), $item->LargeContent ) {
+                return $item
             }
         }
     }

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


More information about the rt-commit mailing list