diff --git a/core/app/models/spree/shipment.rb b/core/app/models/spree/shipment.rb index 388b8836ec1..67203f8e9c0 100644 --- a/core/app/models/spree/shipment.rb +++ b/core/app/models/spree/shipment.rb @@ -12,7 +12,7 @@ class Shipment < Spree::Base has_many :shipping_rates, -> { order(:cost) }, dependent: :destroy, inverse_of: :shipment has_many :shipping_methods, through: :shipping_rates has_many :state_changes, as: :stateful - has_many :cartons, -> { uniq }, through: :inventory_units + has_many :cartons, -> { distinct }, through: :inventory_units before_validation :set_cost_zero_when_nil diff --git a/core/spec/models/spree/shipment_spec.rb b/core/spec/models/spree/shipment_spec.rb index 4cc6911b9bb..6057955ffd5 100644 --- a/core/spec/models/spree/shipment_spec.rb +++ b/core/spec/models/spree/shipment_spec.rb @@ -895,4 +895,13 @@ end end end + + describe '#cartons' do + let(:carton) { create(:carton) } + let(:shipment) { carton.shipments.first } + + subject { shipment.cartons } + + it { is_expected.to include carton } + end end