From 0def139e174840022c9d370247a39685d8687b8f Mon Sep 17 00:00:00 2001 From: Max Kadel Date: Fri, 24 Mar 2023 10:27:00 -0400 Subject: [PATCH] Don't show stackmap link for reserves w/o maps --- app/helpers/application_helper.rb | 3 +++ app/services/stackmap_service.rb | 22 +++++++++++----------- spec/helpers/holding_block_spec.rb | 24 ++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 11 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index acd6ddb82..4644e3154 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -341,6 +341,9 @@ def holding_requests_adapter # Currently this logic is duplicated in Javascript code in availability.es6 def find_it_location?(location_code) return false if (location_code || "").start_with?("plasma$", "marquand$") + + return false if StackmapService::Url.missing_stackmap_reserves.include?(location_code) + true end diff --git a/app/services/stackmap_service.rb b/app/services/stackmap_service.rb index 46ee7320a..a10e8bd08 100644 --- a/app/services/stackmap_service.rb +++ b/app/services/stackmap_service.rb @@ -17,8 +17,8 @@ def initialize(document:, loc:, cn: nil) # @return [String] stackmap url def url if valid? - if missing_stackmap_reserves.include? @loc - missing_stackmap_reserves[@loc] + if StackmapService::Url.missing_stackmap_reserves.include? @loc + StackmapService::Url.missing_stackmap_reserves[@loc] elsif stackmap_libs.include? lib stackmap_url else @@ -42,6 +42,15 @@ def location_label holding_location[:label].presence || holding_location[:library][:label] end + def self.missing_stackmap_reserves + { + 'arch$res3hr' => 'https://library.princeton.edu/architecture', + 'stokes$respiapr' => 'https://library.princeton.edu/stokes', + 'plasma$res' => 'https://library.princeton.edu/plasma-physics', + 'lewis$gr' => 'https://library.princeton.edu/lewis' + } + end + private def locator_url @@ -82,15 +91,6 @@ def stackmap_libs end end - def missing_stackmap_reserves - { - 'arch$res3hr' => 'https://library.princeton.edu/architecture', - 'stokes$respiapr' => 'https://library.princeton.edu/stokes', - 'plasma$res' => 'https://library.princeton.edu/plasma-physics', - 'lewis$gr' => 'https://library.princeton.edu/lewis' - } - end - def by_title_locations %w[lewis$serial plasma$ps stokes$sprps stokes$spiaps] end diff --git a/spec/helpers/holding_block_spec.rb b/spec/helpers/holding_block_spec.rb index 6485265ae..858107793 100644 --- a/spec/helpers/holding_block_spec.rb +++ b/spec/helpers/holding_block_spec.rb @@ -370,6 +370,23 @@ }.with_indifferent_access end + let(:document_in_temp_reserve_location) do + { + id: '1', + format: ['Book'], + holdings_1display: { + "arch$res3hr": { + location_code: "arch$res3hr", + current_location: "Reserve 3-Hour", + current_library: "Architecture Library", + call_number: "HT166.I3", + call_number_browse: "HT166.I3", + temp_location_code: "arch$res3hr" + } + }.to_json.to_s + }.with_indifferent_access + end + before { stub_holding_locations } context 'with Firestone Locator off' do @@ -412,6 +429,13 @@ search_result = helper.holding_block_search(SolrDocument.new(document_without_find_it_link)) expect(search_result).not_to include "data-map-location" end + + context 'with a reserve item in a temporary location' do + it 'does not include the find it icon' do + search_result = helper.holding_block_search(SolrDocument.new(document_in_temp_reserve_location)) + expect(search_result).not_to include "data-map-location" + end + end end context '#holding_block_search with links only' do