-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
i3574: Thesis and numismatics aeon requests need specific parameters
- Loading branch information
1 parent
57af283
commit bab6a7f
Showing
5 changed files
with
89 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# frozen_string_literal: true | ||
module Requests | ||
# Create a URL that creates an aeon request | ||
class NonAlmaAeonUrl < AeonUrl | ||
private | ||
|
||
def aeon_basic_params | ||
super.merge({ | ||
Action: 10, | ||
Form: 21, | ||
ItemTitle: aeon_title.truncate(247), | ||
ItemAuthor: author, | ||
ItemDate: @document[:pub_date_start_sort], | ||
ItemVolume: @holding[:location], | ||
genre: | ||
}).compact | ||
end | ||
|
||
def aeon_title | ||
"#{@document.first(:title_display)}#{title_genre}" | ||
end | ||
|
||
## Don T requested this be appended when present | ||
def title_genre | ||
" [ #{@document.first(:form_genre_display)} ]" unless @document[:form_genre_display].nil? | ||
end | ||
|
||
def genre | ||
return 'numismatics' if holding[:call_number]&.downcase&.start_with?('coin') | ||
'thesis' | ||
end | ||
|
||
def author | ||
@document[:author_display]&.join(" AND ") | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# frozen_string_literal: true | ||
require 'rails_helper' | ||
|
||
RSpec.describe Requests::NonAlmaAeonUrl do | ||
let(:holdings) do | ||
{ "thesis" => {} } | ||
end | ||
let(:document) do | ||
SolrDocument.new({ | ||
id: '9999999', | ||
title_display: 'A book of poems', | ||
form_genre_display: ['Poetry'], | ||
author_display: ['Person 1', 'Person 2'], | ||
holdings_1display: holdings.to_json.to_s | ||
}) | ||
end | ||
before do | ||
stub_holding_locations | ||
end | ||
subject { described_class.new(document:, holding: holdings).to_s } | ||
it 'uses Action 10' do | ||
expect(subject).to include('Action=10') | ||
end | ||
it 'uses form 21' do | ||
expect(subject).to include('Form=21') | ||
end | ||
it 'provides a title with the genre appended' do | ||
expect(subject).to include('ItemTitle=A+book+of+poems+%5B+Poetry+%5D') | ||
end | ||
it 'concatenates a list of authors from the author_display field' do | ||
expect(subject).to include('ItemAuthor=Person+1+AND+Person+2') | ||
end | ||
it 'defaults to the thesis genre' do | ||
expect(subject).to include('genre=thesis') | ||
end | ||
context 'when the holdings has a coin call number' do | ||
let(:holdings) do | ||
{ "numismatics" => { "call_number": "Coin 11362" } } | ||
end | ||
it 'includes the numismatics genre' do | ||
expect(subject).to include('genre=numismatics') | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters