Skip to content

Commit

Permalink
Deprecate Doorkeeper#configured?, Doorkeeper#database_installed?,…
Browse files Browse the repository at this point in the history
… and `Doorkeeper#installed?`

Are unused, so let's deprecate and get ready to remove them.
  • Loading branch information
maclover7 committed Feb 4, 2017
1 parent f21272c commit 5bb5085
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 2 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Expand Up @@ -4,6 +4,8 @@ User-visible changes worth mentioning.

## master

- [] Deprecate `Doorkeeper#configured?`, `Doorkeeper#database_installed?`, and
`Doorkeeper#installed?`
- [#909] Add `InvalidTokenResponse#reason` reader method to allow read the kind
of invalid token error.
- [#928] Test against more recent Ruby versions
Expand Down
5 changes: 5 additions & 0 deletions lib/doorkeeper.rb
Expand Up @@ -49,16 +49,21 @@

require 'doorkeeper/orm/active_record'

require 'active_support/deprecation'

module Doorkeeper
def self.configured?
ActiveSupport::Deprecation.warn "Method `Doorkeeper#configured?` has been deprecated without replacement."
@config.present?
end

def self.database_installed?
ActiveSupport::Deprecation.warn "Method `Doorkeeper#database_installed?` has been deprecated without replacement."
[AccessToken, AccessGrant, Application].all?(&:table_exists?)
end

def self.installed?
ActiveSupport::Deprecation.warn "Method `Doorkeeper#installed?` has been deprecated without replacement."
configured? && database_installed?
end

Expand Down
42 changes: 40 additions & 2 deletions spec/lib/doorkeeper_spec.rb
Expand Up @@ -43,6 +43,13 @@
expect(Doorkeeper.configured?).to eq(false)
end
end

it "is deprecated" do
expect(ActiveSupport::Deprecation).to receive(:warn).
with("Method `Doorkeeper#configured?` has been deprecated without replacement.")

Doorkeeper.configured?
end
end

describe "#database_installed?" do
Expand All @@ -62,27 +69,45 @@
end

context "all tables exist" do
it "returns true" do
before do
klass = double table_exists?: true

Doorkeeper.const_set(:AccessToken, klass)
Doorkeeper.const_set(:AccessGrant, klass)
Doorkeeper.const_set(:Application, klass)
end

it "returns true" do
expect(Doorkeeper.database_installed?).to eq(true)
end

it "is deprecated" do
expect(ActiveSupport::Deprecation).to receive(:warn).
with("Method `Doorkeeper#database_installed?` has been deprecated without replacement.")

Doorkeeper.database_installed?
end
end

context "all tables do not exist" do
it "returns false" do
before do
klass = double table_exists?: false

Doorkeeper.const_set(:AccessToken, klass)
Doorkeeper.const_set(:AccessGrant, klass)
Doorkeeper.const_set(:Application, klass)
end

it "returns false" do
expect(Doorkeeper.database_installed?).to eq(false)
end

it "is deprecated" do
expect(ActiveSupport::Deprecation).to receive(:warn).
with("Method `Doorkeeper#database_installed?` has been deprecated without replacement.")

Doorkeeper.database_installed?
end
end
end

Expand All @@ -108,5 +133,18 @@
expect(Doorkeeper.installed?).to eq(false)
end
end

it "is deprecated" do
expect(ActiveSupport::Deprecation).to receive(:warn).
with("Method `Doorkeeper#configured?` has been deprecated without replacement.")

expect(ActiveSupport::Deprecation).to receive(:warn).
with("Method `Doorkeeper#database_installed?` has been deprecated without replacement.")

expect(ActiveSupport::Deprecation).to receive(:warn).
with("Method `Doorkeeper#installed?` has been deprecated without replacement.")

Doorkeeper.installed?
end
end
end

0 comments on commit 5bb5085

Please sign in to comment.