From 4af16bc47e73cdfdc09324a0394b4be284ca4f88 Mon Sep 17 00:00:00 2001 From: Omar Sahyoun Date: Fri, 15 Apr 2016 16:28:47 +0100 Subject: [PATCH] Fixes broken controller spec for gocardless --- app/controllers/api/go_cardless_controller.rb | 13 ++++--------- spec/controllers/api/go_cardless_controller_spec.rb | 4 ++-- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/app/controllers/api/go_cardless_controller.rb b/app/controllers/api/go_cardless_controller.rb index 9183b1945..c30907c46 100644 --- a/app/controllers/api/go_cardless_controller.rb +++ b/app/controllers/api/go_cardless_controller.rb @@ -33,7 +33,6 @@ def start_flow end def payment_complete - # If one-off payment builder.make_transaction(params, session.id) render json: {success: builder.success?, params: params} end @@ -48,15 +47,11 @@ def builder PaymentProcessor::GoCardless::Transaction end - def client - GoCardlessPro::Client.new( - access_token: Settings.gocardless.token, - environment: Settings.gocardless.environment.to_sym - ) - end - def success_url - local_params = URI.parse(request.url).query + "&page_id=#{params[:page_id]}" + local_params = Rack::Utils.parse_query( + URI.parse(request.url).query + ).merge( params.slice(:page_id) ).to_query + "#{request.base_url}/api/go_cardless/payment_complete?#{local_params}" end end diff --git a/spec/controllers/api/go_cardless_controller_spec.rb b/spec/controllers/api/go_cardless_controller_spec.rb index ad4c3def2..dcac50b96 100644 --- a/spec/controllers/api/go_cardless_controller_spec.rb +++ b/spec/controllers/api/go_cardless_controller_spec.rb @@ -14,11 +14,11 @@ subject end - subject { get :start_flow, foo: 'bar' } + subject { get :start_flow, page_id: '1', foo: 'bar' } it 'instantiates GoCardlessDirector' do expect(GoCardlessDirector).to have_received(:new). - with('fake_session_id', "http://test.host/api/go_cardless/payment_complete?foo=bar") + with('fake_session_id', "http://test.host/api/go_cardless/payment_complete?foo=bar&page_id=1") end it 'redirects' do