Swap param order

This commit is contained in:
Rohan Mitchell
2014-12-12 14:34:55 +11:00
parent 66669e66ab
commit 91c500417b
3 changed files with 4 additions and 4 deletions

View File

@@ -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

View File

@@ -12,7 +12,7 @@ module OpenFoodNetwork
end
def price
VariantOverride.price_for(@variant, @hub) || @variant.price
VariantOverride.price_for(@hub, @variant) || @variant.price
end

View File

@@ -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