Improve nil-safety in variant naming methods

This commit is contained in:
Matt-Yorkley
2023-06-07 12:17:50 +01:00
parent 2d28a57c6f
commit bb73d70e57
2 changed files with 17 additions and 2 deletions

View File

@@ -432,6 +432,20 @@ describe Spree::Variant do
expect(variant.product_and_full_name).to eq "Apple - Pink Lady"
end
end
context "when related naming values are nil" do
before do
product.name = "Apples"
product.display_as = nil
variant.display_as = nil
variant.unit_presentation = nil
end
it "returns empty string or product name" do
expect(variant.full_name).to eq ""
expect(variant.product_and_full_name).to eq product.name
end
end
end
describe "calculating the price with enterprise fees" do