Skip to content

Commit

Permalink
Remove backwards compatible with 1.0.x
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergey Sein committed Aug 24, 2018
1 parent 5e2fb7a commit bb4cec2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 19 deletions.
6 changes: 1 addition & 5 deletions lib/omniauth/strategies/gitlab.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,11 @@ class GitLab < OmniAuth::Strategies::OAuth2
end

def raw_info
@raw_info ||= access_token.get(user_endpoint_url).parsed
@raw_info ||= access_token.get('user').parsed
end

private

def user_endpoint_url
options.client_options.site.match(%r{v(\d+)/?$}) ? 'user' : '/api/v3/user'
end

def callback_url
options.redirect_url || (full_host + script_name + callback_path)
end
Expand Down
17 changes: 3 additions & 14 deletions spec/omniauth/strategies/gitlab_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,9 @@
end

describe '#raw_info' do
context 'with new configuration' do
it 'sent request to current user endpoint' do
expect(access_token).to receive(:get).with('user').and_return(response)
expect(subject.raw_info).to eq(parsed_response)
end
end

context 'with old style configuration' do
let(:enterprise_site) { 'https://some.other.site.com/' }
subject { enterprise }
it 'sent request to current user endpoint' do
expect(access_token).to receive(:get).with('/api/v3/user').and_return(response)
expect(subject.raw_info).to eq(parsed_response)
end
it 'sent request to current user endpoint' do
expect(access_token).to receive(:get).with('user').and_return(response)
expect(subject.raw_info).to eq(parsed_response)
end
end
end

0 comments on commit bb4cec2

Please sign in to comment.