Add fallbacks in migration for migrating locally with RAILS_ENV=test

Instances have these preference values set, but when running this migration locally with RAILS_ENV=test, the preference does not exist in the database.
This commit is contained in:
Matt-Yorkley
2021-03-18 17:01:04 +00:00
parent fec2b0b7c1
commit fcdc627ce3

View File

@@ -25,11 +25,11 @@ class MigrateShippingTaxes < ActiveRecord::Migration
end
def instance_uses_shipping_tax?
Spree::Preference.find_by(key: '/spree/app_configuration/shipment_inc_vat').value
Spree::Preference.find_by(key: '/spree/app_configuration/shipment_inc_vat')&.value || false
end
def instance_shipping_tax_rate
Spree::Preference.find_by(key: '/spree/app_configuration/shipping_tax_rate').value
Spree::Preference.find_by(key: '/spree/app_configuration/shipping_tax_rate')&.value || 0.0
end
def shipping_tax_category