Skip to content

Commit

Permalink
Refactor Product and Promotion ransackable_scopes
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
RyanofWoods committed Feb 27, 2023
1 parent 4f4a594 commit 708794c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
5 changes: 1 addition & 4 deletions core/app/models/spree/product.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
4 changes: 1 addition & 3 deletions core/app/models/spree/promotion.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 708794c

Please sign in to comment.