Skip to content
This repository has been archived by the owner on Mar 27, 2023. It is now read-only.

Commit

Permalink
Fixes broken controller spec for gocardless
Browse files Browse the repository at this point in the history
  • Loading branch information
osahyoun committed Apr 15, 2016
1 parent f6275ed commit 4af16bc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
13 changes: 4 additions & 9 deletions app/controllers/api/go_cardless_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
4 changes: 2 additions & 2 deletions spec/controllers/api/go_cardless_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4af16bc

Please sign in to comment.