Fix touch call to unsaved object

Failure/Error: enterprise.andand.touch

       ActiveRecord::ActiveRecordError:
         cannot touch on a new or destroyed record object. Consider using persisted?, new_record?, or destroyed? before touching
       # ./app/models/spree/address.rb:155:in `touch_enterprise'
       # ./spec/factories/product_factory.rb:12:in `block (3 levels) in <top (required)>'
       # ./spec/factories/variant_factory.rb:26:in `block (4 levels) in <top (required)>'
       # ./spec/models/spree/variant_spec.rb:9:in `block (2 levels) in <module:Spree>'
This commit is contained in:
Matt-Yorkley
2021-03-11 16:14:50 +00:00
committed by Luis Ramos
parent bdbeb2feb8
commit ee0da87681

View File

@@ -152,7 +152,9 @@ module Spree
end
def touch_enterprise
enterprise.andand.touch
return unless enterprise&.persisted?
enterprise.touch
end
def render_address(parts)