diff --git a/oa-core/lib/omniauth/strategy.rb b/oa-core/lib/omniauth/strategy.rb index 11ce8e01f..3fea37f6b 100644 --- a/oa-core/lib/omniauth/strategy.rb +++ b/oa-core/lib/omniauth/strategy.rb @@ -82,7 +82,7 @@ def full_host end def callback_url - full_host + "#{OmniAuth.config.path_prefix}/#{name}/callback" + full_host + callback_path end def session @@ -106,4 +106,4 @@ def fail!(message_key, exception = nil) OmniAuth.config.on_failure.call(self.env, message_key.to_sym) end end -end \ No newline at end of file +end diff --git a/oa-core/spec/omniauth/strategy_spec.rb b/oa-core/spec/omniauth/strategy_spec.rb index 17e988241..d41552785 100644 --- a/oa-core/spec/omniauth/strategy_spec.rb +++ b/oa-core/spec/omniauth/strategy_spec.rb @@ -38,6 +38,16 @@ def callback_phase it 'should use the default callback path' do lambda{ strategy.call({'PATH_INFO' => '/auth/test/callback'}) }.should raise_error("Callback Phase") end + + context 'callback_url' do + it 'uses the default callback_path' do + strategy.should_receive(:full_host).and_return('http://example.com') + + lambda{ strategy.call({'PATH_INFO' => '/auth/test'}) }.should raise_error("Request Phase") + + strategy.callback_url.should == 'http://example.com/auth/test/callback' + end + end end it 'should be able to modify the env on the fly before the request_phase' do @@ -59,6 +69,17 @@ def callback_phase @options = {:callback_path => '/radical'} lambda{ strategy.call({'PATH_INFO' => '/radical'}) }.should raise_error("Callback Phase") end + + context 'callback_url' do + it 'uses a custom callback_path if one is provided' do + @options = {:callback_path => '/radical'} + strategy.should_receive(:full_host).and_return('http://example.com') + + lambda{ strategy.call({'PATH_INFO' => '/radical'}) }.should raise_error("Callback Phase") + + strategy.callback_url.should == 'http://example.com/radical' + end + end end context 'custom prefix' do @@ -73,6 +94,16 @@ def callback_phase it 'should use a custom prefix for callback' do lambda{ strategy.call({'PATH_INFO' => '/wowzers/test/callback'}) }.should raise_error("Callback Phase") end + + context 'callback_url' do + it 'uses a custom prefix' do + strategy.should_receive(:full_host).and_return('http://example.com') + + lambda{ strategy.call({'PATH_INFO' => '/wowzers/test'}) }.should raise_error("Request Phase") + + strategy.callback_url.should == 'http://example.com/wowzers/test/callback' + end + end end end -end \ No newline at end of file +end