mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Prevent display_as and display_name from being used when blank
This commit is contained in:
@@ -51,11 +51,13 @@ Spree::Variant.class_eval do
|
||||
end
|
||||
|
||||
def name_to_display
|
||||
display_name || product.name
|
||||
return product.name if display_name.blank?
|
||||
display_name
|
||||
end
|
||||
|
||||
def unit_to_display
|
||||
display_as || options_text
|
||||
return options_text if display_as.blank?
|
||||
display_as
|
||||
end
|
||||
|
||||
|
||||
|
||||
@@ -133,6 +133,8 @@ module Spree
|
||||
it "returns product name if display_name is empty" do
|
||||
v = create(:variant, product: create(:product))
|
||||
v.name_to_display.should == v.product.name
|
||||
v1 = create(:variant, display_name: "", product: create(:product))
|
||||
v1.name_to_display.should == v1.product.name
|
||||
end
|
||||
end
|
||||
|
||||
@@ -142,10 +144,13 @@ module Spree
|
||||
v.unit_to_display.should == "foo"
|
||||
end
|
||||
|
||||
it "returns options_text if display_as is empty" do
|
||||
it "returns options_text if display_as is blank" do
|
||||
v = create(:variant)
|
||||
v1 = create(:variant, display_as: "")
|
||||
v.stub(:options_text).and_return "ponies"
|
||||
v1.stub(:options_text).and_return "ponies"
|
||||
v.unit_to_display.should == "ponies"
|
||||
v1.unit_to_display.should == "ponies"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user