[Rt-commit] rt branch 5.0/rest2-delete-queue created. rt-5.0.4-137-g089eeb383b

BPS Git Server git at git.bestpractical.com
Wed Sep 6 21:42:35 UTC 2023


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "rt".

The branch, 5.0/rest2-delete-queue has been created
        at  089eeb383b91c63f8af3ea398e021794fc2b9bdf (commit)

- Log -----------------------------------------------------------------
commit 089eeb383b91c63f8af3ea398e021794fc2b9bdf
Author: Jim Brandt <jbrandt at bestpractical.com>
Date:   Wed Aug 30 15:53:09 2023 -0400

    Return success when disabling a disabled record via REST 2
    
    RT's internal API returns "false" when you update a record
    to the value it already has. This false return caused a
    REST 2 DELETE (which is 'disable' on most records) to return
    failure (500) if you disabled an already-disabled queue.
    
    This commit directly return true if record is already disabled.
    
    Fixes: I#37591

diff --git a/lib/RT/REST2/Resource/Record/DeletableByDisabling.pm b/lib/RT/REST2/Resource/Record/DeletableByDisabling.pm
index 8a82b9171d..59414f5c69 100644
--- a/lib/RT/REST2/Resource/Record/DeletableByDisabling.pm
+++ b/lib/RT/REST2/Resource/Record/DeletableByDisabling.pm
@@ -57,6 +57,11 @@ with 'RT::REST2::Resource::Record::Deletable';
 
 sub delete_resource {
     my $self = shift;
+
+    # Don't return failure if the resource is already disabled since
+    # the final state is correct, the resource is disabled.
+    return 1 if $self->record->Disabled == 1;
+
     my ($ok, $msg) = $self->record->SetDisabled(1);
     RT->Logger->debug("Failed to disable ", $self->record_class, " #", $self->record->id, ": $msg")
         unless $ok;

commit 2170dafe7a36ca380520c9140008c27ceb4857d0
Author: Jim Brandt <jbrandt at bestpractical.com>
Date:   Wed Aug 30 15:52:48 2023 -0400

    Add test for deleting a disabled queue via REST 2

diff --git a/t/rest2/queues.t b/t/rest2/queues.t
index 25c2b06df9..77e0c554ff 100644
--- a/t/rest2/queues.t
+++ b/t/rest2/queues.t
@@ -192,6 +192,12 @@ my $queue_url;
     my $content = $mech->json_response;
     is($content->{Name}, 'Bugs');
     is($content->{Disabled}, 1);
+
+    diag 'Try to call delete on a disabled queue';
+    $res = $mech->delete($queue_url,
+        'Authorization' => $auth,
+    );
+    is($res->code, 204);
 }
 
 # Queue create

-----------------------------------------------------------------------


hooks/post-receive
-- 
rt


More information about the rt-commit mailing list