Permalink
Browse files

fixed specs

  • Loading branch information...
1 parent 28a4049 commit 703e1428c2c5973c4630ffcebebc8148bedebd75 @Pasta committed Jan 25, 2012
Showing with 48 additions and 42 deletions.
  1. +1 −1 Gemfile
  2. +13 −12 Gemfile.lock
  3. +31 −26 lib/omniauth/strategies/viadeo.rb
  4. +1 −1 omniauth-viadeo.gemspec
  5. +2 −2 spec/omniauth/strategies/viadeo_spec.rb
View
@@ -2,7 +2,7 @@ source "http://rubygems.org"
gemspec
-gem 'omniauth-oauth', :git => 'https://github.com/intridea/omniauth-oauth.git'
+gem 'omniauth-oauth2'
group :development, :test do
gem 'guard'
View
@@ -1,23 +1,19 @@
-GIT
- remote: https://github.com/intridea/omniauth-oauth.git
- revision: 6e82c91a4f86886d80d2cc256156eca13f2a6309
- specs:
- omniauth-oauth (1.0.0)
- oauth
- omniauth (~> 1.0)
-
PATH
remote: .
specs:
omniauth-viadeo (0.0.1)
- omniauth-oauth (~> 1.0.0)
+ omniauth-oauth2 (~> 1.0.0)
GEM
remote: http://rubygems.org/
specs:
addressable (2.2.6)
crack (0.3.1)
diff-lcs (1.1.3)
+ faraday (0.7.6)
+ addressable (~> 2.2)
+ multipart-post (~> 1.1)
+ rack (~> 1.1)
ffi (1.0.11)
growl (1.0.3)
guard (1.0.0)
@@ -30,10 +26,16 @@ GEM
guard (>= 0.10.0)
hashie (1.2.0)
multi_json (1.0.4)
- oauth (0.4.5)
+ multipart-post (1.1.4)
+ oauth2 (0.5.2)
+ faraday (~> 0.7)
+ multi_json (~> 1.0)
omniauth (1.0.2)
hashie (~> 1.2)
rack
+ omniauth-oauth2 (1.0.0)
+ oauth2 (~> 0.5.0)
+ omniauth (~> 1.0)
rack (1.4.1)
rack-test (0.6.1)
rack (>= 1.0)
@@ -61,8 +63,7 @@ DEPENDENCIES
guard-bundler
guard-rspec
multi_json
- omniauth
- omniauth-oauth!
+ omniauth-oauth2
omniauth-viadeo!
rack-test
rake
@@ -1,16 +1,23 @@
-require 'omniauth/strategies/oauth'
+require 'omniauth-oauth2'
module OmniAuth
module Strategies
class Viadeo < OmniAuth::Strategies::OAuth2
- def initialize(app, client_id=nil, client_secret=nil, options = {}, &block)
- client_options = {
+ option :name, "viadeo"
+
+ uid{ raw_info['id'] }
+
+ extra do
+ {
+ 'raw_info' => raw_info
+ }
+ end
+
+ option :client_options, {
:site => 'https://api.viadeo.com/',
:authorize_url => 'https://secure.viadeo.com/oauth-provider/authorize2',
- :token_url => 'https://secure.viadeo.com/oauth-provider/access_token2'
+ :access_token_path => 'https://secure.viadeo.com/oauth-provider/access_token2'
}
- super(app, :viadeo, client_id, client_secret, client_options, options, &block)
- end
def auth_hash
OmniAuth::Utils.deep_merge(
@@ -24,8 +31,8 @@ def auth_hash
)
end
- def user_data
- @data ||= MultiJson.decode(@access_token.get('/me').body)
+ def raw_info
+ @raw_info ||= MultiJson.decode(@access_token.get('/me').body)
end
def request_phase
@@ -38,29 +45,27 @@ def callback_phase
super
end
- def user_info
+ info do
{
- 'name' => user_data['name'],
- 'link' => user_data['link'],
- 'first_name' => user_data['first_name'],
- 'last_name' => user_data['last_name'],
- 'gender' => user_data['gender'],
- 'nickname' => user_data['nickname'],
- 'has_picture' => user_data['has_picture'] ,
- 'picture_small' => user_data['picture_small'],
- 'picture_large' => user_data['picture_large'],
- 'headline' => user_data['headline'],
- 'introduction' => user_data['introduction'],
- 'interests' => user_data['interests'],
- 'location' => user_data['location'],
- 'is_premium' => user_data['is_premium'],
- 'premium_since' => user_data['premium_since']
+ :name => user_data['name'],
+ :link => user_data['link'],
+ :first_name => user_data['first_name'],
+ :last_name => user_data['last_name'],
+ :gender => user_data['gender'],
+ :nickname => user_data['nickname'],
+ :has_picture => user_data['has_picture'] ,
+ :picture_small => user_data['picture_small'],
+ :picture_large => user_data['picture_large'],
+ :headline => user_data['headline'],
+ :introduction => user_data['introduction'],
+ :interests => user_data['interests'],
+ :location => user_data['location'],
+ :is_premium => user_data['is_premium'],
+ :premium_since => user_data['premium_since']
}
end
end
end
end
-OmniAuth.config.add_camelization 'linkedin', 'LinkedIn'
-
View
@@ -16,7 +16,7 @@ Gem::Specification.new do |s|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.require_paths = ["lib"]
- s.add_runtime_dependency 'omniauth-oauth', '~> 1.0.0'
+ s.add_runtime_dependency 'omniauth-oauth2', '~> 1.0.0'
s.add_development_dependency 'rspec', '~> 2.7.0'
s.add_development_dependency 'rake'
@@ -2,11 +2,11 @@
describe "OmniAuth::Strategies::Viadeo" do
subject do
- OmniAuth::Strategies::Viadeo.new(nil, @options || {})
+ OmniAuth::Strategies::Viadeo.new(nil)
end
context 'client options' do
- it 'has correct LinkedIn site' do
+ it 'has correct Viadeo api site' do
subject.options.client_options.site.should eq('https://api.viadeo.com/')
end

0 comments on commit 703e142

Please sign in to comment.