Skip to content

Commit

Permalink
Merge pull request #1395 from doorkeeper-gem/fix-rake-tasks
Browse files Browse the repository at this point in the history
Fix Rake tasks
  • Loading branch information
nbulaj committed Apr 8, 2020
2 parents ca0496f + de7cdc6 commit ae7ce21
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
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

0 comments on commit ae7ce21

Please sign in to comment.