Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions lib/omniauth/strategies/box_oauth2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,21 @@ class BoxOauth2 < OmniAuth::Strategies::OAuth2
address: raw_info['address'],
status: raw_info['status']
}
end
end

extra do
extra do
{ raw_info: raw_info }
end

private
def callback_url
full_host + script_name + callback_path
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implements fix identified by @aguynamedben in #1 (comment)

end

private

def raw_info
@raw_info ||= access_token.get('users/me').parsed || {}
end
end
end
end
end
end
18 changes: 14 additions & 4 deletions spec/omniauth/strategies/box_oauth2_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
end

it 'has a version number' do
require 'omniauth/box_oauth2/version'
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test was failing without explicitly requiring this.

expect(OmniAuth::BoxOauth2::VERSION).not_to be nil
end

Expand All @@ -44,9 +45,18 @@
end

describe '#callback_path' do
before :each do
allow(subject).to receive(:full_host) { 'http://localhost:3000' }
allow(subject).to receive(:script_name) { '' }
end

it 'has the correct callback path' do
expect(subject.callback_path).to eq('/auth/box_oauth2/callback')
end

it 'has the correct callback url' do
expect(subject.callback_url).to eq('http://localhost:3000/auth/box_oauth2/callback')
end
end

describe '#uid' do
Expand Down Expand Up @@ -99,10 +109,10 @@
describe '#access_token' do
before :each do
response = double('access token',
access_token: 'access_token',
access_token: 'access_token',
refresh_token: 'refresh_token',
expires_in: 3600,
expires_at: 12345,
expires_in: 3600,
expires_at: 12345,
).as_null_object
allow(subject).to receive(:access_token) { response }
end
Expand All @@ -112,4 +122,4 @@
it { expect(subject.access_token.expires_at).to eq(12345) }
it { expect(subject.access_token.refresh_token).to eq('refresh_token') }
end
end
end
2 changes: 0 additions & 2 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
require 'codeclimate-test-reporter'
CodeClimate::TestReporter.start
require 'omniauth/box_oauth2'