Skip to content

Commit

Permalink
Drive browse pages using the browse_nearby_struct, not item_display_s…
Browse files Browse the repository at this point in the history
…truct; fixes #4487
  • Loading branch information
cbeer committed Nov 13, 2024
1 parent bf88f20 commit 9ef62b8
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
2 changes: 1 addition & 1 deletion app/controllers/browse_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def _prefixes
end

def browse_params
params.permit(:start, :barcode, :before, :after, :view)
params.permit(:start, :barcode, :before, :after, :view, :call_number)
end

def fetch_orginal_document
Expand Down
2 changes: 1 addition & 1 deletion app/views/browse/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<% elsif params[:barcode] %>
<%= @original_doc.holdings.find_by_barcode(params[:barcode])&.callnumber %>
<% else %>
<%= @original_doc.holdings.items.first.callnumber %>
<%= @original_doc.browseable_spines.first&.callnumber %>
<% end %>
</p>
<p><%= link_to(document_presenter(@original_doc).heading, solr_document_path(@original_doc)) %></p>
Expand Down
29 changes: 21 additions & 8 deletions spec/views/browse/index.html.erb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,21 @@
require 'rails_helper'

RSpec.describe "browse/index" do
let(:original_doc) {
let(:original_doc) do
SolrDocument.new(
id: 'doc-id',
item_display_struct: [
{ barcode: '123', library: 'library', effective_permanent_location_code: 'location_code', temporary_location_code: 'temporary_location_code', type: 'type',
truncated_callnumber: 'truncated_callnumber', callnumber: 'callnumber123' },
{ barcode: '321', library: 'library', effective_permanent_location_code: 'location_code', temporary_location_code: 'temporary_location_code', type: 'type',
truncated_callnumber: 'truncated_callnumber', callnumber: 'callnumber321' }
]
browse_nearby_struct: browse_nearby_struct,
item_display_struct: item_display_struct
)
}
end

let(:browse_nearby_struct) do
[
{ item_id: '123', callnumber: 'callnumber123', shelfkey: 'A', scheme: 'LC' }
]
end

let(:item_display_struct) { [] }
let(:presenter) { OpenStruct.new(heading: "Title") }

before do
Expand All @@ -35,6 +39,15 @@
end

describe "with barcode" do
let(:item_display_struct) do
[
{ barcode: '123', library: 'library', effective_permanent_location_code: 'location_code', temporary_location_code: 'temporary_location_code', type: 'type',
truncated_callnumber: 'truncated_callnumber', callnumber: 'callnumber123' },
{ barcode: '321', library: 'library', effective_permanent_location_code: 'location_code', temporary_location_code: 'temporary_location_code', type: 'type',
truncated_callnumber: 'truncated_callnumber', callnumber: 'callnumber321' }
]
end

before do
allow(view).to receive(:params).and_return(start: '123', barcode: '321')
end
Expand Down

0 comments on commit 9ef62b8

Please sign in to comment.