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

Commit

Permalink
Update controller specs
Browse files Browse the repository at this point in the history
  • Loading branch information
osahyoun committed Apr 27, 2016
1 parent 90d555d commit cdf0229
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
3 changes: 1 addition & 2 deletions app/controllers/api/go_cardless_controller.rb
Expand Up @@ -2,10 +2,9 @@ class Api::GoCardlessController < PaymentController
skip_before_action :verify_authenticity_token

def start_flow
# session.id is nil until something is stored in the session, so might
# as well make it explicit what we're using the id for.
session[:go_cardless_session_id] = SecureRandom.uuid
flow = GoCardlessDirector.new(session[:go_cardless_session_id], success_url, params)

if flow.success?
redirect_to flow.redirect_url
else
Expand Down
8 changes: 4 additions & 4 deletions spec/controllers/api/go_cardless_controller_spec.rb
Expand Up @@ -5,11 +5,11 @@

before do
allow(Page).to receive(:find) { page }
allow(request.session).to receive(:id) { 'fake_session_id' }
allow(SecureRandom).to receive(:uuid) { 'fake_session_id' }
end

describe 'GET #start_flow' do
let(:director) { double(:director, redirect_url: "http://example.com/redirect_url") }
let(:director) { double(:director, success?: true, redirect_url: "http://example.com/redirect_url") }

before do
allow(GoCardlessDirector).to receive(:new){ director }
Expand All @@ -21,7 +21,7 @@

it 'instantiates GoCardlessDirector' do
expect(GoCardlessDirector).to have_received(:new).
with('fake_session_id', "http://test.host/api/go_cardless/pages/1/transaction?foo=bar&page_id=1")
with('fake_session_id', "http://test.host/api/go_cardless/pages/1/transaction?foo=bar&page_id=1", controller.params)
end

it 'redirects' do
Expand All @@ -41,7 +41,7 @@

it 'creates GC transaction' do
expect(PaymentProcessor::GoCardless::Transaction).to(
have_received(:make_transaction).with(hash_including({session_token: 'fake_session_id'}))
have_received(:make_transaction).with(hash_including({page_id: '1'}))
)
end
end
Expand Down

0 comments on commit cdf0229

Please sign in to comment.