[Rt-commit] r8305 - in rt/branches/3.7-EXPERIMENTAL-TUNIS: t/web
ruz at bestpractical.com
ruz at bestpractical.com
Thu Jul 26 19:00:12 EDT 2007
Author: ruz
Date: Thu Jul 26 19:00:12 2007
New Revision: 8305
Modified:
rt/branches/3.7-EXPERIMENTAL-TUNIS/html/Elements/EditCustomFieldSelect
rt/branches/3.7-EXPERIMENTAL-TUNIS/t/web/cf_select_one.t
Log:
* make sure that 0 value is not selected instead of 'no value'
Modified: rt/branches/3.7-EXPERIMENTAL-TUNIS/html/Elements/EditCustomFieldSelect
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL-TUNIS/html/Elements/EditCustomFieldSelect (original)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/html/Elements/EditCustomFieldSelect Thu Jul 26 19:00:12 2007
@@ -82,6 +82,7 @@
</%ARGS>
<%METHOD options>
+% @Default = grep defined && length, @Default;
% my $selected;
% my $CFVs = $CustomField->Values;
% my @levels;
@@ -106,7 +107,7 @@
% push @levels, $level;
% }
<option value="<% $name %>"
-% if ( grep( ( $_ || '') eq ( $name || '') , @Default )
+% if ( ( grep $_ eq $name, @Default )
% || ( $Values && $Values->HasEntry( $name ) ) )
% {
% $$SelectedRef = 1;
Modified: rt/branches/3.7-EXPERIMENTAL-TUNIS/t/web/cf_select_one.t
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL-TUNIS/t/web/cf_select_one.t (original)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/t/web/cf_select_one.t Thu Jul 26 19:00:12 2007
@@ -3,7 +3,7 @@
use strict;
use warnings;
-use Test::More tests => 33;
+use Test::More tests => 41;
use RT::Test;
my ($baseurl, $m) = RT::Test->started_ok;
@@ -134,3 +134,27 @@
'0', 'API returns correct value';
}
+diag "check that we can set empty value when the current is 0"
+ if $ENV{'TEST_VERBOSE'};
+{
+ ok $m->goto_ticket( $tid ), "opened ticket's page";
+ $m->follow_link( text => 'Custom Fields' );
+ $m->title_like(qr/Modify ticket/i, 'modify ticket');
+ $m->content_like(qr/\Q$cf_name/, 'CF on the page');
+
+ my $value = $m->form_number(3)->value("Object-RT::Ticket-$tid-CustomField-$cfid-Values");
+ is lc $value, '0', 'correct value is selected';
+ $m->select("Object-RT::Ticket-$tid-CustomField-$cfid-Values" => '' );
+ $m->submit;
+ $m->content_like(qr/0 is no longer a value for custom field/mi, '0 is no longer a value');
+
+ $value = $m->form_number(3)->value("Object-RT::Ticket-$tid-CustomField-$cfid-Values");
+ is $value, '', '(no value) is selected';
+
+ my $ticket = RT::Ticket->new( $RT::SystemUser );
+ $ticket->Load( $tid );
+ ok $ticket->id, 'loaded the ticket';
+ is $ticket->FirstCustomFieldValue( $cf_name ),
+ undef, 'API returns correct value';
+}
+
More information about the Rt-commit
mailing list