Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix handling of cancel_uri

  • Loading branch information...
commit 5419dbc835200968f2652c1bd6d555dcc1d678e3 1 parent 9cf23a7
@hmarr hmarr authored
Showing with 18 additions and 0 deletions.
  1. +2 −0  lib/gocardless/client.rb
  2. +16 −0 spec/client_spec.rb
View
2  lib/gocardless/client.rb
@@ -338,6 +338,7 @@ def new_limit_url(type, limit_params)
limit_params[:merchant_id] = merchant_id
redirect_uri = limit_params.delete(:redirect_uri)
+ cancel_uri = limit_params.delete(:cancel_uri)
state = limit_params.delete(:state)
params = {
@@ -347,6 +348,7 @@ def new_limit_url(type, limit_params)
type => limit_params,
}
params[:redirect_uri] = redirect_uri unless redirect_uri.nil?
+ params[:cancel_uri] = cancel_uri unless cancel_uri.nil?
params[:state] = state unless state.nil?
sign_params(params)
View
16 spec/client_spec.rb
@@ -64,6 +64,16 @@
query['client_id'].first.should == @app_id
end
+ it "includes the cancel uri if present" do
+ cancel_uri = 'http://test/cancel'
+ url = URI.parse(@client.authorize_url(
+ :redirect_uri => @redirect_uri,
+ :cancel_uri => cancel_uri
+ ))
+ query = CGI.parse(url.query)
+ query['cancel_uri'].first.should == cancel_uri
+ end
+
it "encodes prefilling parameters correctly" do
params = {:merchant => {:user => {:email => "a@b.com"}}}
url = @client.authorize_url(params.merge(:redirect_uri => @redirect_uri))
@@ -363,6 +373,12 @@ def get_params(url)
get_params(url)["redirect_uri"].should == "http://www.google.com"
end
+ it "should include the cancel_uri in the URL query" do
+ params = { 'a' => '1', 'b' => '2', :cancel_uri => "http://www.google.com" }
+ url = @client.send(:new_limit_url, :subscription, params)
+ get_params(url)["cancel_uri"].should == "http://www.google.com"
+ end
+
it "should add merchant_id to the limit" do
url = @client.send(:new_limit_url, :subscription, {})
get_params(url)['subscription[merchant_id]'].should == @merchant_id
Please sign in to comment.
Something went wrong with that request. Please try again.