mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Swap param order
This commit is contained in:
@@ -8,7 +8,7 @@ class VariantOverride < ActiveRecord::Base
|
||||
where(hub_id: hubs)
|
||||
}
|
||||
|
||||
def self.price_for(variant, hub)
|
||||
def self.price_for(hub, variant)
|
||||
VariantOverride.where(variant_id: variant, hub_id: hub).first.andand.price
|
||||
end
|
||||
end
|
||||
|
||||
@@ -12,7 +12,7 @@ module OpenFoodNetwork
|
||||
end
|
||||
|
||||
def price
|
||||
VariantOverride.price_for(@variant, @hub) || @variant.price
|
||||
VariantOverride.price_for(@hub, @variant) || @variant.price
|
||||
end
|
||||
|
||||
|
||||
|
||||
@@ -19,11 +19,11 @@ describe VariantOverride do
|
||||
|
||||
it "returns the numeric price when present" do
|
||||
VariantOverride.create!(variant: variant, hub: hub, price: 12.34)
|
||||
VariantOverride.price_for(variant, hub).should == 12.34
|
||||
VariantOverride.price_for(hub, variant).should == 12.34
|
||||
end
|
||||
|
||||
it "returns nil otherwise" do
|
||||
VariantOverride.price_for(variant, hub).should be_nil
|
||||
VariantOverride.price_for(hub, variant).should be_nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user