Skip to content

Commit

Permalink
Add failing test showing payment processing is set in a transaction.
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Salzberg committed Apr 4, 2014
1 parent 67894be commit 54f6df0
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions core/spec/models/spree/order/checkout_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require 'spec_helper'
require 'spree/testing_support/order_walkthrough'

describe Spree::Order do
let(:order) { Spree::Order.new }
Expand Down Expand Up @@ -413,6 +414,32 @@ class SubclassedOrder < Spree::Order
end
end

describe "payment processing" do
# Turn off transactional fixtures so that we can test that
# processing state is persisted.
self.use_transactional_fixtures = false
before(:all) { DatabaseCleaner.strategy = :truncation }
after(:all) do
DatabaseCleaner.clean
DatabaseCleaner.strategy = :transaction
end
let(:order) { OrderWalkthrough.up_to(:payment) }
let(:creditcard) { create(:credit_card) }
let!(:payment_method) { create(:credit_card_payment_method, :environment => 'test') }

it "does not process payment within transaction" do
# Make sure we are not already in a transaction
ActiveRecord::Base.connection.open_transactions.should == 0

Spree::Payment.any_instance.should_receive(:authorize!) do
ActiveRecord::Base.connection.open_transactions.should == 0
end

order.payments.create!({ :amount => order.outstanding_balance, :payment_method => payment_method, :source => creditcard })
order.next!
end
end

describe 'update_from_params' do
let(:permitted_params) { {} }
let(:params) { {} }
Expand Down

0 comments on commit 54f6df0

Please sign in to comment.