Permalink
Browse files

Fix mock_*_call methods to preserve the omniauth.params hash

  • Loading branch information...
1 parent c2ceb5f commit fba3c36db51e395e3f768eb5bddb860221bde463 @alexis alexis committed Jun 4, 2012
Showing with 17 additions and 1 deletion.
  1. +3 −1 lib/omniauth/strategy.rb
  2. +14 −0 spec/omniauth/strategy_spec.rb
View
@@ -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!
@@ -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

0 comments on commit fba3c36

Please sign in to comment.