Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure cartons find soft deleted shipping methods #3165

Merged
merged 1 commit into from
Oct 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/app/models/spree/carton.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
class Spree::Carton < Spree::Base
belongs_to :address, class_name: 'Spree::Address', optional: true
belongs_to :stock_location, class_name: 'Spree::StockLocation', inverse_of: :cartons, optional: true
belongs_to :shipping_method, class_name: 'Spree::ShippingMethod', inverse_of: :cartons, optional: true
belongs_to :shipping_method, -> { with_discarded }, class_name: 'Spree::ShippingMethod', inverse_of: :cartons, optional: true

has_many :inventory_units, class_name: "Spree::InventoryUnit", inverse_of: :carton, dependent: :nullify
has_many :orders, -> { distinct }, through: :inventory_units
Expand Down
8 changes: 8 additions & 0 deletions core/spec/models/spree/carton_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@
RSpec.describe Spree::Carton do
let(:carton) { create(:carton) }

describe 'shipping method' do
it 'returns soft deleted shipping method' do
carton = create(:carton)
carton.shipping_method.discard
expect(carton.reload.shipping_method).to be_present
end
pelargir marked this conversation as resolved.
Show resolved Hide resolved
end

describe "#create" do
subject { carton }

Expand Down