diff --git a/build-ci.rb b/build-ci.rb index 800d08ba3fa..4d3092cf134 100755 --- a/build-ci.rb +++ b/build-ci.rb @@ -20,7 +20,7 @@ def initialize(name) @name = name end - ALL = %w[api backend core frontend sample].map(&method(:new)).freeze + ALL = %w[api backend core].map(&method(:new)).freeze # Install subproject # diff --git a/circle.yml b/circle.yml index b387c066899..8fc50cd8afc 100644 --- a/circle.yml +++ b/circle.yml @@ -1,11 +1,11 @@ --- machine: environment: - DB: postgresql + DB: mysql services: - - postgresql + - mysql ruby: - version: 2.1.5 + version: 2.2.5 dependencies: override: - bundle check --path=vendor/bundle || bundle install --path=vendor/bundle diff --git a/core/app/models/spree/order.rb b/core/app/models/spree/order.rb index 39dcd4bb431..4724915818d 100644 --- a/core/app/models/spree/order.rb +++ b/core/app/models/spree/order.rb @@ -48,7 +48,7 @@ class CannotRebuildShipments < StandardError; end belongs_to :store, class_name: 'Spree::Store' has_many :state_changes, as: :stateful has_many :line_items, -> { order(:created_at, :id) }, dependent: :destroy, inverse_of: :order - has_many :payments, dependent: :destroy + has_many :payments, dependent: :destroy, inverse_of: :order has_many :return_authorizations, dependent: :destroy, inverse_of: :order has_many :reimbursements, inverse_of: :order has_many :adjustments, -> { order(:created_at) }, as: :adjustable, inverse_of: :adjustable, dependent: :destroy diff --git a/core/app/models/spree/order_capturing.rb b/core/app/models/spree/order_capturing.rb index bd5c5222a68..3868bb3fc83 100644 --- a/core/app/models/spree/order_capturing.rb +++ b/core/app/models/spree/order_capturing.rb @@ -21,22 +21,15 @@ def capture_payments Spree::OrderMutex.with_lock!(@order) do uncaptured_amount = @order.display_total.cents - begin - sorted_payments(@order).each do |payment| - amount = [uncaptured_amount, payment.money.cents].min - - if amount > 0 - payment.capture!(amount) - uncaptured_amount -= amount - elsif Spree::OrderCapturing.void_unused_payments - payment.void_transaction! - end + sorted_payments(@order).each do |payment| + amount = [uncaptured_amount, payment.money.cents].min + + if amount > 0 + payment.capture!(amount) + uncaptured_amount -= amount + elsif Spree::OrderCapturing.void_unused_payments + payment.void_transaction! end - ensure - # FIXME: Adding the inverse_of on the payments relation for orders -should- fix this, - # however it only appears to make it worse (calling with changes three times instead of once. - # Warrants an investigation. Reloading for now. - @order.reload.update! end end end diff --git a/core/spec/models/spree/order_capturing_spec.rb b/core/spec/models/spree/order_capturing_spec.rb index a2980cc2d2f..362f204121c 100644 --- a/core/spec/models/spree/order_capturing_spec.rb +++ b/core/spec/models/spree/order_capturing_spec.rb @@ -4,8 +4,8 @@ describe '#capture_payments' do subject { Spree::OrderCapturing.new(order, payment_methods).capture_payments } - # Regression for the order.update! in the ensure block. - # See the comment there. + # Regression for https://github.com/solidusio/solidus/pull/407 + # See also https://github.com/solidusio/solidus/pull/1406 context "updating the order" do let(:order) { create :completed_order_with_totals } let(:payment_methods) { [] } @@ -14,6 +14,7 @@ before do payment.pend! + order.save! allow_any_instance_of(Spree::Order).to receive(:thingamajig) do |order| changes_spy.change_callback_occured if order.changes.any?