Skip to content

Commit 458ef40

Browse files
authored
Merge pull request #3165 from CandleScience/carton-paranoia
Ensure cartons find soft deleted shipping methods
2 parents 6036639 + ee4c286 commit 458ef40

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

core/app/models/spree/carton.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
class Spree::Carton < Spree::Base
44
belongs_to :address, class_name: 'Spree::Address', optional: true
55
belongs_to :stock_location, class_name: 'Spree::StockLocation', inverse_of: :cartons, optional: true
6-
belongs_to :shipping_method, class_name: 'Spree::ShippingMethod', inverse_of: :cartons, optional: true
6+
belongs_to :shipping_method, -> { with_discarded }, class_name: 'Spree::ShippingMethod', inverse_of: :cartons, optional: true
77

88
has_many :inventory_units, class_name: "Spree::InventoryUnit", inverse_of: :carton, dependent: :nullify
99
has_many :orders, -> { distinct }, through: :inventory_units

core/spec/models/spree/carton_spec.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@
55
RSpec.describe Spree::Carton do
66
let(:carton) { create(:carton) }
77

8+
describe 'shipping method' do
9+
it 'returns soft deleted shipping method' do
10+
carton = create(:carton)
11+
carton.shipping_method.discard
12+
expect(carton.reload.shipping_method).to be_present
13+
end
14+
end
15+
816
describe "#create" do
917
subject { carton }
1018

0 commit comments

Comments
 (0)