Merge pull request #962 from hynkle/fix-ambiguous-provider-constant-lookup
limit Builder#provider's symbol lookup to constants under OmniAuth::Strategies
This commit is contained in:
commit
94f8f05c95
|
@ -31,7 +31,7 @@ module OmniAuth
|
|||
middleware = klass
|
||||
else
|
||||
begin
|
||||
middleware = OmniAuth::Strategies.const_get(OmniAuth::Utils.camelize(klass.to_s).to_s)
|
||||
middleware = OmniAuth::Strategies.const_get(OmniAuth::Utils.camelize(klass.to_s).to_s, false)
|
||||
rescue NameError
|
||||
raise(LoadError.new("Could not find matching strategy for #{klass.inspect}. You may need to install an additional gem (such as omniauth-#{klass})."))
|
||||
end
|
||||
|
|
|
@ -3,7 +3,7 @@ require 'helper'
|
|||
describe OmniAuth::Builder do
|
||||
describe '#provider' do
|
||||
it 'translates a symbol to a constant' do
|
||||
expect(OmniAuth::Strategies).to receive(:const_get).with('MyStrategy').and_return(Class.new)
|
||||
expect(OmniAuth::Strategies).to receive(:const_get).with('MyStrategy', false).and_return(Class.new)
|
||||
OmniAuth::Builder.new(nil) do
|
||||
provider :my_strategy
|
||||
end
|
||||
|
@ -26,6 +26,16 @@ describe OmniAuth::Builder do
|
|||
end
|
||||
end.to raise_error(LoadError, 'Could not find matching strategy for :lorax. You may need to install an additional gem (such as omniauth-lorax).')
|
||||
end
|
||||
|
||||
it "doesn't translate a symbol to a top-level constant" do
|
||||
class MyStrategy; end
|
||||
|
||||
expect do
|
||||
OmniAuth::Builder.new(nil) do
|
||||
provider :my_strategy
|
||||
end
|
||||
end.to raise_error(LoadError, 'Could not find matching strategy for :my_strategy. You may need to install an additional gem (such as omniauth-my_strategy).')
|
||||
end
|
||||
end
|
||||
|
||||
describe '#options' do
|
||||
|
|
Loading…
Reference in New Issue