diff --git a/lib/models/callnumber_item.rb b/lib/models/callnumber_item.rb index c804be6..99e456b 100644 --- a/lib/models/callnumber_item.rb +++ b/lib/models/callnumber_item.rb @@ -1,7 +1,7 @@ class CallnumberItem def initialize(browse_doc:, catalog_doc:, exact_match:) @browse_doc = browse_doc - @catalog_doc = catalog_doc + @catalog_doc = catalog_doc || {} @exact_match = exact_match end diff --git a/spec/models/callnumber_item_spec.rb b/spec/models/callnumber_item_spec.rb index d5d1cdd..00470e2 100644 --- a/spec/models/callnumber_item_spec.rb +++ b/spec/models/callnumber_item_spec.rb @@ -25,6 +25,10 @@ @catalog_doc["edition"] = ["my edition", "vernacular edition"] expect(subject.title).to eq("Zhiznʹ gospodina de Molʹera / M. Bulgakov ; [podgot. teksta i poslesl. V.I. Loseva]. my edition") end + it "is an empty string when there is no matching catalog record" do + @catalog_doc = nil + expect(subject.title).to eq("") + end end context "#vernacular_title" do it "shows vernacular title without edition when there isn't one" do