Skip to content

Commit

Permalink
Rubocop fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
zquestz committed Sep 16, 2024
1 parent 405db19 commit 772f760
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,5 @@ Style/HashTransformKeys:
Enabled: false
Style/HashTransformValues:
Enabled: false
AllCops:
NewCops: enable
7 changes: 4 additions & 3 deletions lib/omniauth/strategies/google_oauth2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -202,15 +202,16 @@ def image_size_opts_passed?

def image_params
image_params = []
if options[:image_size].is_a?(Integer)
case options[:image_size]
when Integer
image_params << "s#{options[:image_size]}"
elsif options[:image_size].is_a?(Hash)
when Hash
image_params << "w#{options[:image_size][:width]}" if options[:image_size][:width]
image_params << "h#{options[:image_size][:height]}" if options[:image_size][:height]
end
image_params << 'c' if options[:image_aspect_ratio] == 'square'

'/' + image_params.join('-')
"/#{image_params.join('-')}"
end

def strip_unnecessary_query_parameters(query_parameters)
Expand Down
6 changes: 3 additions & 3 deletions spec/omniauth/strategies/google_oauth2_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -324,20 +324,20 @@
it 'has the correct default callback path' do
allow(subject).to receive(:full_host) { base_url }
allow(subject).to receive(:script_name) { '' }
expect(subject.send(:callback_url)).to eq(base_url + '/auth/google_oauth2/callback')
expect(subject.send(:callback_url)).to eq("#{base_url}/auth/google_oauth2/callback")
end

it 'should set the callback path with script_name if present' do
allow(subject).to receive(:full_host) { base_url }
allow(subject).to receive(:script_name) { '/v1' }
expect(subject.send(:callback_url)).to eq(base_url + '/v1/auth/google_oauth2/callback')
expect(subject.send(:callback_url)).to eq("#{base_url}/v1/auth/google_oauth2/callback")
end

it 'should set the callback_path parameter if present' do
@options = { callback_path: '/auth/foo/callback' }
allow(subject).to receive(:full_host) { base_url }
allow(subject).to receive(:script_name) { '' }
expect(subject.send(:callback_url)).to eq(base_url + '/auth/foo/callback')
expect(subject.send(:callback_url)).to eq("#{base_url}/auth/foo/callback")
end
end

Expand Down

0 comments on commit 772f760

Please sign in to comment.