From da34e7b780cc26c598166e06da60fc3608b59a0c Mon Sep 17 00:00:00 2001 From: Ahmed Ejaz Date: Mon, 22 Apr 2024 01:35:28 +0500 Subject: [PATCH] 11060 - fix undefined method tax_category_options error in specs --- app/controllers/admin/products_v3_controller.rb | 3 ++- app/reflexes/products_reflex.rb | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/controllers/admin/products_v3_controller.rb b/app/controllers/admin/products_v3_controller.rb index 168fa001d0..92386e1231 100644 --- a/app/controllers/admin/products_v3_controller.rb +++ b/app/controllers/admin/products_v3_controller.rb @@ -24,7 +24,8 @@ module Admin elsif product_set.errors.present? @error_counts = { saved: product_set.saved_count, invalid: product_set.invalid.count } - render "index", status: :unprocessable_entity, locals: { producers:, categories:, flash: } + render "index", status: :unprocessable_entity, + locals: { producers:, categories:, tax_category_options:, flash: } end end diff --git a/app/reflexes/products_reflex.rb b/app/reflexes/products_reflex.rb index 9cad290331..a2800c83e4 100644 --- a/app/reflexes/products_reflex.rb +++ b/app/reflexes/products_reflex.rb @@ -89,7 +89,7 @@ class ProductsReflex < ApplicationReflex html: render(partial: "admin/products_v3/content", locals: { products: @products, pagy: @pagy, search_term: @search_term, producer_options: producers, producer_id: @producer_id, - category_options: categories, category_id: @category_id, + category_options: categories, tax_category_options:, category_id: @category_id, flashes: flash }) ) @@ -125,6 +125,10 @@ class ProductsReflex < ApplicationReflex Spree::Taxon.order(:name).map { |c| [c.name, c.id] } end + def tax_category_options + Spree::TaxCategory.order(:name).pluck(:name, :id) + end + def fetch_products product_query = OpenFoodNetwork::Permissions.new(current_user) .editable_products.merge(product_scope).ransack(ransack_query).result(distinct: true)