mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Bring Spree::Variant#active so that we can make it return just variants without includes
This makes the variants returned not readonly in rails 4 and thus fixes a spec in Spree::VariantsController#destroy
This commit is contained in:
@@ -85,6 +85,10 @@ Spree::Variant.class_eval do
|
||||
]
|
||||
end
|
||||
|
||||
def self.active(currency = nil)
|
||||
where(id: joins(:prices).where(deleted_at: nil).where('spree_prices.currency' => currency || Spree::Config[:currency]).where('spree_prices.amount IS NOT NULL').select("spree_variants.id"))
|
||||
end
|
||||
|
||||
# We override in_stock? to avoid depending on the non-overridable method Spree::Stock::Quantifier.can_supply?
|
||||
# VariantStock implements can_supply? itself which depends on overridable methods
|
||||
def in_stock?(quantity = 1)
|
||||
|
||||
Reference in New Issue
Block a user