diff --git a/umich_catalog_indexing/lib/umich_traject/electronic_holding.rb b/umich_catalog_indexing/lib/umich_traject/electronic_holding.rb index 648a047f..bd843671 100644 --- a/umich_catalog_indexing/lib/umich_traject/electronic_holding.rb +++ b/umich_catalog_indexing/lib/umich_traject/electronic_holding.rb @@ -10,23 +10,24 @@ def library end def link - code_map = { - "ann_arbor" => "UMAA", - "flint" => "UMFL" - } - URI::DEFAULT_PARSER.escape(@e56["u"].sub("openurl", "openurl-#{code_map[link_campus]}")) + code = (_alma_campuses.count == 1 && _alma_campuses.first == "UMFL") ? "UMFL" : "UMAA" + URI::DEFAULT_PARSER.escape(@e56["u"].sub("openurl", "openurl-#{code}")) end def link_text "Available online" end - def link_campus + def campuses + inst_code_map = { + "UMAA" => "ann_arbor", + "UMFL" => "flint" + } # return flint when it's the only campus - if _alma_campuses.count == 1 && _alma_campuses.first == "UMFL" - "flint" + if _alma_campuses.empty? + inst_code_map.values else - "ann_arbor" + _alma_campuses.map { |code| inst_code_map[code] } end end @@ -86,7 +87,7 @@ def to_h "library", "link", "link_text", - "link_campus", + "campuses", "interface_name", "collection_name", "authentication_note", diff --git a/umich_catalog_indexing/spec/traject/umich/electronic_holding_spec.rb b/umich_catalog_indexing/spec/traject/umich/electronic_holding_spec.rb index bcdb1295..4aadf0cd 100644 --- a/umich_catalog_indexing/spec/traject/umich/electronic_holding_spec.rb +++ b/umich_catalog_indexing/spec/traject/umich/electronic_holding_spec.rb @@ -71,22 +71,22 @@ def get_record(path) expect(subject.institution_codes).to eq(["MIFLIC"]) end end - context "#link_campus" do - it "shows ann_arbor when no c code" do - expect(subject.link_campus).to eq("ann_arbor") + context "#campuses" do + it "shows both ann_arbor and flint when no c code" do + expect(subject.campuses).to contain_exactly("ann_arbor", "flint") end - it "shows ann_arbor when both UMAA and UMFL are present" do + it "shows both ann_arbor and flint when both UMAA and UMFL are present" do ann_arbor_campus flint_campus - expect(subject.link_campus).to eq("ann_arbor") + expect(subject.campuses).to contain_exactly("ann_arbor", "flint") end it "shows ann_arbor when c code is only UMAA" do ann_arbor_campus - expect(subject.link_campus).to eq("ann_arbor") + expect(subject.campuses).to contain_exactly("ann_arbor") end it "shows flint when c code is only UMFL" do flint_campus - expect(subject.link_campus).to eq("flint") + expect(subject.campuses).to contain_exactly("flint") end end context "#interface_name" do @@ -137,7 +137,7 @@ def get_record(path) "library" => s.library, "link" => s.link, "link_text" => s.link_text, - "link_campus" => s.link_campus, + "campuses" => s.campuses, "interface_name" => s.interface_name, "collection_name" => s.collection_name, "authentication_note" => s.authentication_note,