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.
RyanofWoods committed Feb 27, 2023

Verified

This commit was signed with the committer’s verified signature.
Mamaduka George Mamadashvili
1 parent 66bf2d2 commit a68e768
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
@@ -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?
4 changes: 1 addition & 3 deletions core/app/models/spree/promotion.rb
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit a68e768

Please sign in to comment.