]> git.openstreetmap.org Git - rails.git/commitdiff
Remove nil ApiCapability user branch
authorAnton Khorev <tony29@yandex.ru>
Thu, 5 Sep 2024 20:21:24 +0000 (23:21 +0300)
committerAnton Khorev <tony29@yandex.ru>
Thu, 5 Sep 2024 20:21:24 +0000 (23:21 +0300)
app/abilities/api_capability.rb
test/abilities/api_capability_test.rb

index 2035afff991690cbd3a507dfe4962ca4bf92887a..07345d25475ab976c38643788e04fe7369f32c0f 100644 (file)
@@ -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)
index bcfcaf74e4d809ad0a8aba72af5c0837f8af062d..5e8396c676ac754543f5e08c27b5d82045b33e52 100644 (file)
@@ -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