Skip to content

Commit

Permalink
updated initializer, added more help
Browse files Browse the repository at this point in the history
  • Loading branch information
gacha committed May 17, 2011
1 parent 9cd749f commit 3be1f83
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
20 changes: 15 additions & 5 deletions oa-more/lib/omniauth/strategies/draugiem.rb
Expand Up @@ -8,17 +8,27 @@ module Strategies
#
# Authenticate to draugiem.lv and frype.com and others.
#
# @example Basic Usage
# @example Basic Rails Usage
#
# Add this to config/initializers/omniauth.rb
#
# Rails.application.config.middleware.use OmniAuth::Builder do
# provider :draugiem, 'App id', 'API Key'
# end
#
# @example Basic Rack example
#
# use Rack::Session::Cookie
# use OmniAuth::Strategies::Draugiem, 'App id', 'API Key'
#
# use OmniAuth::Strategies::Draugiem, 'API Key', 'App id'
class Draugiem
include OmniAuth::Strategy
attr_accessor :api_key, :app_id, :options
attr_accessor :app_id, :api_key

def initialize(app, api_key, app_id)
def initialize(app, app_id, api_key)
super(app, :draugiem)
@api_key = api_key
@app_id = app_id
@api_key = api_key
end

protected
Expand Down
5 changes: 2 additions & 3 deletions oa-more/spec/omniauth/strategies/draugiem_spec.rb
Expand Up @@ -5,11 +5,11 @@
include OmniAuth::Test::StrategyTestCase

def strategy
[OmniAuth::Strategies::Draugiem, "abc",123]
[OmniAuth::Strategies::Draugiem, '123', "abc"]
end

it 'should initialize with api key and app id' do
lambda{OmniAuth::Strategies::Draugiem.new({},'abc','123')}.should_not raise_error
lambda{OmniAuth::Strategies::Draugiem.new({},'123','abc')}.should_not raise_error
end

describe '/auth/draugiem' do
Expand Down Expand Up @@ -41,7 +41,6 @@ def strategy
}
}))
get '/auth/draugiem/callback?dr_auth_status=ok&dr_auth_code=123456'
debugger

last_request.env['omniauth.auth']['credentials']['apikey'].should == "123456789"
last_request.env['omniauth.auth']['user_info']['location'].should == "Durbe"
Expand Down

0 comments on commit 3be1f83

Please sign in to comment.