Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/MSch/omniauth
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Bleigh committed Nov 15, 2010
2 parents 9807bf3 + c7ce5fb commit 8951841
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
4 changes: 2 additions & 2 deletions oa-core/lib/omniauth/strategy.rb
Expand Up @@ -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
Expand All @@ -106,4 +106,4 @@ def fail!(message_key, exception = nil)
OmniAuth.config.on_failure.call(self.env, message_key.to_sym)
end
end
end
end
33 changes: 32 additions & 1 deletion oa-core/spec/omniauth/strategy_spec.rb
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
end

0 comments on commit 8951841

Please sign in to comment.