From 7b367556642062a4dfa283914558b4c0e395c25a Mon Sep 17 00:00:00 2001 From: "E. Lynette Rayle" Date: Tue, 4 Jun 2019 09:28:06 -0400 Subject: [PATCH] determine is loc special processing should be done based on template uri instead of authority name --- lib/qa/authorities/linked_data/find_term.rb | 2 +- spec/lib/authorities/linked_data/find_term_spec.rb | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/qa/authorities/linked_data/find_term.rb b/lib/qa/authorities/linked_data/find_term.rb index 4fd8b3f3..2b4cc145 100644 --- a/lib/qa/authorities/linked_data/find_term.rb +++ b/lib/qa/authorities/linked_data/find_term.rb @@ -124,7 +124,7 @@ def loc_id # determine if the current authority is LOC which may require special processing of its ids for backward compatibility def loc? - authority_name.to_s.casecmp('loc').zero? + term_config.url_config.template.starts_with? 'http://id.loc.gov/authorities/' end def expects_uri? diff --git a/spec/lib/authorities/linked_data/find_term_spec.rb b/spec/lib/authorities/linked_data/find_term_spec.rb index f21e89a6..503d14e1 100644 --- a/spec/lib/authorities/linked_data/find_term_spec.rb +++ b/spec/lib/authorities/linked_data/find_term_spec.rb @@ -175,6 +175,16 @@ it 'extracts correct uri when loc id does not have blank' do expect(results_without_blank[:uri]).to eq 'http://id.loc.gov/authorities/subjects/sh85118553' end + + context 'when alternate authority name is used to access loc' do + let(:results) { lod_loc.find('sh 85118553', subauth: 'subjects') } + + before { allow(lod_loc.term_config).to receive(:authority_name).and_return('ALT_LOC_AUTHORITY') } + + it 'does special processing to remove blank from id' do + expect(results[:uri]).to eq 'http://id.loc.gov/authorities/subjects/sh85118553' + end + end end end