[Rt-commit] rt branch, 4.0/fix-cf-valuesclass-updates, created. rt-4.0.10-92-g5a792b9
Ruslan Zakirov
ruz at bestpractical.com
Thu Mar 14 09:00:19 EDT 2013
The branch, 4.0/fix-cf-valuesclass-updates has been created
at 5a792b98f740434bc422b6f683d36566d0a74bd4 (commit)
- Log -----------------------------------------------------------------
commit baf212e3f802530e448664da573778c5680f931e
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Thu Mar 14 16:30:45 2013 +0400
ValuesClass was missing from *Accessible
it was changed from attribute to column
diff --git a/lib/RT/CustomField.pm b/lib/RT/CustomField.pm
index 4094dcd..cc20b56 100644
--- a/lib/RT/CustomField.pm
+++ b/lib/RT/CustomField.pm
@@ -2057,6 +2057,8 @@ sub _CoreAccessible {
{read => 1, write => 1, sql_type => -4, length => 0, is_blob => 1, is_numeric => 0, type => 'text', default => ''},
Repeated =>
{read => 1, write => 1, sql_type => 5, length => 6, is_blob => 0, is_numeric => 1, type => 'smallint(6)', default => '0'},
+ ValuesClass =>
+ {read => 1, write => 1, sql_type => 12, length => 64, is_blob => 0, is_numeric => 0, type => 'varchar(64)', default => ''},
BasedOn =>
{read => 1, write => 1, sql_type => 4, length => 11, is_blob => 0, is_numeric => 1, type => 'int(11)', default => ''},
Description =>
commit c5e5ea3958f5313c289c17766109d77ecde90895
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Thu Mar 14 16:32:54 2013 +0400
any false ValuesClass should be valid
RT::CustomField->ValidateValuesClass must allow "0" as
RT::Record->_Set replace undef value by 0
diff --git a/lib/RT/CustomField.pm b/lib/RT/CustomField.pm
index cc20b56..a69c6f4 100644
--- a/lib/RT/CustomField.pm
+++ b/lib/RT/CustomField.pm
@@ -693,7 +693,7 @@ sub ValidateValuesClass {
my $self = shift;
my $class = shift;
- return 1 if !defined $class || $class eq 'RT::CustomFieldValues';
+ return 1 if !$class || $class eq 'RT::CustomFieldValues';
return 1 if grep $class eq $_, RT->Config->Get('CustomFieldValuesSources');
return undef;
}
commit 08aa38d08a87e63f0e67afbc720ef187b8b5123b
Author: Emmanuel Lacour <elacour at easter-eggs.com>
Date: Tue Aug 30 14:22:37 2011 +0200
Fix CF ValuesClass update in web UI
* update only if needed
* display localized update result
diff --git a/share/html/Admin/CustomFields/Modify.html b/share/html/Admin/CustomFields/Modify.html
index 4515ed7..4281d17 100644
--- a/share/html/Admin/CustomFields/Modify.html
+++ b/share/html/Admin/CustomFields/Modify.html
@@ -202,7 +202,15 @@ if ( $ARGS{'Update'} && $id ne 'new' ) {
Object => $CustomFieldObj,
ARGSRef => \%ARGS
);
- $CustomFieldObj->SetValuesClass( $ValuesClass );
+ if ( ($ValuesClass||'RT::CustomFieldValues') ne $CustomFieldObj->ValuesClass ) {
+ my $original = $CustomFieldObj->ValuesClass;
+ my ($good, $msg) = $CustomFieldObj->SetValuesClass( $ValuesClass );
+ if ( $good ) {
+ $msg = loc("[_1] changed from '[_2]' to '[_3]'",
+ loc("Field values source"), $original, $ValuesClass );
+ }
+ push @results, $msg;
+ }
# Set the render type if we have it, but unset it if the new type doesn't
# support render types
commit 5a792b98f740434bc422b6f683d36566d0a74bd4
Author: Emmanuel Lacour <elacour at easter-eggs.com>
Date: Fri Sep 2 17:00:25 2011 +0200
tests around RT::CustomField->SetValuesClass
UI and API
diff --git a/t/customfields/external.t b/t/customfields/external.t
index 62c2cef..7354916 100644
--- a/t/customfields/external.t
+++ b/t/customfields/external.t
@@ -3,7 +3,7 @@ use warnings;
use strict;
use RT;
-use RT::Test nodata => 1, tests => 11;
+use RT::Test nodata => 1, tests => 13;
sub new (*) {
my $class = shift;
@@ -53,3 +53,9 @@ isa_ok( $cf, 'RT::CustomField' );
is( $values->Count, $count, "count is correct" );
}
+{
+ my ($ret, $msg) = $cf->SetValuesClass('RT::CustomFieldValues');
+ ok $ret, 'Reverting this CF as internal source values based' or diag "error: $msg";
+ ($ret, $msg) = $cf->SetValuesClass('RT::CustomFieldValues::Groups');
+ ok $ret, 'Reverting this CF as external source values based' or diag "error: $msg";
+}
diff --git a/t/web/cf_values_class.t b/t/web/cf_values_class.t
new file mode 100644
index 0000000..6466427
--- /dev/null
+++ b/t/web/cf_values_class.t
@@ -0,0 +1,54 @@
+use strict;
+use warnings;
+
+use RT::Test tests => 8;
+
+use constant VALUES_CLASS => 'RT::CustomFieldValues::Groups';
+RT->Config->Set(CustomFieldValuesSources => VALUES_CLASS);
+
+my ($baseurl, $m) = RT::Test->started_ok;
+ok $m->login, 'logged in as root';
+
+my $cf_name = 'test values class';
+
+my $cfid;
+diag "Create a CF";
+{
+ $m->follow_link( id => 'tools-config-custom-fields-create');
+ $m->submit_form(
+ form_name => "ModifyCustomField",
+ fields => {
+ Name => $cf_name,
+ TypeComposite => 'Select-1',
+ LookupType => 'RT::Queue-RT::Ticket',
+ },
+ );
+ $m->content_contains('Object created', 'created Select-1' );
+ $cfid = $m->form_name('ModifyCustomField')->value('id');
+ ok $cfid, "found id of the CF in the form, it's #$cfid";
+}
+
+diag "change to external values class";
+{
+ $m->submit_form(
+ form_name => "ModifyCustomField",
+ fields => { ValuesClass => 'RT::CustomFieldValues::Groups', },
+ button => 'Update',
+ );
+ $m->content_contains(
+ "Field values source changed from 'RT::CustomFieldValues' to 'RT::CustomFieldValues::Groups'",
+ 'changed to external values class' );
+}
+
+diag "change to internal values class";
+{
+ $m->submit_form(
+ form_name => "ModifyCustomField",
+ fields => { ValuesClass => 'RT::CustomFieldValues', },
+ button => 'Update',
+ );
+ $m->content_contains(
+ "Field values source changed from 'RT::CustomFieldValues::Groups' to 'RT::CustomFieldValues'",
+ 'changed to internal values class' );
+}
+
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list