From 708794c300591f718d9751fcedd88a3d1ea8d165 Mon Sep 17 00:00:00 2001 From: Ryan Woods Date: Sat, 25 Feb 2023 08:29:42 +0100 Subject: [PATCH] Refactor Product and Promotion ransackable_scopes By using allowed_ransackable_scopes which was introduced in the last commit, stores will be able to easily concatenate to the arrays already declared on Product and Promotion in Solidus. --- core/app/models/spree/product.rb | 5 +---- core/app/models/spree/promotion.rb | 4 +--- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/core/app/models/spree/product.rb b/core/app/models/spree/product.rb index 1543aa242df..4feae6e507d 100644 --- a/core/app/models/spree/product.rb +++ b/core/app/models/spree/product.rb @@ -133,10 +133,7 @@ def find_or_build_master self.allowed_ransackable_associations = %w[stores variants_including_master master variants] self.allowed_ransackable_attributes = %w[name slug] - - def self.ransackable_scopes(_auth_object = nil) - %i(available with_discarded with_variant_sku_cont with_all_variant_sku_cont with_kept_variant_sku_cont) - end + self.allowed_ransackable_scopes = %i[available with_discarded with_variant_sku_cont with_all_variant_sku_cont with_kept_variant_sku_cont] # @return [Boolean] true if there are any variants def has_variants? diff --git a/core/app/models/spree/promotion.rb b/core/app/models/spree/promotion.rb index f322e62d701..6b4794b7a88 100644 --- a/core/app/models/spree/promotion.rb +++ b/core/app/models/spree/promotion.rb @@ -54,9 +54,7 @@ class Promotion < Spree::Base self.allowed_ransackable_associations = ['codes'] self.allowed_ransackable_attributes = %w[name path promotion_category_id] - def self.ransackable_scopes(*) - %i(active) - end + self.allowed_ransackable_scopes = %i[active] def self.order_activatable?(order) order && !UNACTIVATABLE_ORDER_STATES.include?(order.state)