File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed
core/spec/models/spree/order Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change 11require 'spec_helper'
2+ require 'spree/testing_support/order_walkthrough'
23
34describe 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 ) { { } }
You can’t perform that action at this time.
0 commit comments