From 262b76abdda580669d5d15db49dac9c96d352b02 Mon Sep 17 00:00:00 2001 From: Justin Coyne Date: Mon, 9 Oct 2023 11:27:32 -0500 Subject: [PATCH] If the passed in origin isn't a Symphony location, then treat it as a Folio location Fixes #1903 --- app/models/library_location.rb | 3 ++- spec/models/library_location_spec.rb | 16 +++++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/app/models/library_location.rb b/app/models/library_location.rb index 60136b4a9..d842162ff 100644 --- a/app/models/library_location.rb +++ b/app/models/library_location.rb @@ -16,8 +16,9 @@ def active_messages end # This is the code Folio uses, which is a combination of library & Symphony location + # In certain cases, this wasn't a Symphony location, so the location is a FOLIO location (e.g. BUSINESS/BUS-CRES) def folio_location_code - @folio_location_code ||= FolioLocationMap.folio_code_for(library_code: library, home_location: location) + @folio_location_code ||= FolioLocationMap.folio_code_for(library_code: library, home_location: location) || location rescue FolioLocationMap::NotFound Honeybadger.notify('Location code not found', context: { library:, location: }) nil diff --git a/spec/models/library_location_spec.rb b/spec/models/library_location_spec.rb index 3ff77ef0e..f0d4f37dc 100644 --- a/spec/models/library_location_spec.rb +++ b/spec/models/library_location_spec.rb @@ -18,9 +18,19 @@ subject { library_location.folio_location_code } let(:library_location) { described_class.new(origin, origin_location) } - let(:origin) { 'GREEN' } - let(:origin_location) { 'STACKS' } - it { is_expected.to eq 'GRE-STACKS' } + context 'a symphony location' do + let(:origin) { 'GREEN' } + let(:origin_location) { 'STACKS' } + + it { is_expected.to eq 'GRE-STACKS' } + end + + context 'a FOLIO location' do + let(:origin) { 'BUSINESS' } + let(:origin_location) { 'BUS-CRES' } + + it { is_expected.to eq 'BUS-CRES' } + end end end