From c548f115125d6fb77e74bb2fc46e6eb25d9e133c Mon Sep 17 00:00:00 2001 From: James Mead Date: Tue, 10 Oct 2023 11:37:55 +0100 Subject: [PATCH] Remove redundant :: prefix from Doorkeeper constant --- app/controllers/application_controller.rb | 2 +- app/controllers/root_controller.rb | 4 ++-- app/jobs/permission_updater.rb | 2 +- app/jobs/reauth_enforcer.rb | 2 +- app/models/doorkeeper/application.rb | 2 +- .../user_permission_manageable_application_policy.rb | 2 +- config/initializers/doorkeeper.rb | 6 +++--- lib/user_permissions_controller_methods.rb | 2 +- script/make_oauth_work_in_dev | 2 +- test/integration/superadmin_application_edit_test.rb | 2 +- test/jobs/push_user_updates_job_test.rb | 2 +- test/models/doorkeeper/application_test.rb | 2 +- test/models/user_test.rb | 2 +- 13 files changed, 16 insertions(+), 16 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 268de6845..44c47f194 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -25,7 +25,7 @@ def current_resource_owner end def application_making_request - @_application_making_request ||= ::Doorkeeper::Application.find(doorkeeper_token.application_id) if doorkeeper_token + @_application_making_request ||= Doorkeeper::Application.find(doorkeeper_token.application_id) if doorkeeper_token end private diff --git a/app/controllers/root_controller.rb b/app/controllers/root_controller.rb index dccd5f7f1..50a7d6eda 100644 --- a/app/controllers/root_controller.rb +++ b/app/controllers/root_controller.rb @@ -6,13 +6,13 @@ class RootController < ApplicationController skip_after_action :verify_authorized def index - applications = ::Doorkeeper::Application.where(show_on_dashboard: true).can_signin(current_user) + applications = Doorkeeper::Application.where(show_on_dashboard: true).can_signin(current_user) @applications_and_permissions = zip_permissions(applications, current_user) end def signin_required - @application = ::Doorkeeper::Application.find_by(id: session.delete(:signin_missing_for_application)) + @application = Doorkeeper::Application.find_by(id: session.delete(:signin_missing_for_application)) end def privacy_notice; end diff --git a/app/jobs/permission_updater.rb b/app/jobs/permission_updater.rb index 4fe8624ee..f4326de1f 100644 --- a/app/jobs/permission_updater.rb +++ b/app/jobs/permission_updater.rb @@ -3,7 +3,7 @@ class PermissionUpdater < PushUserUpdatesJob def perform(uid, application_id) user = User.find_by(uid:) - application = ::Doorkeeper::Application.find_by(id: application_id) + application = Doorkeeper::Application.find_by(id: application_id) # It's possible they've been deleted between when the job was scheduled and run. return if user.nil? || application.nil? return unless application.supports_push_updates? diff --git a/app/jobs/reauth_enforcer.rb b/app/jobs/reauth_enforcer.rb index e8040b841..d7d60ceda 100644 --- a/app/jobs/reauth_enforcer.rb +++ b/app/jobs/reauth_enforcer.rb @@ -2,7 +2,7 @@ class ReauthEnforcer < PushUserUpdatesJob def perform(uid, application_id) - application = ::Doorkeeper::Application.find_by(id: application_id) + application = Doorkeeper::Application.find_by(id: application_id) # It's possible the application has been deleted between when the job was scheduled and run. return if application.nil? return unless application.supports_push_updates? diff --git a/app/models/doorkeeper/application.rb b/app/models/doorkeeper/application.rb index f5a1a8f3b..d377b8b7b 100644 --- a/app/models/doorkeeper/application.rb +++ b/app/models/doorkeeper/application.rb @@ -1,7 +1,7 @@ require "doorkeeper/orm/active_record/application" # rubocop:disable Rails/ApplicationRecord -class ::Doorkeeper::Application < ActiveRecord::Base +class Doorkeeper::Application < ActiveRecord::Base # rubocop:enable Rails/ApplicationRecord has_many :supported_permissions, dependent: :destroy diff --git a/app/policies/user_permission_manageable_application_policy.rb b/app/policies/user_permission_manageable_application_policy.rb index 02f33479d..b1919aec8 100644 --- a/app/policies/user_permission_manageable_application_policy.rb +++ b/app/policies/user_permission_manageable_application_policy.rb @@ -31,7 +31,7 @@ def resolve private def applications - ::Doorkeeper::Application.includes(:supported_permissions) + Doorkeeper::Application.includes(:supported_permissions) end end end diff --git a/config/initializers/doorkeeper.rb b/config/initializers/doorkeeper.rb index 61ebf0f1f..f757c8f88 100644 --- a/config/initializers/doorkeeper.rb +++ b/config/initializers/doorkeeper.rb @@ -74,7 +74,7 @@ # Use a custom class for generating the access token. # See https://doorkeeper.gitbook.io/guides/configuration/other-configurations#custom-access-token-generator # - # access_token_generator '::Doorkeeper::JWT' + # access_token_generator 'Doorkeeper::JWT' # The controller +Doorkeeper::ApplicationController+ inherits from. # Defaults to +ActionController::Base+ unless +api_only+ is set, which changes the default to @@ -119,7 +119,7 @@ # If you wish to use another hashing implementation, you can override # this strategy as follows: # - # hash_token_secrets using: '::Doorkeeper::Hashing::MyCustomHashImpl' + # hash_token_secrets using: 'Doorkeeper::Hashing::MyCustomHashImpl' # # Keep in mind that changing the hashing function will invalidate all existing # secrets, if there are any. @@ -134,7 +134,7 @@ # If you wish to use bcrypt for application secret hashing, uncomment # this line instead: # - # hash_application_secrets using: '::Doorkeeper::SecretStoring::BCrypt' + # hash_application_secrets using: 'Doorkeeper::SecretStoring::BCrypt' # When the above option is enabled, and a hashed token or secret is not found, # you can allow to fall back to another strategy. For users upgrading diff --git a/lib/user_permissions_controller_methods.rb b/lib/user_permissions_controller_methods.rb index c8a17ab54..48da189a3 100644 --- a/lib/user_permissions_controller_methods.rb +++ b/lib/user_permissions_controller_methods.rb @@ -3,7 +3,7 @@ module UserPermissionsControllerMethods def visible_applications(user) if user.api_user? - applications = ::Doorkeeper::Application.includes(:supported_permissions) + applications = Doorkeeper::Application.includes(:supported_permissions) if current_user.superadmin? api_user_authorised_apps = user.authorisations.not_revoked.pluck(:application_id) applications.where(id: api_user_authorised_apps) diff --git a/script/make_oauth_work_in_dev b/script/make_oauth_work_in_dev index 9f1363298..b82653873 100755 --- a/script/make_oauth_work_in_dev +++ b/script/make_oauth_work_in_dev @@ -98,7 +98,7 @@ def deverise_uri(uri) end puts "Updating SSO config so that it works in development..." -applications = ::Doorkeeper::Application.where(retired: false) +applications = Doorkeeper::Application.where(retired: false) applications.each do |application| local_config = values_for_app(application) if local_config.present? diff --git a/test/integration/superadmin_application_edit_test.rb b/test/integration/superadmin_application_edit_test.rb index d23ea0629..01807de4b 100644 --- a/test/integration/superadmin_application_edit_test.rb +++ b/test/integration/superadmin_application_edit_test.rb @@ -14,7 +14,7 @@ class SuperAdminApplicationEditTest < ActionDispatch::IntegrationTest # normal user who's authorised to use app @user = create(:user) - ::Doorkeeper::AccessToken.create!(resource_owner_id: @user.id, application_id: @application.id, token: "1234") + Doorkeeper::AccessToken.create!(resource_owner_id: @user.id, application_id: @application.id, token: "1234") end should "be able to enable push updates to applications" do diff --git a/test/jobs/push_user_updates_job_test.rb b/test/jobs/push_user_updates_job_test.rb index 799021670..72054dde8 100644 --- a/test/jobs/push_user_updates_job_test.rb +++ b/test/jobs/push_user_updates_job_test.rb @@ -12,7 +12,7 @@ class TestJob < PushUserUpdatesJob foo_app, _bar_app = *create_list(:application, 2) # authenticate access - ::Doorkeeper::AccessToken.create!(resource_owner_id: user.id, application_id: foo_app.id, token: "1234") + Doorkeeper::AccessToken.create!(resource_owner_id: user.id, application_id: foo_app.id, token: "1234") assert_enqueued_with(job: TestJob, args: [user.uid, foo_app.id]) do TestJob.perform_on(user) diff --git a/test/models/doorkeeper/application_test.rb b/test/models/doorkeeper/application_test.rb index 8025957c8..a2417f8c0 100644 --- a/test/models/doorkeeper/application_test.rb +++ b/test/models/doorkeeper/application_test.rb @@ -1,6 +1,6 @@ require "test_helper" -class ::Doorkeeper::ApplicationTest < ActiveSupport::TestCase +class Doorkeeper::ApplicationTest < ActiveSupport::TestCase should "have a signin supported permission on create" do assert_not_nil create(:application).signin_permission end diff --git a/test/models/user_test.rb b/test/models/user_test.rb index 091b006ad..18c733178 100644 --- a/test/models/user_test.rb +++ b/test/models/user_test.rb @@ -1110,7 +1110,7 @@ def setup end def authenticate_access(user, app) - ::Doorkeeper::AccessToken.create!(resource_owner_id: user.id, application_id: app.id) + Doorkeeper::AccessToken.create!(resource_owner_id: user.id, application_id: app.id) end def assert_user_has_permissions(expected_permissions, application, user)