Skip to content

Commit

Permalink
Merge pull request #1015 from omniauth/make-sure-strategy-passes-rack…
Browse files Browse the repository at this point in the history
…-freeze

Make sure strategy passes rack freeze
  • Loading branch information
BobbyMcWho committed Dec 10, 2020
2 parents cc7e285 + e405613 commit 49ca577
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ group :test do
gem 'rack-test'
gem 'rest-client', '~> 2.0.0', :platforms => [:jruby_18]
gem 'rspec', '~> 3.5'
gem 'rack-freeze'
gem 'rubocop', '>= 0.58.2', '< 0.69.0', :platforms => %i[ruby_20 ruby_21 ruby_22 ruby_23 ruby_24]
gem 'simplecov-lcov'
gem 'tins', '~> 1.13', :platforms => %i[jruby_18 jruby_19 ruby_19]
Expand Down
11 changes: 5 additions & 6 deletions lib/omniauth/strategy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -528,16 +528,15 @@ def fail!(message_key, exception = nil)
OmniAuth.config.on_failure.call(env)
end

def dup
super.tap do
@options = @options.dup
end
end

class Options < OmniAuth::KeyStore; end

protected

def initialize_copy(*args)
super
@options = @options.dup
end

def merge_stack(stack)
stack.inject({}) do |a, e|
a.merge!(e)
Expand Down
1 change: 1 addition & 0 deletions spec/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

require 'rspec'
require 'rack/test'
require 'rack/freeze'
require 'omniauth'
require 'omniauth/test'

Expand Down
9 changes: 3 additions & 6 deletions spec/omniauth/builder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,11 @@ class MyStrategy; end

describe '#call' do
it 'passes env to to_app.call' do
app = lambda { |_env| [200, {}, []] }
app = lambda { |env| [200, {}, env['CUSTOM_ENV_VALUE']] }
builder = OmniAuth::Builder.new(app)
env = {'REQUEST_METHOD' => 'GET', 'PATH_INFO' => '/some/path'}
allow(app).to receive(:call).and_call_original
env = {'REQUEST_METHOD' => 'GET', 'PATH_INFO' => '/some/path', 'CUSTOM_ENV_VALUE' => 'VALUE'}

builder.call(env)

expect(app).to have_received(:call).with(env)
expect(builder.call(env)).to eq([200, {}, 'VALUE'])
end
end

Expand Down

0 comments on commit 49ca577

Please sign in to comment.