Skip to content

Commit 54f6df0

Browse files
author
Chris Salzberg
committed
Add failing test showing payment processing is set in a transaction.
1 parent 67894be commit 54f6df0

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

core/spec/models/spree/order/checkout_spec.rb

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
require 'spec_helper'
2+
require 'spree/testing_support/order_walkthrough'
23

34
describe Spree::Order do
45
let(:order) { Spree::Order.new }
@@ -413,6 +414,32 @@ class SubclassedOrder < Spree::Order
413414
end
414415
end
415416

417+
describe "payment processing" do
418+
# Turn off transactional fixtures so that we can test that
419+
# processing state is persisted.
420+
self.use_transactional_fixtures = false
421+
before(:all) { DatabaseCleaner.strategy = :truncation }
422+
after(:all) do
423+
DatabaseCleaner.clean
424+
DatabaseCleaner.strategy = :transaction
425+
end
426+
let(:order) { OrderWalkthrough.up_to(:payment) }
427+
let(:creditcard) { create(:credit_card) }
428+
let!(:payment_method) { create(:credit_card_payment_method, :environment => 'test') }
429+
430+
it "does not process payment within transaction" do
431+
# Make sure we are not already in a transaction
432+
ActiveRecord::Base.connection.open_transactions.should == 0
433+
434+
Spree::Payment.any_instance.should_receive(:authorize!) do
435+
ActiveRecord::Base.connection.open_transactions.should == 0
436+
end
437+
438+
order.payments.create!({ :amount => order.outstanding_balance, :payment_method => payment_method, :source => creditcard })
439+
order.next!
440+
end
441+
end
442+
416443
describe 'update_from_params' do
417444
let(:permitted_params) { {} }
418445
let(:params) { {} }

0 commit comments

Comments
 (0)