[Rt-commit] rt branch, 4.4/custom-field-disable-enable-msg, created. rt-4.2.11-176-gaca98b6

Dustin Graves dustin at bestpractical.com
Thu Sep 17 14:55:33 EDT 2015


The branch, 4.4/custom-field-disable-enable-msg has been created
        at  aca98b69d988bbb36a113272f3ee978ceb722135 (commit)

- Log -----------------------------------------------------------------
commit aca98b69d988bbb36a113272f3ee978ceb722135
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 9a8af4b..a422f0f 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