Skip to content

Commit

Permalink
Respect the searchworksTreatTemporaryLocationAsPermanentLocation loca…
Browse files Browse the repository at this point in the history
…tion detail when selecting items in a location
  • Loading branch information
cbeer committed Sep 28, 2023
1 parent ccb0c8d commit e359b87
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
8 changes: 7 additions & 1 deletion app/models/folio/holdings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,13 @@ def folio_location_code
end

def items_in_location
@items.select { |item| item.home_location == folio_location_code }
@items.select do |item|
if item.effective_location.details['searchworksTreatTemporaryLocationAsPermanentLocation'] == 'true'
item.effective_location.code == folio_location_code
else
item.home_location == folio_location_code
end
end
end
end
end
1 change: 1 addition & 0 deletions app/services/folio_graphql_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ def instance(hrid:)
}
scanServicePointCode
availabilityClass
searchworksTreatTemporaryLocationAsPermanentLocation
}
}
permanentLocation {
Expand Down
23 changes: 22 additions & 1 deletion spec/models/folio/holdings_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
type: 'multimedia',
callnumber: 'XX(14820051.1)',
public_note: nil,
effective_location: instance_double(Folio::Location),
effective_location: instance_double(Folio::Location, details: {}),
permanent_location:)
end

Expand All @@ -26,4 +26,25 @@
it { is_expected.to eq items }
end
end

context 'with searchworksTreatTemporaryLocationAsPermanentLocation set' do
let(:item) do
Folio::Item.new(barcode: '123',
status: 'Available',
type: 'multimedia',
callnumber: 'XX(14820051.1)',
public_note: nil,
effective_location: instance_double(Folio::Location, code: 'MUS-CRES',
details: { 'searchworksTreatTemporaryLocationAsPermanentLocation' => 'true' }),
permanent_location: instance_double(Folio::Location, code: 'SAL3-STACKS'))
end

context 'for a request with the permanent location' do
let(:request) { Page.new(item_id: '14820051', origin: 'SAL3', origin_location: 'STACKS') }

it 'excludes items with an effective location that does not match the requested location' do
expect(holdings.to_a).to be_blank
end
end
end
end

0 comments on commit e359b87

Please sign in to comment.