mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
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:
committed by
Neal Chambers
parent
fec59e5ae2
commit
cd34e160bf
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user