Permalink
Browse files

Add failing test showing payment processing is set in a transaction.

  • Loading branch information...
shioyama committed Mar 27, 2014
1 parent 67894be commit 54f6df0b4aad720eb50a07ca9423532d29264287
Showing with 27 additions and 0 deletions.
  1. +27 −0 core/spec/models/spree/order/checkout_spec.rb
@@ -1,4 +1,5 @@
require 'spec_helper'
require 'spree/testing_support/order_walkthrough'
describe Spree::Order do
let(:order) { Spree::Order.new }
@@ -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) { {} }

0 comments on commit 54f6df0

Please sign in to comment.