From e7fb89c8d016d01accb8714c138ba1ff89e5dce8 Mon Sep 17 00:00:00 2001 From: Anton Khorev Date: Thu, 5 Sep 2024 23:21:24 +0300 Subject: [PATCH] Remove nil ApiCapability user branch --- app/abilities/api_capability.rb | 2 +- test/abilities/api_capability_test.rb | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/app/abilities/api_capability.rb b/app/abilities/api_capability.rb index 2035afff9..07345d254 100644 --- a/app/abilities/api_capability.rb +++ b/app/abilities/api_capability.rb @@ -5,7 +5,7 @@ class ApiCapability def initialize(token) if Settings.status != "database_offline" - user = (User.find(token.resource_owner_id) if token.respond_to?(:resource_owner_id)) + user = User.find(token.resource_owner_id) if user&.active? can [:create, :comment, :close, :reopen], Note if scope?(token, :write_notes) diff --git a/test/abilities/api_capability_test.rb b/test/abilities/api_capability_test.rb index bcfcaf74e..5e8396c67 100644 --- a/test/abilities/api_capability_test.rb +++ b/test/abilities/api_capability_test.rb @@ -88,12 +88,6 @@ end class UserApiCapabilityTest < ActiveSupport::TestCase test "user preferences" do - # a user with no tokens - capability = ApiCapability.new nil - [:index, :show, :update_all, :update, :destroy].each do |act| - assert capability.cannot? act, UserPreference - end - # A user with empty tokens token = create(:oauth_access_token) capability = ApiCapability.new token -- 2.39.5