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

Provide an option to skip orm hooks #1668

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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: 2 additions & 0 deletions lib/doorkeeper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ def setup_orm_adapter
end

def run_orm_hooks
return if config.skip_orm_hooks

config.clear_cache!

if @orm_adapter.respond_to?(:run_hooks)
Expand Down
1 change: 1 addition & 0 deletions lib/doorkeeper/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ def configure_secrets_for(type, using:, fallback:)
option :custom_access_token_expires_in, default: ->(_context) { nil }
option :authorization_code_expires_in, default: 600
option :orm, default: :active_record
option :skip_orm_hooks, default: false
option :native_redirect_uri, default: "urn:ietf:wg:oauth:2.0:oob", deprecated: true
option :grant_flows, default: %w[authorization_code client_credentials]
option :handle_auth_errors, default: :render
Expand Down
23 changes: 23 additions & 0 deletions spec/models/doorkeeper/application_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,29 @@ def self.generate
expect(new_application.secret).to eq("custom_application_secret")
end

context "when precompiling assets" do
let(:precompiling_assets) { true }
let(:orm_adapter) { Doorkeeper.orm_adapter }

context "when skip orm hooks is true" do
before do
assets_compiling = precompiling_assets

Doorkeeper.configure do
orm DOORKEEPER_ORM
skip_orm_hooks true if assets_compiling
end

allow(orm_adapter).to receive(:run_hooks)
Doorkeeper.run_orm_hooks
end

it "skips running orm hooks" do
expect(orm_adapter).not_to have_received(:run_hooks)
end
end
end

context "when application_owner is enabled" do
context "when application owner is not required" do
before do
Expand Down