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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
*.gem
.bundle
.idea
Gemfile.lock
pkg/*
coverage
2 changes: 1 addition & 1 deletion lib/omniauth-square/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Omniauth
module Square
VERSION = "1.0.2"
VERSION = "1.0.3"
end
end
13 changes: 12 additions & 1 deletion lib/omniauth/strategies/square.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,24 @@ def raw_info
@raw_info ||= access_token.get('/v1/me').parsed
end

alias :old_request_phase :request_phase

def request_phase
if request.params['plan_id']
options[:authorize_params][:plan_id] = request.params['plan_id']
end

old_request_phase
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of aliasing, couldn't you just say super here?

Copy link
Author

Choose a reason for hiding this comment

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

I have tried to use super, but then added test is failed, seems like it doesn't work.

Copy link
Author

Choose a reason for hiding this comment

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

@rzane do I need to do something else to get this PR merged?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not the maintainer, just a past contributor. Therefore, you need @dja to merge.

Copy link
Owner

Choose a reason for hiding this comment

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

@vdolgishev I'm working on some updates to the gem overall, so this should be merged in very soon.

Copy link
Author

Choose a reason for hiding this comment

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

@dja do you need some help with updates?

end

protected

def build_access_token
parsed_response = fetch_access_token

parsed_response['expires_at'] = Time.parse(parsed_response['expires_at']).to_i
parsed_response.merge!(deep_symbolize(options.auth_token_params))
auth_token_params = options.auth_token_params || {}
parsed_response.merge!(deep_symbolize(auth_token_params))

connect_client = client.dup
connect_client.site = options.client_options.connect_site
Expand Down
1 change: 1 addition & 0 deletions omniauth-square.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ Gem::Specification.new do |s|
s.add_development_dependency 'rack-test'
s.add_development_dependency 'simplecov'
s.add_development_dependency 'webmock'
s.add_development_dependency 'pry'
end
14 changes: 13 additions & 1 deletion spec/omniauth/strategies/square_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

describe OmniAuth::Strategies::Square do
before :each do
@request = double('Request', :scheme => '', :url => '')
@request = double('Request', :scheme => '', :url => '', :params => {}, :cookies => {}, :env => {})
@request.stub(:params) { {} }
end

Expand Down Expand Up @@ -150,6 +150,18 @@
end
end

describe '#request_phase' do
before do
@request.stub(:params).and_return('plan_id' => 'test_plan_id')
subject.stub(:old_request_phase).and_return(:something)
end

it 'adds `plan_id` parameter to `authorize_params`' do
expect { subject.request_phase }.to change { subject.options.authorize_params.plan_id }.
from(nil).to('test_plan_id')
end
end

describe '#access_token_request_payload' do
before do
@request.stub(:params).and_return('code' => '11111')
Expand Down
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
require 'webmock/rspec'
require 'omniauth'
require 'omniauth-square'
require 'pry'

RSpec.configure do |config|
config.include WebMock::API
Expand Down