[Rt-commit] rt branch, 4.0/default-render-type-fix, updated. rt-4.0.0-188-ga0dc09a
? sunnavy
sunnavy at bestpractical.com
Sun May 8 23:52:52 EDT 2011
The branch, 4.0/default-render-type-fix has been updated
via a0dc09a38e3ae8ecc588ac749c481633d3594f86 (commit)
via 8eb98fa62db4acdb7d13ea5adf7515a1d7f26a31 (commit)
from b7f93b6c522dae1c37bddf89520e81347cd01abc (commit)
Summary of changes:
lib/RT/CustomField.pm | 2 +-
t/api/cf_render_type.t | 49 ++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 50 insertions(+), 1 deletions(-)
create mode 100644 t/api/cf_render_type.t
- Log -----------------------------------------------------------------
commit 8eb98fa62db4acdb7d13ea5adf7515a1d7f26a31
Author: sunnavy <sunnavy at bestpractical.com>
Date: Mon May 9 11:24:23 2011 +0800
we want the render type string, not just if defined
diff --git a/lib/RT/CustomField.pm b/lib/RT/CustomField.pm
index bfb6e54..031fa9e 100644
--- a/lib/RT/CustomField.pm
+++ b/lib/RT/CustomField.pm
@@ -1024,7 +1024,7 @@ sub DefaultRenderType {
my $composite = @_ ? shift : $self->TypeComposite;
my ($type, $max) = split /-/, $composite, 2;
return unless $type and $self->HasRenderTypes($composite);
- return defined $FieldTypes{$type}->{render_types}->{ $max == 1 ? 'single' : 'multiple' }[0];
+ return $FieldTypes{$type}->{render_types}->{ $max == 1 ? 'single' : 'multiple' }[0];
}
=head2 HasRenderTypes [TYPE_COMPOSITE]
commit a0dc09a38e3ae8ecc588ac749c481633d3594f86
Author: sunnavy <sunnavy at bestpractical.com>
Date: Mon May 9 11:39:48 2011 +0800
cf render type test
diff --git a/t/api/cf_render_type.t b/t/api/cf_render_type.t
new file mode 100644
index 0000000..ac09049
--- /dev/null
+++ b/t/api/cf_render_type.t
@@ -0,0 +1,49 @@
+use strict;
+use warnings;
+
+use RT::Test tests => 13;
+
+my $cf = RT::CustomField->new($RT::SystemUser);
+my ( $id, $ret, $msg );
+
+diag "single select";
+( $id, $msg ) = $cf->Create(
+ Name => 'single_select',
+ Type => 'Select',
+ MaxValues => '1',
+ Queue => 0,
+);
+ok( $id, $msg );
+
+is( $cf->RenderType, 'Select box', 'default render type is Select box' );
+( $ret, $msg ) = $cf->SetRenderType('Dropdown');
+ok( $ret, 'changed to Dropdown' );
+is( $cf->RenderType, 'Dropdown', 'render type is indeed updated' );
+
+( $ret, $msg ) = $cf->SetRenderType('List');
+ok( $ret, 'changed to List' );
+is( $cf->RenderType, 'List', 'render type is indeed updated' );
+
+( $ret, $msg ) = $cf->SetRenderType('fakeone');
+ok( !$ret, 'failed to set an invalid render type' );
+is( $cf->RenderType, 'List', 'render type is still List' );
+
+diag "multiple select";
+( $id, $msg ) = $cf->Create(
+ Name => 'multiple_select',
+ Type => 'Select',
+ MaxValues => '0',
+ Queue => 0,
+ RenderType => 'List',
+);
+
+is( $cf->RenderType, 'List', 'set render type to List' );
+( $ret, $msg ) = $cf->SetRenderType('Dropdown');
+ok( !$ret, 'Dropdown is invalid for multiple select' );
+
+is( $cf->RenderType, 'List', 'render type is still List' );
+
+( $ret, $msg ) = $cf->SetRenderType('Select box');
+ok( $ret, 'changed to Select box' );
+is( $cf->RenderType, 'Select box', 'render type is indeed updated' );
+
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list