[Rt-commit] rt branch, 4.4/custom-field-disable-enable-msg, created. rt-4.2.11-168-g29c0402
Dustin Graves
dustin at bestpractical.com
Tue Aug 18 13:12:48 EDT 2015
The branch, 4.4/custom-field-disable-enable-msg has been created
at 29c04025c19786466ecd975c6d91ee9f0166b798 (commit)
- Log -----------------------------------------------------------------
commit 29c04025c19786466ecd975c6d91ee9f0166b798
Author: Dustin Graves <dustin at bestpractical.com>
Date: Thu Aug 13 19:42:34 2015 +0000
Change Custom Field disable/enable message to be friendlier
e.g. CustomField Foo: Disabled changed from (no value) to "1" ==>
CustomField Foo: Disabled
CustomField Foo: Disabled changed from "1" to "0" ==>
CustomField Foo: Enabled
Fixes: I#31141
diff --git a/lib/RT/CustomField.pm b/lib/RT/CustomField.pm
index 39b90b9..0c594f2 100644
--- a/lib/RT/CustomField.pm
+++ b/lib/RT/CustomField.pm
@@ -1084,6 +1084,22 @@ Takes a boolean.
=cut
+sub SetDisabled {
+ my $self = shift;
+ my $val = shift;
+
+ my ($status, $msg) = $self->_Set(Field => 'Disabled', Value => $val);
+
+ unless ($status) {
+ return ($status, $msg);
+ }
+
+ if ( $val == 1 ) {
+ return (1, $self->loc("Disabled"));
+ } else {
+ return (1, $self->loc("Enabled"));
+ }
+}
=head2 SetTypeComposite
diff --git a/t/api/customfield.t b/t/api/customfield.t
index df8f66d..265af97 100644
--- a/t/api/customfield.t
+++ b/t/api/customfield.t
@@ -368,7 +368,14 @@ like($cf->Description, qr/Queue/, "Specify Queue => 1 and IncludeGlobal and get
# Disable one of them
($ok, $msg) = $cf->SetDisabled(1);
+is($msg, "Disabled", "Disabling custom field gives correct message");
ok($ok, "Disabled the Queue-specific one");
+($ok, $msg) = $cf->SetDisabled(0);
+is($msg, "Enabled", "Enabling custom field gives correct message");
+ok($ok, "Enabled the Queue-specific one");
+($ok, $msg) = $cf->SetDisabled(1);
+is($msg, "Disabled", "Disabling custom field again gives correct message");
+ok($ok, "Disabled the Queue-specific one again");
# With just a name, prefers the non-disabled
$cf = RT::CustomField->new( RT->SystemUser );
-----------------------------------------------------------------------
More information about the rt-commit
mailing list