Add tax category to sample products

This commit is contained in:
luisramos0
2019-10-27 19:59:35 +00:00
parent 237cd5438b
commit f396f6bebd

View File

@@ -72,10 +72,18 @@ class ProductFactory
variant_unit: "weight",
variant_unit_scale: 1,
unit_value: 1,
shipping_category: DefaultShippingCategory.find_or_create
shipping_category: DefaultShippingCategory.find_or_create,
tax_category_id: find_or_create_tax_category.id
)
product = Spree::Product.create_with(params).find_or_create_by_name!(params[:name])
product.variants.first.update_attribute :on_demand, true
product
end
def find_or_create_tax_category
tax_category_name = "Tax Category"
tax_category = Spree::TaxCategory.find_by_name(tax_category_name)
tax_category ||= Spree::TaxCategory.create!(name: tax_category_name)
tax_category
end
end