mirror of
https://github.com/omniauth/omniauth.git
synced 2022-11-09 12:31:49 -05:00
Merge pull request #977 from BobbyMcWho/hashie-4
Allow Hashie version 4.0.x
This commit is contained in:
commit
68b40cb151
6 changed files with 89 additions and 26 deletions
|
@ -1,7 +1,9 @@
|
|||
bundler_args: --without development
|
||||
before_install:
|
||||
- gem update --system
|
||||
- gem update bundler
|
||||
- gem uninstall -v '>= 2' -i $(rvm gemdir)@global -ax bundler || true
|
||||
- gem install bundler -v '1.17.3'
|
||||
install:
|
||||
- bundle _1.17.3_ install --jobs=3 --retry=3
|
||||
cache: bundler
|
||||
env:
|
||||
global:
|
||||
|
|
4
Gemfile
4
Gemfile
|
@ -13,14 +13,14 @@ end
|
|||
|
||||
group :test do
|
||||
gem 'coveralls', :require => false
|
||||
gem 'hashie', '>= 3.4.6', '< 3.7.0', :platforms => [:jruby_18]
|
||||
gem 'hashie', '>= 3.4.6', '~> 4.0.0', :platforms => [:jruby_18]
|
||||
gem 'json', '~> 2.0.3', :platforms => %i[jruby_18 jruby_19 ruby_19]
|
||||
gem 'mime-types', '~> 3.1', :platforms => [:jruby_18]
|
||||
gem 'rack', '>= 2.0.6', :platforms => %i[jruby_18 jruby_19 ruby_19 ruby_20 ruby_21]
|
||||
gem 'rack-test'
|
||||
gem 'rest-client', '~> 2.0.0', :platforms => [:jruby_18]
|
||||
gem 'rspec', '~> 3.5.0'
|
||||
gem 'rubocop', '>= 0.58.2', :platforms => %i[ruby_20 ruby_21 ruby_22 ruby_23 ruby_24]
|
||||
gem 'rubocop', '>= 0.58.2', '< 0.69.0', :platforms => %i[ruby_20 ruby_21 ruby_22 ruby_23 ruby_24]
|
||||
gem 'tins', '~> 1.13.0', :platforms => %i[jruby_18 jruby_19 ruby_19]
|
||||
end
|
||||
|
||||
|
|
|
@ -132,7 +132,7 @@ module OmniAuth
|
|||
end
|
||||
|
||||
module Utils
|
||||
module_function
|
||||
module_function # rubocop:disable Layout/IndentationWidth
|
||||
|
||||
def form_css
|
||||
"<style type='text/css'>#{OmniAuth.config.form_css}</style>"
|
||||
|
|
|
@ -1,24 +1,5 @@
|
|||
module OmniAuth
|
||||
class Builder < ::Rack::Builder
|
||||
def initialize(app, &block)
|
||||
@options = nil
|
||||
if rack14? || rack2?
|
||||
super
|
||||
else
|
||||
@app = app
|
||||
super(&block)
|
||||
@ins << @app
|
||||
end
|
||||
end
|
||||
|
||||
def rack14?
|
||||
Rack.release.start_with?('1.') && (Rack.release.split('.')[1].to_i >= 4)
|
||||
end
|
||||
|
||||
def rack2?
|
||||
Rack.release.start_with? '2.'
|
||||
end
|
||||
|
||||
def on_failure(&block)
|
||||
OmniAuth.config.on_failure = block
|
||||
end
|
||||
|
@ -40,7 +21,7 @@ module OmniAuth
|
|||
end
|
||||
|
||||
def options(options = false)
|
||||
return @options || {} if options == false
|
||||
return @options ||= {} if options == false
|
||||
|
||||
@options = options
|
||||
end
|
||||
|
|
|
@ -5,7 +5,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|||
require 'omniauth/version'
|
||||
|
||||
Gem::Specification.new do |spec|
|
||||
spec.add_dependency 'hashie', ['>= 3.4.6', '< 3.7.0']
|
||||
spec.add_dependency 'hashie', ['>= 3.4.6', '~> 4.0.0']
|
||||
spec.add_dependency 'rack', ['>= 1.6.2', '< 3']
|
||||
spec.add_development_dependency 'bundler', '~> 1.14'
|
||||
spec.add_development_dependency 'rake', '~> 12.0'
|
||||
|
|
|
@ -47,4 +47,84 @@ describe OmniAuth::Builder do
|
|||
b.provider k
|
||||
end
|
||||
end
|
||||
|
||||
describe '#on_failure' do
|
||||
it 'passes the block to the config' do
|
||||
prok = proc {}
|
||||
|
||||
with_config_reset(:on_failure) do
|
||||
OmniAuth::Builder.new(nil).on_failure(&prok)
|
||||
|
||||
expect(OmniAuth.config.on_failure).to eq(prok)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#before_options_phase' do
|
||||
it 'passes the block to the config' do
|
||||
prok = proc {}
|
||||
|
||||
with_config_reset(:before_options_phase) do
|
||||
OmniAuth::Builder.new(nil).before_options_phase(&prok)
|
||||
|
||||
expect(OmniAuth.config.before_options_phase).to eq(prok)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#before_request_phase' do
|
||||
it 'passes the block to the config' do
|
||||
prok = proc {}
|
||||
|
||||
with_config_reset(:before_request_phase) do
|
||||
OmniAuth::Builder.new(nil).before_request_phase(&prok)
|
||||
|
||||
expect(OmniAuth.config.before_request_phase).to eq(prok)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#before_callback_phase' do
|
||||
it 'passes the block to the config' do
|
||||
prok = proc {}
|
||||
|
||||
with_config_reset(:before_callback_phase) do
|
||||
OmniAuth::Builder.new(nil).before_callback_phase(&prok)
|
||||
|
||||
expect(OmniAuth.config.before_callback_phase).to eq(prok)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#configure' do
|
||||
it 'passes the block to the config' do
|
||||
prok = proc {}
|
||||
allow(OmniAuth).to receive(:configure).and_call_original
|
||||
|
||||
OmniAuth::Builder.new(nil).configure(&prok)
|
||||
|
||||
expect(OmniAuth).to have_received(:configure) do |&block|
|
||||
expect(block).to eq(prok)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#call' do
|
||||
it 'passes env to to_app.call' do
|
||||
app = lambda { |_env| [200, {}, []] }
|
||||
builder = OmniAuth::Builder.new(app)
|
||||
env = {'REQUEST_METHOD' => 'GET', 'PATH_INFO' => '/some/path'}
|
||||
allow(app).to receive(:call).and_call_original
|
||||
|
||||
builder.call(env)
|
||||
|
||||
expect(app).to have_received(:call).with(env)
|
||||
end
|
||||
end
|
||||
|
||||
def with_config_reset(option)
|
||||
old_config = OmniAuth.config.send(option)
|
||||
yield
|
||||
OmniAuth.config.send("#{option}=", old_config)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue