Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ FRAMEWORK_ALMA_API_KEY=KEY_GOES_HERE
FRAMEWORK_ALMA_API_URL=https://api-na.hosted.exlibrisgroup.com/almaws/v1/
FRAMEWORK_ALMA_SANDBOX_KEY=KEY_GOES_HERE
LIT_TIND_API_KEY=KEY_GOES_HERE
# set a warning message when we know we're getting rate limited by OCLC
FRAMEWORK_LOCATION_REQUESTS_ALERT="Location Requests that involve WorldCat lookups are currently being rate limited by OCLC. We have contacted OCLC support and are awaiting resolution."
10 changes: 10 additions & 0 deletions app/helpers/location_requests_alert_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module LocationRequestsAlertHelper
def location_requests_alert
Rails.configuration.location_requests_alert.presence
end

def display_location_requests_alert
alert = location_requests_alert
content_tag(:div, alert, class: 'alert alert-warning', role: 'alert') if alert
Comment thread
anarchivist marked this conversation as resolved.
end
end
3 changes: 3 additions & 0 deletions app/views/location_requests/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<h1>Location Request</h1>

<%= display_location_requests_alert %>

<p>
The Location Request tool takes an OCLC number and queries OCLC and/or HathiTrust.
The tool is good for searching for single-volume monographs. For multi-volume monographs
Expand Down
1 change: 1 addition & 0 deletions config/altmedia.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ default: &default
alma_api_url: <%= ENV["FRAMEWORK_ALMA_API_URL"].presence || 'https://api-na.hosted.exlibrisgroup.com/almaws/v1/' %>
alma_api_key: <%= ENV["FRAMEWORK_ALMA_API_KEY"].presence || 'fake-api-key' %>
alma_sandbox_key: <%= ENV["FRAMEWORK_ALMA_SANDBOX_KEY"].presence || 'fake-api-key' %>
location_requests_alert: <%= ENV["FRAMEWORK_LOCATION_REQUESTS_ALERT"] %>
paypal_payflow_url: <%= ENV["PAYPAL_PAYFLOW_URL"] || 'https://payflowlink.paypal.com' %>
paypal_payflow_login: <%= ENV["PAYPAL_PAYFLOW_LOGIN"] || 'ucblibrary' %>
tind_base_uri: <%= ENV["LIT_TIND_BASE_URL"] || 'https://digicoll.lib.berkeley.edu/' %>
Expand Down
3 changes: 3 additions & 0 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ def log_active_storage_root!(active_storage_root)
# Valid groups for libproxy access based on Alma groups
config.libproxy_groups = config.libproxy['valid_groups']

# alert message on location requests when we know we're being rate limited
config.location_requests_alert = config.altmedia['location_requests_alert']

# Tind set values for marc inserts
config.tind_resource_types = config.tind_marc['resource_types']
config.tind_restrictions = config.tind_marc['restrictions']
Expand Down
47 changes: 47 additions & 0 deletions spec/helpers/location_requests_alert_helper_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
require 'rails_helper'

describe LocationRequestsAlertHelper, type: :helper do
let(:configured_alert) { nil }

before do
allow(Rails.configuration).to receive(:location_requests_alert).and_return(configured_alert)
end

describe '#location_requests_alert' do
subject(:location_requests_alert) { helper.location_requests_alert }

context 'when the alert is not configured' do
it { is_expected.to be_nil }
end

context 'when the alert is blank' do
let(:configured_alert) { ' ' }

it { is_expected.to be_nil }
end

context 'when the alert is configured' do
let(:configured_alert) { 'OCLC requests are currently rate limited.' }

it { is_expected.to eq(configured_alert) }
end
end

describe '#display_location_requests_alert' do
subject(:output) { helper.display_location_requests_alert }

context 'when the alert is not configured' do
it { is_expected.to be_nil }
end

context 'when the alert is configured' do
let(:configured_alert) { 'OCLC requests are currently rate limited.' }

it 'renders the configured message as a warning alert' do
render html: output

assert_dom 'div.alert.alert-warning[role=?]', 'alert', text: configured_alert, count: 1
end
end
end
end
23 changes: 23 additions & 0 deletions spec/system/location_requests_system_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,29 @@
end
end

describe 'location requests alert' do
let(:configured_alert) { nil }

before do
allow(Rails.configuration).to receive(:location_requests_alert).and_return(configured_alert)
visit new_location_request_path
end

context 'when the alert is not configured' do
it 'does not display a warning alert' do
expect(page).to have_no_selector('div.alert.alert-warning[role="alert"]')
end
end

context 'when the alert is configured' do
let(:configured_alert) { 'OCLC requests are currently rate limited.' }

it 'displays the configured warning alert' do
expect(page).to have_selector('div.alert.alert-warning[role="alert"]', text: configured_alert)
end
end
end

shared_examples 'a form with immediate and off-hours options' do
it 'includes the "immediate" radio group' do
[true, false].each do |state|
Expand Down
Loading