From 91c500417bd4a8bd4f638bff869b10b2fc661fd1 Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Fri, 12 Dec 2014 14:34:55 +1100 Subject: [PATCH] Swap param order --- app/models/variant_override.rb | 2 +- lib/open_food_network/variant_proxy.rb | 2 +- spec/models/variant_override_spec.rb | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/models/variant_override.rb b/app/models/variant_override.rb index f307125e88..dcb281ea80 100644 --- a/app/models/variant_override.rb +++ b/app/models/variant_override.rb @@ -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 diff --git a/lib/open_food_network/variant_proxy.rb b/lib/open_food_network/variant_proxy.rb index 26e6796e9a..9863fccad2 100644 --- a/lib/open_food_network/variant_proxy.rb +++ b/lib/open_food_network/variant_proxy.rb @@ -12,7 +12,7 @@ module OpenFoodNetwork end def price - VariantOverride.price_for(@variant, @hub) || @variant.price + VariantOverride.price_for(@hub, @variant) || @variant.price end diff --git a/spec/models/variant_override_spec.rb b/spec/models/variant_override_spec.rb index 082a7fb135..d592262c97 100644 --- a/spec/models/variant_override_spec.rb +++ b/spec/models/variant_override_spec.rb @@ -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