[Rt-commit] rt branch, 4.2/custom-field-groupings, updated. rt-4.0.8-488-g349625e

Alex Vandiver alexmv at bestpractical.com
Tue Nov 20 01:46:06 EST 2012


The branch, 4.2/custom-field-groupings has been updated
       via  349625e7309e15777b23f5de4665ed152b507770 (commit)
       via  e084acbb1a129e441984abe07a1b1b7a4778a5c3 (commit)
       via  70b05fc2ef1e56b3c8a5e9321df365939cc8cd97 (commit)
       via  c2eb541ab89b138235951ca74c73ee1cd623323e (commit)
       via  b1cc4054c4e5a76c43e23d3bfad6a7c8b8562027 (commit)
       via  ff5687eee313a66f87394c4a72404b6853b09156 (commit)
      from  a73772e0090f9085d659eb9a4903c546d1d6359a (commit)

Summary of changes:
 lib/RT/Interface/Web.pm      |  15 ++-
 lib/RT/Test/Web.pm           |   2 +-
 share/html/NoAuth/js/late.js |   2 +
 t/web/cf_groupings.t         | 275 +++++++++++++++++++++++++++++++++++++++++++
 t/web/cf_groupings_user.t    | 110 +++++++++++++++++
 t/web/cf_groups.t            | 169 --------------------------
 t/web/cf_groups_users.t      | 120 -------------------
 7 files changed, 399 insertions(+), 294 deletions(-)
 create mode 100644 t/web/cf_groupings.t
 create mode 100644 t/web/cf_groupings_user.t
 delete mode 100644 t/web/cf_groups.t
 delete mode 100644 t/web/cf_groups_users.t

- Log -----------------------------------------------------------------
commit ff5687eee313a66f87394c4a72404b6853b09156
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Mon Nov 19 22:53:38 2012 -0500

    Don't apply change/keyup handlers if the CF only appears once

