Skip to content
This repository has been archived by the owner on Apr 24, 2020. It is now read-only.

Commit

Permalink
Symbolize client options before passing them through.
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Bleigh committed Oct 1, 2011
1 parent 16040a0 commit a09b479
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .rspec
@@ -0,0 +1,2 @@
--colour
--format=progress
7 changes: 7 additions & 0 deletions Rakefile
@@ -1,2 +1,9 @@
#!/usr/bin/env rake
require "bundler/gem_tasks"
require 'rspec/core/rake_task'

desc 'Default: run specs.'
task :default => :spec

desc "Run specs"
RSpec::Core::RakeTask.new
4 changes: 2 additions & 2 deletions lib/omniauth/strategies/oauth2.rb
Expand Up @@ -22,7 +22,7 @@ class OAuth2
attr_accessor :access_token

def client
::OAuth2::Client.new(options.client_id, options.client_secret, options.client_options)
::OAuth2::Client.new(options.client_id, options.client_secret, options.client_options.inject({}){|h,(k,v)| h[k.to_sym] = v; h})
end

def callback_url
Expand All @@ -36,7 +36,7 @@ def callback_url
end

def request_phase
redirect client.auth_code.authorize_url({:redirect_uri => callback_url}.merge(options))
redirect client.auth_code.authorize_url({:redirect_uri => callback_url}.merge(options.authorize_params))
end

def callback_phase
Expand Down
15 changes: 15 additions & 0 deletions spec/omniauth/strategies/oauth2_spec.rb
@@ -0,0 +1,15 @@
require 'spec_helper'

describe OmniAuth::Strategies::OAuth2 do
def app; lambda{|env| [200, {}, ["Hello."]]} end
let(:fresh_strategy){ Class.new(OmniAuth::Strategies::OAuth2) }

describe '#client' do
subject{ fresh_strategy }

it 'should be initialized with symbolized client_options' do
instance = subject.new(app, :client_options => {'authorize_url' => 'https://example.com'})
instance.client.options[:authorize_url].should == 'https://example.com'
end
end
end

0 comments on commit a09b479

Please sign in to comment.