[Rt-commit] rt branch, 4.2/removing-image-cf-values, created. rt-4.1.6-243-g4b91b3c

Thomas Sibley trs at bestpractical.com
Mon Feb 11 20:47:11 EST 2013


The branch, 4.2/removing-image-cf-values has been created
        at  4b91b3c9ed983cfc3cff5aa8bd78cf43fe4e9f55 (commit)

- Log -----------------------------------------------------------------
commit b8dcceec67c985169601c986d59200d5bc782406
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Mon Feb 11 16:12:35 2013 -0800

    Failing tests showing that removing values for an image CF is broken
    
    Broken by 6a9d0bf.

diff --git a/t/web/cf_image.t b/t/web/cf_image.t
new file mode 100644
index 0000000..54d54f2
--- /dev/null
+++ b/t/web/cf_image.t
@@ -0,0 +1,61 @@
+use strict;
+use warnings;
+
+use RT::Test tests => 'no_declare';
+
+my (undef, $m) = RT::Test->started_ok;
+$m->login;
+$m->follow_link( id => 'tools-config-custom-fields-create' );
+$m->submit_form_ok({
+    form_name => "ModifyCustomField",
+    fields    => {
+        Name          => 'Images',
+        TypeComposite => 'Image-1',
+        LookupType    => 'RT::Queue-RT::Ticket',
+    },
+});
+$m->content_contains("Object created");
+my $cfid = $m->form_name('ModifyCustomField')->value('id');
+ok $cfid, "Created CF correctly";
+
+$m->follow_link_ok( {id => "page-applies-to"} );
+$m->form_with_fields( "AddCustomField-1" );
+$m->tick( "AddCustomField-1", 0 );
+$m->click_ok( "UpdateObjs" );
+$m->content_contains("Object created");
+
+
+$m->submit_form_ok({
+    form_name => "CreateTicketInQueue",
+    fields    => { Queue => 'General' },
+});
+$m->content_contains("Upload one image");
+$m->submit_form_ok({
+    form_name => "TicketCreate",
+    fields    => {
+        Subject => 'Test ticket',
+        Content => 'test',
+    },
+});
+$m->content_like( qr/Ticket \d+ created/,
+                  "a ticket is created succesfully" );
+
+$m->follow_link_ok( {id => "page-basics"} );
+$m->content_contains("Upload one image");
+$m->submit_form_ok({
+    form_name => "TicketModify",
+    fields    => {
+        "Object-RT::Ticket-1-CustomField-1-Upload" =>
+            RT::Test::get_relocatable_file('bpslogo.png', '..', 'data'),
+    },
+});
+$m->content_contains("bpslogo.png added");
+$m->content_contains("/Download/CustomFieldValue/1/bpslogo.png");
+
+$m->form_name("TicketModify");
+$m->tick("Object-RT::Ticket-1-CustomField-1-DeleteValueIds", 1);
+$m->click_ok("SubmitTicket");
+$m->content_lacks("/Download/CustomFieldValue/1/bpslogo.png");
+
+undef $m;
+done_testing;

commit 4b91b3c9ed983cfc3cff5aa8bd78cf43fe4e9f55
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Mon Feb 11 17:10:55 2013 -0800

    Process image/file CF uploads from "-Upload" params only
    
    Other CF param actions, such as "-DeleteValuesId", should be processed
    normally as they do not contain upload data.  The upload logic was made
    too general by the refactoring in 6a9d0bf.
    
    Restrictions on the CF type to Image or Binary still apply since we
    don't want to allow arbitrary CF types to store upload data.
    
    This commit makes the newly added t/web/cf_image.t pass.

diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
index 819ceba..b2fb18b 100644
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -2990,7 +2990,10 @@ sub ProcessObjectCustomFieldUpdatesForCreate {
 }
 
 sub _NormalizeObjectCustomFieldValue {
-    my %args    = (@_);
+    my %args    = (
+        Param   => "",
+        @_
+    );
     my $cf_type = $args{CustomField}->Type;
     my @values  = ();
 
@@ -3010,7 +3013,7 @@ sub _NormalizeObjectCustomFieldValue {
         }
         grep defined, @values;
 
-    if ($cf_type eq 'Image' or $cf_type eq 'Binary') {
+    if ($args{'Param'} =~ /-Upload$/ and $cf_type =~ /^(Image|Binary)$/) {
         @values = _UploadedFile( $args{'Param'} ) || ();
     }
 

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


More information about the Rt-commit mailing list