From 97d9aadb69b27405e00e07be0207354082d41869 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Sat, 15 Jul 2023 16:26:20 +0100 Subject: [PATCH] Update specs --- spec/controllers/api/v0/products_controller_spec.rb | 3 +-- spec/controllers/api/v0/reports/packing_report_spec.rb | 4 ++-- spec/factories/product_factory.rb | 2 -- spec/models/product_importer_spec.rb | 2 +- spec/models/spree/order/checkout_spec.rb | 3 +-- spec/system/admin/product_import_spec.rb | 2 +- spec/system/admin/products_spec.rb | 2 +- 7 files changed, 7 insertions(+), 11 deletions(-) diff --git a/spec/controllers/api/v0/products_controller_spec.rb b/spec/controllers/api/v0/products_controller_spec.rb index c48af9ba66..730c8ed8bd 100644 --- a/spec/controllers/api/v0/products_controller_spec.rb +++ b/spec/controllers/api/v0/products_controller_spec.rb @@ -102,8 +102,7 @@ describe Api::V0::ProductsController, type: :controller do expect(response.status).to eq(422) expect(json_response["error"]).to eq("Invalid resource. Please fix errors and try again.") errors = json_response["errors"] - expect(errors.keys).to match_array(["name", "primary_taxon", "shipping_category", - "supplier", "variant_unit"]) + expect(errors.keys).to match_array(["name", "primary_taxon", "supplier", "variant_unit"]) end it "can update a product" do diff --git a/spec/controllers/api/v0/reports/packing_report_spec.rb b/spec/controllers/api/v0/reports/packing_report_spec.rb index 9cec0b7c7f..2dcdc9f284 100644 --- a/spec/controllers/api/v0/reports/packing_report_spec.rb +++ b/spec/controllers/api/v0/reports/packing_report_spec.rb @@ -71,7 +71,7 @@ describe Api::V0::ReportsController, type: :controller do "variant" => line_item.full_name, "quantity" => line_item.quantity, "price" => (line_item.quantity * line_item.price).to_s, - "temp_controlled" => line_item.product.shipping_category&.temperature_controlled + "temp_controlled" => line_item.variant.shipping_category&.temperature_controlled }. merge(dimensions(line_item)). merge(contacts(line_item.order.bill_address)) @@ -89,7 +89,7 @@ describe Api::V0::ReportsController, type: :controller do "variant" => line_item.full_name, "quantity" => line_item.quantity, "price" => (line_item.quantity * line_item.price).to_s, - "temp_controlled" => line_item.product.shipping_category&.temperature_controlled + "temp_controlled" => line_item.variant.shipping_category&.temperature_controlled }.merge(dimensions(line_item)) end diff --git a/spec/factories/product_factory.rb b/spec/factories/product_factory.rb index 06a7aef77c..320060563f 100644 --- a/spec/factories/product_factory.rb +++ b/spec/factories/product_factory.rb @@ -18,8 +18,6 @@ FactoryBot.define do variant_unit_scale { 1 } variant_unit_name { '' } - shipping_category { DefaultShippingCategory.find_or_create } - # ensure stock item will be created for this products master before(:create) { create(:stock_location) if Spree::StockLocation.count.zero? } diff --git a/spec/models/product_importer_spec.rb b/spec/models/product_importer_spec.rb index edda720680..f42d7c85f0 100644 --- a/spec/models/product_importer_spec.rb +++ b/spec/models/product_importer_spec.rb @@ -285,7 +285,7 @@ describe ProductImport::ProductImporter do expect(carrots.on_hand).to eq 5 expect(carrots.variants.first.price).to eq 3.20 expect(carrots.primary_taxon.name).to eq "Vegetables" - expect(carrots.shipping_category).to eq shipping_category + expect(carrots.variants.first.shipping_category).to eq shipping_category expect(carrots.supplier).to eq enterprise expect(carrots.variants.first.unit_presentation).to eq "500g" end diff --git a/spec/models/spree/order/checkout_spec.rb b/spec/models/spree/order/checkout_spec.rb index 8ed666961d..84b28216aa 100644 --- a/spec/models/spree/order/checkout_spec.rb +++ b/spec/models/spree/order/checkout_spec.rb @@ -123,8 +123,7 @@ describe Spree::Order::Checkout do let(:order) { create(:order_with_totals_and_distribution, ship_address: create(:address) ) } let(:shipping_method) { create(:shipping_method, distributors: [order.distributor]) } let(:other_shipping_category) { create(:shipping_category) } - let(:other_product) { create(:product, shipping_category: other_shipping_category ) } - let(:other_variant) { other_product.variants.first } + let(:other_variant) { create(:variant, shipping_category: other_shipping_category) } before do order.order_cycle = create(:simple_order_cycle, diff --git a/spec/system/admin/product_import_spec.rb b/spec/system/admin/product_import_spec.rb index ec0a2d43de..8671daa8c7 100644 --- a/spec/system/admin/product_import_spec.rb +++ b/spec/system/admin/product_import_spec.rb @@ -182,7 +182,7 @@ describe "Product Import" do carrots = Spree::Product.find_by(name: 'Carrots') expect(carrots.variants.first.tax_category).to eq tax_category - expect(carrots.shipping_category).to eq shipping_category + expect(carrots.variants.first.shipping_category).to eq shipping_category end it "records a timestamp on import that can be viewed and filtered under Bulk Edit Products" do diff --git a/spec/system/admin/products_spec.rb b/spec/system/admin/products_spec.rb index 043769815d..386d0a5239 100644 --- a/spec/system/admin/products_spec.rb +++ b/spec/system/admin/products_spec.rb @@ -110,7 +110,7 @@ describe ' expect(product.variants.first.price.to_s).to eq('19.99') expect(product.on_hand).to eq(5) expect(product.variants.first.tax_category_id).to eq(tax_category.id) - expect(product.shipping_category).to eq(shipping_category) + expect(product.variants.first.shipping_category).to eq(shipping_category) expect(product.description).to eq("
A description...
") expect(product.group_buy).to be_falsey expect(product.variants.first.unit_presentation).to eq("5kg")