Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Rake tasks #1395

Merged
merged 1 commit into from
Apr 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ User-visible changes worth mentioning.

## master

- [#PR number] Your changes description.
- [#1395] Fix `NameError: uninitialized constant Doorkeeper::AccessToken` for Rake tasks.

## 5.4.0.rc1
- [#1366] Sets expiry of token generated using `refresh_token` to that of original token. (Fixes #1364)
Expand Down
2 changes: 1 addition & 1 deletion lib/doorkeeper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
# Main Doorkeeper namespace.
#
module Doorkeeper
autoload :OAuth, "doorkeeper/oauth"
autoload :Errors, "doorkeeper/errors"
autoload :OAuth, "doorkeeper/oauth"
autoload :Rake, "doorkeeper/rake"
autoload :Request, "doorkeeper/request"
autoload :Server, "doorkeeper/server"
Expand Down
12 changes: 10 additions & 2 deletions lib/doorkeeper/orm/active_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,20 @@ def self.initialize_application_owner!
lazy_load do
require "doorkeeper/models/concerns/ownership"

Doorkeeper.config.application_model.send :include, Doorkeeper::Models::Ownership
Doorkeeper.config.application_model.include(Doorkeeper::Models::Ownership)
end
end

def self.lazy_load(&block)
ActiveSupport.on_load(:active_record, {}, &block)
# ActiveSupport has no public interface to check if something
# already lazy-loaded :(
loaded = ActiveSupport.instance_variable_get(:"@loaded") || {}

if loaded.key?(:active_record)
block.call
else
ActiveSupport.on_load(:active_record, {}, &block)
end
end

def self.models
Expand Down