diff --git a/share/html/NoAuth/js/late.js b/share/html/NoAuth/js/late.js
index 2e846b2..cacf883 100644
--- a/share/html/NoAuth/js/late.js
+++ b/share/html/NoAuth/js/late.js
@@ -65,6 +65,8 @@ jQuery(function() {
         var update_elems = all_inputs.filter(function () {
             return name_filter_regex.test(jQuery(this).attr("name"));
         }).not(elem);
+        if (update_elems.length == 0)
+            return;
         var trigger_func = function() {
             var curval = elem.val();
             if ((elem.attr("type") == "checkbox") || (elem.attr("type") == "radio")) {

commit b1cc4054c4e5a76c43e23d3bfad6a7c8b8562027
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Mon Nov 19 13:11:24 2012 -0500

    Rename groupings tests to not imply groups

diff --git a/t/web/cf_groups.t b/t/web/cf_groupings.t
similarity index 100%
rename from t/web/cf_groups.t
rename to t/web/cf_groupings.t
diff --git a/t/web/cf_groups_users.t b/t/web/cf_groupings_user.t
similarity index 100%
rename from t/web/cf_groups_users.t
rename to t/web/cf_groupings_user.t

commit c2eb541ab89b138235951ca74c73ee1cd623323e
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Mon Nov 19 14:00:38 2012 -0500

    Refactor groupings tests

diff --git a/t/web/cf_groupings.t b/t/web/cf_groupings.t
index c8f493d..8ad241e 100644
--- a/t/web/cf_groupings.t
+++ b/t/web/cf_groupings.t
@@ -3,20 +3,16 @@ use warnings;
 
 use RT::Test tests => undef;
 
+my @groupings = qw/Basics Dates People Links More/;
 RT->Config->Set( 'CustomFieldGroupings',
     'RT::Ticket' => {
-        Basics => ['TestBasics'],
-        Dates  => ['TestDates'],
-        People => ['TestPeople'],
-        Links  => ['TestLinks'],
-        More   => ['TestMore'],
+        map { +($_ => ["Test$_"]) } @groupings,
     },
 );
 
 my %CF;
-
-while ( my ($grouping, $cfs) = each %{ RT->Config->Get('CustomFieldGroupings')->{'RT::Ticket'} } ) {
-    my $name = $cfs->[0];
+for my $grouping (@groupings) {
+    my $name = "Test$grouping";
     my $cf = RT::CustomField->new( RT->SystemUser );
     my ($id, $msg) = $cf->Create(
         Name => $name,
@@ -26,8 +22,7 @@ while ( my ($grouping, $cfs) = each %{ RT->Config->Get('CustomFieldGroupings')->
         Pattern => '^(?!bad value).*$',
     );
     ok $id, "custom field '$name' correctly created";
-    $grouping =~ s/\W//g;
-    $CF{$name} = "$grouping-" . $cf->Id;
+    $CF{$grouping} = $id;
 }
 
 my $queue = RT::Test->load_or_create_queue( Name => 'General' );
@@ -35,6 +30,13 @@ my $queue = RT::Test->load_or_create_queue( Name => 'General' );
 my ( $baseurl, $m ) = RT::Test->started_ok;
 ok $m->login, 'logged in as root';
 
+my %location = (
+    Basics => ".ticket-info-basics",
+    Dates  => ".ticket-info-dates",
+    People => "#ticket-create-message",
+    Links  => ".ticket-info-links",
+    More   => ".ticket-info-cfs",
+);
 {
     note "testing Create";
     $m->goto_create_ticket($queue);
@@ -43,98 +45,61 @@ ok $m->login, 'logged in as root';
     my $dom = $m->dom;
     $m->form_name('TicketCreate');
 
-    my $input_name = $prefix . $CF{'TestBasics'} .'-Value';
-    is $dom->find(qq{input[name="$input_name"]})->size, 1, "only one CF input on the page";
-    ok $dom->at(qq{.ticket-info-basics input[name="$input_name"]}), "CF is in the right place";
-    $m->field( $input_name, 'TestBasicsValue' );
-
-    $input_name = $prefix . $CF{'TestPeople'} .'-Value';
-    is $dom->find(qq{input[name="$input_name"]})->size, 1, "only one CF input on the page";
-    ok $dom->at(qq{#ticket-create-message input[name="$input_name"]}), "CF is in the right place";
-    $m->field( $input_name, 'TestPeopleValue' );
-
-    $input_name = $prefix . $CF{'TestDates'} .'-Value';
-    is $dom->find(qq{input[name="$input_name"]})->size, 1, "only one CF input on the page";
-    ok $dom->at(qq{.ticket-info-dates input[name="$input_name"]}), "CF is in the right place";
-    $m->field( $input_name, 'TestDatesValue' );
-
-    $input_name = $prefix . $CF{'TestLinks'} .'-Value';
-    is $dom->find(qq{input[name="$input_name"]})->size, 1, "only one CF input on the page";
-    ok $dom->at(qq{.ticket-info-links input[name="$input_name"]}), "CF is in the right place";
-    $m->field( $input_name, 'TestLinksValue' );
-
-    $input_name = $prefix . $CF{'TestMore'} .'-Value';
-    is $dom->find(qq{input[name="$input_name"]})->size, 1, "only one CF input on the page";
-    ok $dom->at(qq{.ticket-info-cfs input[name="$input_name"]}), "CF is in the right place";
-    $m->field( $input_name, 'TestMoreValue' );
-
+    for my $grouping (@groupings) {
+        my $input_name = $prefix . "$grouping-$CF{$grouping}-Value";
+        is $dom->find(qq{input[name="$input_name"]})->size, 1, "only one CF input on the page";
+        ok $dom->at(qq{$location{$grouping} input[name="$input_name"]}), "CF is in the right place";
+        $m->field( $input_name, "Test" . $grouping . "Value" );
+    }
     $m->submit;
+}
 
+my $id = $m->get_ticket_id;
+{
     note "testing Display";
-    my $id = $m->get_ticket_id;
     ok $id, "created a ticket";
-    $dom = $m->dom;
+    my $dom = $m->dom;
 
-    foreach my $name ( qw(Basics People Dates Links) ) {
-        my $row_id = 'CF-'. $CF{"Test$name"} .'-ShowRow';
-        $row_id =~ s/^CF-(\w+)-/CF-/;
-        is $dom->find(qq{#$row_id})->size, 1, "CF on the page";
-        is $dom->at(qq{#$row_id})->all_text, "Test$name: Test${name}Value", "value is set";
-        ok $dom->at(qq{.ticket-info-\L$name\E #$row_id}), "CF is in the right place";
-    }
-    {
-        my $row_id = 'CF-'. $CF{"TestMore"} .'-ShowRow';
-        $row_id =~ s/^CF-(\w+)-/CF-/;
+    $location{People} = ".ticket-info-people";
+    foreach my $grouping (@groupings) {
+        my $row_id = "CF-$CF{$grouping}-ShowRow";
         is $dom->find(qq{#$row_id})->size, 1, "CF on the page";
-        is $dom->at(qq{#$row_id})->all_text, "TestMore: TestMoreValue", "value is set";
-        ok $dom->at(qq{.ticket-info-cfs #$row_id}), "CF is in the right place";
+        is $dom->at(qq{#$row_id})->all_text, "Test$grouping: Test${grouping}Value", "value is set";
+        ok $dom->at(qq{$location{$grouping} #$row_id}), "CF is in the right place";
     }
+}
 
-    $prefix = 'Object-RT::Ticket-'. $id .'-CustomField:';
-
+{
     note "testing Basics/People/Dates/Links pages";
-    { # Basics
+    my $prefix = 'Object-RT::Ticket-'. $id .'-CustomField:';
+    { # Basics and More both show up on "Basics"
         $m->follow_link_ok({id => 'page-basics'}, 'Ticket -> Basics');
         is $m->dom->find(qq{input[name^="$prefix"][name\$="-Value"]})->size, 2,
-            "only one CF input on the page";
-        my $input_name = $prefix . $CF{'TestBasics'} .'-Value';
-        ok $m->dom->at(qq{.ticket-info-basics input[name="$input_name"]}),
-            "CF is in the right place";
-        $m->submit_form_ok({
-            with_fields => { $input_name => "TestBasicsChanged" },
-            button      => 'SubmitTicket',
-        });
-        $m->content_like(qr{to TestBasicsChanged});
-
-        $m->submit_form_ok({
-            with_fields => { $input_name => "bad value" },
-            button      => 'SubmitTicket',
-        });
-        $m->content_like(qr{Input must match});
-    }
-    { # Custom group 'More'
-        $m->follow_link_ok({id => 'page-basics'}, 'Ticket -> Basics');
-        my $input_name = $prefix . $CF{'TestMore'} .'-Value';
-        ok $m->dom->at(qq{.ticket-info-cfs input[name="$input_name"]}),
-            "CF is in the right place";
-        $m->submit_form_ok({
-            with_fields => { $input_name => "TestMoreChanged" },
-            button      => 'SubmitTicket',
-        });
-        $m->content_like(qr{to TestMoreChanged});
-
-        $m->submit_form_ok({
-            with_fields => { $input_name => "bad value" },
-            button      => 'SubmitTicket',
-        });
-        $m->content_like(qr{Input must match});
+            "two CF inputs on the page";
+        for my $name (qw/Basics More/) {
+            my $input_name = "$prefix$name-$CF{$name}-Value";
+            ok $m->dom->at(qq{$location{$name} input[name="$input_name"]}),
+                "CF is in the right place";
+            $m->submit_form_ok({
+                with_fields => { $input_name => "Test${name}Changed" },
+                button      => 'SubmitTicket',
+            });
+            $m->content_like(qr{to Test${name}Changed});
+
+            $m->submit_form_ok({
+                with_fields => { $input_name => "bad value" },
+                button      => 'SubmitTicket',
+            });
+            $m->content_like(qr{Input must match});
+        }
     }
 
+    # Everything else gets its own page
     foreach my $name ( qw(People Dates Links) ) {
         $m->follow_link_ok({id => "page-\L$name"}, "Ticket's $name page");
         is $m->dom->find(qq{input[name^="$prefix"][name\$="-Value"]})->size, 1,
             "only one CF input on the page";
-        my $input_name = $prefix . $CF{"Test$name"} .'-Value';
+        my $input_name = "$prefix$name-$CF{$name}-Value";
         $m->submit_form_ok({
             with_fields => { $input_name => "Test${name}Changed" },
             button      => 'SubmitTicket',
@@ -147,14 +112,17 @@ ok $m->login, 'logged in as root';
         });
         $m->content_like(qr{Input must match});
     }
+}
 
+{
     note "testing Jumbo";
+    my $prefix = 'Object-RT::Ticket-'. $id .'-CustomField:';
     $m->follow_link_ok({id => "page-jumbo"}, "Ticket's Jumbo page");
-    $dom = $m->dom;
+    my $dom = $m->dom;
     $m->form_name("TicketModifyAll");
 
     foreach my $name ( qw(Basics People Dates Links More) ) {
-        my $input_name = $prefix . $CF{"Test$name"} .'-Value';
+        my $input_name = "$prefix$name-$CF{$name}-Value";
         is $dom->find(qq{input[name="$input_name"]})->size, 1,
             "only one CF input on the page";
         $m->field( $input_name, "Test${name}Again" );
diff --git a/t/web/cf_groupings_user.t b/t/web/cf_groupings_user.t
index f46477a..74037e1 100644
--- a/t/web/cf_groupings_user.t
+++ b/t/web/cf_groupings_user.t
@@ -37,8 +37,13 @@ while (my ($group,$cfs) = each %{ RT->Config->Get('CustomFieldGroupings')->{'RT:
 my ( $baseurl, $m ) = RT::Test->started_ok;
 ok $m->login, 'logged in as root';
 
-my $index = 1;
-
+my %location = (
+    Identity      => ".user-info-identity",
+    AccessControl => ".user-info-access-control",
+    Location      => ".user-info-location",
+    Phones        => ".user-info-phones",
+    More          => ".user-info-cfs",
+);
 {
     note "testing Create";
     $m->follow_link_ok({id => 'tools-config-users-create'}, 'Create ');
@@ -46,73 +51,58 @@ my $index = 1;
     my $dom = $m->dom;
     $m->form_name('UserCreate');
 
-    $m->field( 'Name', 'user'. $index++ );
+    $m->field( 'Name', 'user1' );
 
     my $prefix = 'Object-RT::User--CustomField:';
-    my $input_name = $prefix . $CF{'TestIdentity'} .'-Value';
-    is $dom->find(qq{input[name="$input_name"]})->size, 1, "only one CF input on the page";
-    ok $dom->at(qq{.user-info-identity input[name="$input_name"]}), "CF is in the right place";
-    $m->field( $input_name, 'TestIdentityValue' );
-
-    $input_name = $prefix . $CF{'TestAccessControl'} .'-Value';
-    is $dom->find(qq{input[name="$input_name"]})->size, 1, "only one CF input on the page";
-    ok $dom->at(qq{.user-info-access-control input[name="$input_name"]}), "CF is in the right place";
-    $m->field( $input_name, 'TestAccessControlValue' );
-
-    $input_name = $prefix . $CF{'TestLocation'} .'-Value';
-    is $dom->find(qq{input[name="$input_name"]})->size, 1, "only one CF input on the page";
-    ok $dom->at(qq{.user-info-location input[name="$input_name"]}), "CF is in the right place";
-    $m->field( $input_name, 'TestLocationValue' );
-
-    $input_name = $prefix . $CF{'TestPhones'} .'-Value';
-    is $dom->find(qq{input[name="$input_name"]})->size, 1, "only one CF input on the page";
-    ok $dom->at(qq{.user-info-phones input[name="$input_name"]}), "CF is in the right place";
-    $m->field( $input_name, 'TestPhonesValue' );
-
-    $input_name = $prefix . $CF{'TestMore'} .'-Value';
-    is $dom->find(qq{input[name="$input_name"]})->size, 1, "only one CF input on the page";
-    ok $dom->at(qq{.user-info-cfs input[name="$input_name"]}), "CF is in the right place";
-    $m->field( $input_name, 'TestMoreValue' );
+    for my $name (keys %location) {
+        my $input_name = $prefix . $CF{"Test$name"} .'-Value';
+        is $dom->find(qq{input[name="$input_name"]})->size, 1, "only one CF input on the page";
+        ok $dom->at(qq{$location{$name} input[name="$input_name"]}), "CF is in the right place";
+        $m->field( $input_name, "Test${name}Value" );
+    }
 
     $m->submit;
     $m->content_like(qr{User created});
-    my ($id) = ($m->uri =~ /id=(\d+)/);
-    ok $id, "found user's id #$id";
+}
+
+my ($id) = ($m->uri =~ /id=(\d+)/);
+ok $id, "found user's id #$id";
 
+{
     note "testing values on Modify page and on the object";
-    {
-        my $user = RT::User->new( RT->SystemUser );
-        $user->Load( $id );
-        ok $user->id, "loaded user";
-
-        $m->form_name('UserModify');
-        foreach my $cf_name ( keys %CF ) {
-            is $user->FirstCustomFieldValue($cf_name), "${cf_name}Value",
-                "correct value of $cf_name CF";
-            my $input = 'Object-RT::User-'. $id .'-CustomField:'
-                . $CF{$cf_name} .'-Value';
-            is $m->value($input), "${cf_name}Value",
-                "correct value in UI";
-            $m->field( $input, "${cf_name}Changed" );
-        }
-        $m->submit;
+    my $user = RT::User->new( RT->SystemUser );
+    $user->Load( $id );
+    ok $user->id, "loaded user";
+
+    my $dom = $m->dom;
+    $m->form_name('UserModify');
+    my $prefix = "Object-RT::User-$id-CustomField:";
+    foreach my $name ( keys %location ) {
+        is $user->FirstCustomFieldValue("Test$name"), "Test${name}Value",
+            "correct value of Test$name CF";
+        my $input_name = $prefix . $CF{"Test$name"} .'-Value';
+        is $m->value($input_name), "Test${name}Value",
+            "correct value in UI";
+        $m->field( $input_name, "Test${name}Changed" );
+        ok $dom->at(qq{$location{$name} input[name="$input_name"]}), "CF is in the right place";
     }
+    $m->submit;
+}
 
+{
     note "testing that update works";
-    {
-        my $user = RT::User->new( RT->SystemUser );
-        $user->Load( $id );
-        ok $user->id, "loaded user";
-
-        $m->form_name('UserModify');
-        foreach my $cf_name ( keys %CF ) {
-            is $user->FirstCustomFieldValue($cf_name), "${cf_name}Changed",
-                "correct value of $cf_name CF";
-            my $input = 'Object-RT::User-'. $id .'-CustomField:'
-                . $CF{$cf_name} .'-Value';
-            is $m->value($input), "${cf_name}Changed",
-                "correct value in UI";
-        }
+    my $user = RT::User->new( RT->SystemUser );
+    $user->Load( $id );
+    ok $user->id, "loaded user";
+
+    $m->form_name('UserModify');
+    my $prefix = "Object-RT::User-$id-CustomField:";
+    foreach my $name ( keys %location ) {
+        is $user->FirstCustomFieldValue("Test$name"), "Test${name}Changed",
+            "correct value of Test$name CF";
+        my $input = $prefix . $CF{"Test$name"} .'-Value';
+        is $m->value($input), "Test${name}Changed",
+            "correct value in UI";
     }
 }
 

commit 70b05fc2ef1e56b3c8a5e9321df365939cc8cd97
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Tue Nov 20 01:19:32 2012 -0500

    Correctly test for different submitted values with select-multiple CFs
    
    The previous comparison code used eq to test the submitted values for
    equality.  This is incorrect in the case of select-multiple CFs, whose
    "Values" key may be an arrayref (or may be a single scalar!).  Descend
    into arrayref values in each key to check for equality.

diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
index a5ea10e..5a7f230 100644
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -2614,10 +2614,17 @@ sub ProcessObjectCustomFieldUpdates {
                 if (@groupings > 1) {
                     # Check for consistency, in case of JS fail
                     for my $key (qw/AddValue Value Values DeleteValues DeleteValueIds/) {
-                        warn "CF $cf submitted with multiple differing $key"
-                            if grep {($custom_fields_to_mod{$class}{$id}{$cf}{$_}{$key} || '')
-                                 ne  ($custom_fields_to_mod{$class}{$id}{$cf}{$groupings[0]}{$key} || '')}
-                                @groupings;
+                        my $base = $custom_fields_to_mod{$class}{$id}{$cf}{$groupings[0]}{$key};
+                        $base = [ $base ] unless ref $base;
+                        for my $grouping (@groupings[1..$#groupings]) {
+                            my $other = $custom_fields_to_mod{$class}{$id}{$cf}{$grouping}{$key};
+                            $other = [ $other ] unless ref $other;
+                            warn "CF $cf submitted with multiple differing values"
+                                if grep {$_} List::MoreUtils::pairwise {
+                                    no warnings qw(uninitialized);
+                                    $a ne $b
+                                } @{$base}, @{$other};
+                        }
                     }
                     # We'll just be picking the 1st grouping in the hash, alphabetically
                 }

commit e084acbb1a129e441984abe07a1b1b7a4778a5c3
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Tue Nov 20 01:22:15 2012 -0500

    Tests for CFs being rendered in more than one location

diff --git a/t/web/cf_groupings.t b/t/web/cf_groupings.t
index 8ad241e..73a07e5 100644
--- a/t/web/cf_groupings.t
+++ b/t/web/cf_groupings.t
@@ -133,5 +133,143 @@ my $id = $m->get_ticket_id;
     }
 }
 
+{
+    note "Reconfigure to place one CF in multiple boxes";
+    $m->no_warnings_ok;
+    RT::Test->stop_server;
+
+    RT->Config->Set( 'CustomFieldGroupings',
+        'RT::Ticket' => {
+            Basics => [ 'TestMore' ],
+            More   => [ 'TestMore' ],
+        },
+    );
+
+    ( $baseurl, $m ) = RT::Test->started_ok;
+    ok $m->login, 'logged in as root';
+}
+
+{
+    note "Testing one CF in multiple boxes";
+    $m->goto_create_ticket($queue);
+
+    my $prefix = 'Object-RT::Ticket--CustomField:';
+    my $dom = $m->dom;
+    $m->form_name('TicketCreate');
+
+    my $cf = $CF{More};
+    is $m->dom->find(qq{input[name^="$prefix"][name\$="-$cf-Value"]})->size, 2,
+        "Two 'More' CF inputs on the page";
+    for my $grouping (qw/Basics More/) {
+        my $input_name = $prefix . "$grouping-$cf-Value";
+        is $dom->find(qq{input[name="$input_name"]})->size, 1, "Found the $grouping grouping";
+        ok $dom->at(qq{$location{$grouping} input[name="$input_name"]}), "CF is in the right place";
+        $m->field( $input_name, "TestMoreValue" );
+    }
+    $m->submit;
+    $m->no_warnings_ok( "Submitting CF with two (identical) values had no warnings" );
+}
+
+$id = $m->get_ticket_id;
+my $ticket = RT::Ticket->new ( RT->SystemUser );
+$ticket->Load( $id );
+is $ticket->CustomFieldValuesAsString( "TestMore", Separator => "|" ), "TestMoreValue",
+    "Value submitted twice is set correctly (and only once)";
+
+my $cf = $CF{More};
+my $prefix = 'Object-RT::Ticket-'. $id .'-CustomField:';
+{
+    note "Updating with multiple appearances of a CF";
+    $m->follow_link_ok({id => 'page-basics'}, 'Ticket -> Basics');
+
+    is $m->dom->find(qq{input[name^="$prefix"][name\$="-$cf-Value"]})->size, 2,
+        "Two 'More' CF inputs on the page";
+    my @inputs;
+    for my $grouping (qw/Basics More/) {
+        my $input_name =  "$prefix$grouping-$cf-Value";
+        push @inputs, $input_name;
+        ok $m->dom->at(qq{$location{$grouping} input[name="$input_name"]}),
+            "CF is in the right place";
+    }
+    $m->submit_form_ok({
+        with_fields => {
+            map {+($_ => "TestMoreChanged")} @inputs,
+        },
+        button => 'SubmitTicket',
+    });
+    $m->no_warnings_ok;
+    $m->content_like(qr{to TestMoreChanged});
+
+    $ticket->Load( $id );
+    is $ticket->CustomFieldValuesAsString( "TestMore", Separator => "|" ), "TestMoreChanged",
+        "Updated value submitted twice is set correctly (and only once)";
+}
+
+{
+    note "Updating with _differing_ values in multiple appearances of a CF";
+
+    my %inputs = map {+($_ => "$prefix$_-$cf-Value")} qw/Basics More/;
+    $m->submit_form_ok({
+        with_fields => {
+            $inputs{Basics} => "BasicsValue",
+            $inputs{More}   => "MoreValue",
+        },
+        button => 'SubmitTicket',
+    });
+    $m->warning_like(qr{CF $cf submitted with multiple differing values});
+    $m->content_like(qr{to BasicsValue}, "Arbitrarily chose first value");
+
+    $ticket->Load( $id );
+    is $ticket->CustomFieldValuesAsString( "TestMore", Separator => "|" ), "BasicsValue",
+        "Conflicting value submitted twice is set correctly (and only once)";
+}
+
+{
+    note "Configuring CF to be a select-multiple";
+    my $custom_field = RT::CustomField->new( RT->SystemUser );
+    $custom_field->Load( $cf );
+    $custom_field->SetType( "Select" );
+    $custom_field->SetMaxValues( 0 );
+    $custom_field->AddValue( Name => $_ ) for 1..9;
+}
+
+{
+    note "Select multiples do not interfere with each other when appearing multiple times";
+    $m->follow_link_ok({id => 'page-basics'}, 'Ticket -> Basics');
+
+    $m->form_name('TicketModify');
+    my %inputs = map {+($_ => "$prefix$_-$cf-Values")} qw/Basics More/;
+    ok $m->dom->at(qq{select[name="$inputs{Basics}"]}), "Found 'More' CF in Basics box";
+    ok $m->dom->at(qq{select[name="$inputs{More}"]}),   "Found 'More' CF in More box";
+
+    $m->select( $inputs{Basics} => [1, 3, 9] );
+    $m->select( $inputs{More}   => [1, 3, 9] );
+    $m->click( 'SubmitTicket' );
+    $m->no_warnings_ok;
+    $m->content_like(qr{$_ added as a value for TestMore}) for 1, 3, 9;
+    $m->content_like(qr{BasicsValue is no longer a value for custom field TestMore});
+
+    $ticket->Load( $id );
+    is $ticket->CustomFieldValuesAsString( "TestMore", Separator => "|" ), "1|3|9",
+        "Multi-select values submitted correctly";
+}
+
+{
+    note "Submit multiples correctly choose one set of values when conflicting information is submitted";
+    $m->form_name('TicketModify');
+    my %inputs = map {+($_ => "$prefix$_-$cf-Values")} qw/Basics More/;
+    $m->select( $inputs{Basics} => [2, 3, 4] );
+    $m->select( $inputs{More}   => [8, 9] );
+    $m->click( 'SubmitTicket' );
+    $m->warning_like(qr{CF $cf submitted with multiple differing values});
+    $m->content_like(qr{$_ added as a value for TestMore}) for 2, 4;
+    $m->content_unlike(qr{$_ added as a value for TestMore}) for 8;
+    $m->content_like(qr{$_ is no longer a value for custom field TestMore}) for 1, 9;
+
+    $ticket->Load( $id );
+    is $ticket->CustomFieldValuesAsString( "TestMore", Separator => "|" ), "3|2|4",
+        "Multi-select values submitted correctly";
+}
+
 undef $m;
 done_testing;

commit 349625e7309e15777b23f5de4665ed152b507770
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Tue Nov 20 01:25:16 2012 -0500

    Adjust a regex to match the new grouping style
    
    Though this method (nor set_custom_field, which calls it) is not called
    in core RT's tests, it is used in RTIR.

diff --git a/lib/RT/Test/Web.pm b/lib/RT/Test/Web.pm
index f36ee23..2b19aea 100644
--- a/lib/RT/Test/Web.pm
+++ b/lib/RT/Test/Web.pm
@@ -345,7 +345,7 @@ sub custom_field_input {
     my $cf_id = $cf_obj->id;
     
     my ($res) =
-        grep /^Object-RT::Ticket-\d*-CustomField-$cf_id-Values?$/,
+        grep /^Object-RT::Ticket-\d*-CustomField(?::\w+)?-$cf_id-Values?$/,
         map $_->name,
         $self->current_form->inputs;
     unless ( $res ) {

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


More information about the Rt-commit mailing list