Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #610 from alexis/master

Problem with mock_request_call and mock_callback_call methods not preserving the omniauth.params hash
  • Loading branch information...
commit 30936dae1bff9223277cf60d52aef13b0da5a66f 2 parents c2ceb5f + fba3c36
@sferik sferik authored
Showing with 17 additions and 1 deletion.
  1. +3 −1 lib/omniauth/strategy.rb
  2. +14 −0 spec/omniauth/strategy_spec.rb
View
4 lib/omniauth/strategy.rb
@@ -261,6 +261,8 @@ def mock_call!(env)
def mock_request_call
setup_phase
+ session['omniauth.params'] = request.params
+
if request.params['origin']
@env['rack.session']['omniauth.origin'] = request.params['origin']
elsif env['HTTP_REFERER'] && !env['HTTP_REFERER'].match(/#{request_path}$/)
@@ -276,7 +278,7 @@ def mock_callback_call
fail!(mocked_auth)
else
@env['omniauth.auth'] = mocked_auth
- @env['omniauth.params'] = session.delete('query_params') || {}
+ @env['omniauth.params'] = session.delete('omniauth.params') || {}
@env['omniauth.origin'] = session.delete('omniauth.origin')
@env['omniauth.origin'] = nil if env['omniauth.origin'] == ''
call_app!
View
14 spec/omniauth/strategy_spec.rb
@@ -564,6 +564,20 @@ def make_env(path = '/auth/test', props = {})
strategy.env['omniauth.origin'].should == 'http://example.com/origin'
end
+ it 'should set omniauth.params on the request phase' do
+ OmniAuth.config.mock_auth[:test] = {}
+
+ strategy.call(make_env('/auth/test', 'QUERY_STRING' => 'foo=bar'))
+ strategy.env['rack.session']['omniauth.params'].should == {'foo' => 'bar'}
+ end
+
+ it 'should turn omniauth.params into an env variable on the callback phase' do
+ OmniAuth.config.mock_auth[:test] = {}
+
+ strategy.call(make_env('/auth/test/callback', 'rack.session' => {'omniauth.params' => {'foo' => 'bar'}}))
+ strategy.env['omniauth.params'].should == {'foo' => 'bar'}
+ end
+
after do
OmniAuth.config.test_mode = false
end
Please sign in to comment.
Something went wrong with that request. Please try again.