Skip to content

Commit

Permalink
Merge pull request #1626 from doorkeeper-gem/features/remove-active_r…
Browse files Browse the repository at this point in the history
…ecord_options

Remove deprecated active_record_options config option
  • Loading branch information
nbulaj committed Jan 12, 2023
2 parents 254e08e + d7451ce commit 1794b50
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 46 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ User-visible changes worth mentioning.
- [#1622] Drop support for Rubies 2.5 and 2.6
- [#1605] Fix URI validation for Ruby 3.2+.
- [#1625] Exclude endless access tokens from `StaleRecordsCleaner`.
- [#1626] Remove deprecated `active_record_options` config option.

## 5.6.2

Expand Down
5 changes: 0 additions & 5 deletions lib/doorkeeper/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -324,11 +324,6 @@ def configure_secrets_for(type, using:, fallback:)
option :skip_client_authentication_for_password_grant,
default: false

# TODO: remove the option
option :active_record_options,
default: {},
deprecated: { message: "Customize Doorkeeper models instead" }

# Hook to allow arbitrary user-client authorization
option :authorize_resource_owner_for_client,
default: ->(_client, _resource_owner) { true }
Expand Down
15 changes: 1 addition & 14 deletions lib/doorkeeper/orm/active_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,7 @@ module Mixins
end

def self.run_hooks
# Deprecated, will be removed soon
return unless (options = Doorkeeper.config.active_record_options[:establish_connection])

Doorkeeper::Orm::ActiveRecord.models.each do |model|
model.establish_connection(options)
end
end

def self.models
[
Doorkeeper.config.access_grant_model,
Doorkeeper.config.access_token_model,
Doorkeeper.config.application_model,
]
# nop
end
end
end
Expand Down
27 changes: 0 additions & 27 deletions spec/lib/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -626,33 +626,6 @@
if DOORKEEPER_ORM == :active_record
class FakeCustomModel; end

describe "active_record_options" do
let(:models) { [Doorkeeper::AccessGrant, Doorkeeper::AccessToken, Doorkeeper::Application] }

before do
models.each do |model|
allow(model).to receive(:establish_connection).and_return(true)
end
end

it "establishes connection for Doorkeeper models based on options" do
expect(models).to all(receive(:establish_connection))

expect(Kernel).to receive(:warn).with(
/\[DOORKEEPER\] active_record_options has been deprecated and will soon be removed/,
)

Doorkeeper.configure do
orm DOORKEEPER_ORM
active_record_options(
establish_connection: Rails.configuration.database_configuration[Rails.env],
)
end

Doorkeeper.setup
end
end

describe "access_token_class" do
it "uses default doorkeeper value" do
expect(config.access_token_class).to eq("Doorkeeper::AccessToken")
Expand Down

0 comments on commit 1794b50

Please sign in to comment.