Fix deleting of return_authorizations

return_authorizations have a stock_location_id, not the other way round. So there's no dependent field to nullify.
This commit is contained in:
David Cook
2023-10-03 14:52:08 +11:00
committed by Neal Chambers
parent fec59e5ae2
commit cd34e160bf
2 changed files with 13 additions and 1 deletions

View File

@@ -9,7 +9,7 @@ module Spree
belongs_to :order, class_name: 'Spree::Order', inverse_of: :return_authorizations
has_many :inventory_units, inverse_of: :return_authorization, dependent: :nullify
has_one :stock_location, dependent: :nullify
has_one :stock_location, dependent: nil
before_save :force_positive_amount
before_create :generate_number

View File

@@ -33,6 +33,18 @@ module Spree
expect(return_authorization.amount.to_s).to eq "10.2"
expect(return_authorization.reason.to_s).to eq "half broken"
end
context "with a return authorization" do
let!(:return_authorization) { create(:return_authorization, order:) }
it "deletes a return authorization" do
expect{
spree_delete :destroy, id: return_authorization.id, order_id: order.number
}.to change { order.return_authorizations.without_deleted.count }.by(-1)
expect(response).to redirect_to spree.admin_order_return_authorizations_url(order.number)
end
end
end
end
end