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

Commit

Permalink
Stub for error_container
Browse files Browse the repository at this point in the history
  • Loading branch information
osahyoun committed Apr 27, 2016
1 parent 7a8ff62 commit 90d555d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 2 additions & 0 deletions app/controllers/payment_controller.rb
Expand Up @@ -18,7 +18,9 @@ def transaction
end
else
@errors = client::ErrorProcessing.new(builder.error_container).process

@page = page

respond_to do |format|
format.html { render 'payment/donation_errors', layout: 'sumofus' }
format.json { render json: { success: false, errors: @errors }, status: 422 }
Expand Down
14 changes: 9 additions & 5 deletions spec/controllers/api/payment/braintree_controller_spec.rb
@@ -1,7 +1,11 @@
require 'rails_helper'

describe Api::Payment::BraintreeController do
before do
allow(Page).to receive(:find){ page }
end

let(:page) { instance_double("Page") }
let(:action) { instance_double("Action", member_id: 79) }

describe "GET token" do
Expand All @@ -21,8 +25,8 @@
end

describe "POST transaction" do

let(:client) { PaymentProcessor::Clients::Braintree }

let(:params) do
{
payment_method_nonce: 'wqeuinv-50238-FIERN',
Expand All @@ -32,6 +36,7 @@
page_id: '12'
}
end

let(:payment_options) do
{
nonce: params[:payment_method_nonce],
Expand All @@ -41,11 +46,11 @@
page_id: params[:page_id]
}
end

before :each do
request.accept = "application/json" # ask for json
end


describe 'successfully' do

describe 'with recurring: true' do
Expand Down Expand Up @@ -104,7 +109,6 @@
end

describe 'unsuccessfully' do

let(:errors) { instance_double('PaymentProcessor::Clients::Braintree::ErrorProcessing', process: {my_error: 'foo'}) }

before :each do
Expand All @@ -113,7 +117,7 @@

describe 'with recurring: true' do

let(:builder){ instance_double('PaymentProcessor::Clients::Braintree::Subscription', success?: false, result: {}) }
let(:builder){ instance_double('PaymentProcessor::Clients::Braintree::Subscription', success?: false, error_container: {}) }

before do
allow(client::Subscription).to receive(:make_subscription).and_return(builder)
Expand Down Expand Up @@ -145,7 +149,7 @@
describe 'without recurring' do

let(:transaction) { instance_double('Braintree::Transaction', id: 't1234')}
let(:builder){ instance_double('PaymentProcessor::Clients::Braintree::Transaction', success?: false, result: {}) }
let(:builder){ instance_double('PaymentProcessor::Clients::Braintree::Transaction', success?: false, error_container: {}) }

before :each do
allow(client::Transaction).to receive(:make_transaction).and_return(builder)
Expand Down

0 comments on commit 90d555d

Please sign in to comment.