|
243 | 243 | describe 'holding availability' do |
244 | 244 | let(:library_lewis_reserves) { file_fixture('alma/library_lewis_reserves.json') } |
245 | 245 | let(:library_lewis_stacks) { file_fixture('alma/library_lewis_stacks.json') } |
| 246 | + let(:library_firestone_stacks) { file_fixture('alma/library_firestone_stacks.json') } |
246 | 247 |
|
247 | 248 | before do |
248 | 249 | stub_alma_holding_items(mms_id: '9919392043506421', holding_id: '22105104420006421', filename: '9919392043506421_holding_items.json') |
249 | 250 | stub_alma_holding_items(mms_id: '99122455086806421', holding_id: '22477860740006421', filename: '99122455086806421_holding_items.json') |
250 | 251 | stub_alma_library(library_code: 'firestone', location_code: 'dixn') |
251 | 252 | stub_alma_library(library_code: 'firestone', location_code: 'stacks') |
252 | 253 |
|
| 254 | + stub_alma_holding_items(mms_id: '99126856502706421', holding_id: '22965530090006421', filename: '99126856502706421_process_type_requested.json') |
| 255 | + |
253 | 256 | # https://api-na.hosted.exlibrisgroup.com/almaws/v1/bibs/9999362473506421/holdings/22752541670006421/items?limit=100&order_by=enum_a |
254 | 257 | stub_alma_holding_items(mms_id: '9999362473506421', holding_id: '22752541670006421', filename: '9999362473506421_holding_items.json') |
255 | 258 | stub_alma_holding_items(mms_id: '9999362473506421', holding_id: '22752541690006421', filename: '9999362473506421_holding_items_two.json') |
256 | 259 |
|
257 | 260 | stub_alma_library(library_code: 'lewis', location_code: 'resterm', body: library_lewis_reserves) |
258 | 261 | stub_alma_library(library_code: 'lewis', location_code: 'stacks', body: library_lewis_stacks) |
| 262 | + stub_alma_library(library_code: 'firestone', location_code: 'stacks', body: library_firestone_stacks) |
259 | 263 | end |
260 | 264 |
|
261 | 265 | it 'reports holdings availability' do |
|
276 | 280 | # but we are not really using this value anymore. |
277 | 281 | expect(item[:on_reserve]).to eq 'N' |
278 | 282 |
|
279 | | - # Make sure temp locations are handled and the permanent location is preserved. |
280 | | - availability = adapter.get_availability_holding(id: '9999362473506421', holding_id: '22752541690006421') |
| 283 | + create(:holding_location, code: 'firestone$stacks', label: 'Stacks') |
| 284 | + availability = adapter.get_availability_holding(id: '99126856502706421', holding_id: '22965530090006421') |
281 | 285 | item = availability.first |
282 | | - expect(item[:in_temp_library]).to be true |
283 | | - expect(item[:temp_library_code]).to eq 'lewis' |
284 | | - |
285 | | - # Test an actual response. These values are not particularly meaningful, but to make sure we don't |
286 | | - # inadvertently change them when refactoring. |
287 | | - item_test = { barcode: '32101099065268', id: '23752541680006421', holding_id: '22752541690006421', copy_number: '0', |
288 | | - status: 'Available', status_label: 'Item in place', status_source: 'base_status', process_type: nil, |
289 | | - on_reserve: 'Y', item_type: 'Gen', pickup_location_id: 'lewis', pickup_location_code: 'lewis', |
290 | | - location: 'lewis$resterm', label: 'Lewis Library - Term Loan Reserves', description: '', enum_display: '', |
291 | | - chron_display: '', requested: false, in_temp_library: true, temp_library_code: 'lewis', |
292 | | - temp_library_label: 'Lewis Library - Term Loan Reserves', temp_location_code: 'lewis$resterm', |
293 | | - temp_location_label: 'Lewis Library - Term Loan Reserves' } |
| 286 | + expect(item[:in_temp_library]).to be false |
| 287 | + expect(item[:temp_library_code]).to be_nil |
| 288 | + |
| 289 | + item_test = { barcode: '32101116415405', |
| 290 | + id: '23965530080006421', |
| 291 | + holding_id: '22965530090006421', |
| 292 | + copy_number: '', |
| 293 | + status: 'Unavailable', |
| 294 | + status_label: 'Unavailable', |
| 295 | + status_source: 'process_type', |
| 296 | + process_type: 'HOLDSHELF', |
| 297 | + on_reserve: 'N', |
| 298 | + item_type: 'Gen', |
| 299 | + pickup_location_id: 'firestone', |
| 300 | + pickup_location_code: 'firestone', |
| 301 | + location: 'firestone$stacks', |
| 302 | + label: 'Firestone Library - Stacks', |
| 303 | + description: '', |
| 304 | + enum_display: '', |
| 305 | + chron_display: '', |
| 306 | + requested: true, |
| 307 | + in_temp_library: false } |
294 | 308 | expect(item).to eq item_test |
295 | 309 | end |
296 | 310 |
|
|
312 | 326 | before do |
313 | 327 | stub_alma_ids(ids: '9965126093506421', status: 200) |
314 | 328 | stub_alma_holding_items(mms_id: '9965126093506421', holding_id: '22202918790006421', filename: '9965126093506421_holding_items.json') |
| 329 | + stub_alma_holding_items(mms_id: '99131644166406421', holding_id: '221091258440006421', filename: '99131644166406421_in_process_acq.json') |
315 | 330 | stub_alma_ids(ids: '9943506421', status: 200) |
316 | 331 | stub_alma_holding_items(mms_id: '9943506421', holding_id: '22261963850006421', filename: '9943506421_holding_items.json') |
317 | 332 | stub_alma_library(library_code: 'firestone', location_code: 'stacks') |
318 | 333 | stub_alma_library(library_code: 'recap', location_code: 'xr') |
319 | 334 | end |
320 | 335 |
|
321 | | - it 'uses the work_order to calculate status' do |
322 | | - availability = adapter.get_availability_holding(id: '9965126093506421', holding_id: '22202918790006421') |
323 | | - item = availability.first |
324 | | - expect(item[:status]).to eq 'Unavailable' |
325 | | - expect(item[:status_label]).to eq 'Holdings Management' |
326 | | - expect(item[:status_source]).to eq 'work_order' |
| 336 | + context 'item with process type value' do |
| 337 | + # PROCESS_TYPE_VALUES = ACQ CLAIM_RETURNED_LOAN HOLDSHELF ILL LOAN LOST_ILL LOST_LOAN LOST_LOAN_AND_PAID MISSING REQUESTED TECHNICAL TRANSIT TRANSIT_TO_REMOTE_STORAGE WORK_ORDER_DEPARTMENT |
| 338 | + it '-WORK_ORDER_DEPARTMENT- and work order not AcqWorkOrder or Firestone it has status and label Unavailable' do |
| 339 | + availability = adapter.get_availability_holding(id: '9965126093506421', holding_id: '22202918790006421') |
| 340 | + item = availability.first |
| 341 | + expect(item[:status]).to eq 'Unavailable' |
| 342 | + expect(item[:status_label]).to eq 'Unavailable' |
| 343 | + expect(item[:status_source]).to eq 'process_type' |
| 344 | + end |
| 345 | + |
| 346 | + it '-WORK_ORDER_DEPARTMENT- and work order is AcqWorkOrder it has status Unavailable and label Acquisitions and Cataloging' do |
| 347 | + availability = adapter.get_availability_holding(id: '99131644166406421', holding_id: '221091258440006421') |
| 348 | + item = availability.first |
| 349 | + expect(item[:status]).to eq 'Unavailable' |
| 350 | + expect(item[:status_label]).to eq 'Acquisitions and Cataloging' |
| 351 | + expect(item[:status_source]).to eq 'work_order' |
| 352 | + end |
327 | 353 | end |
328 | 354 |
|
329 | 355 | it 'uses the process_type to calculate status' do |
330 | 356 | availability = adapter.get_availability_holding(id: '9943506421', holding_id: '22261963850006421') |
331 | 357 | item = availability.find { |bib_item| bib_item[:id] == '23261963800006421' } |
332 | 358 | expect(item[:status]).to eq 'Unavailable' |
333 | | - expect(item[:status_label]).to eq 'Transit' |
| 359 | + expect(item[:status_label]).to eq 'Unavailable' |
334 | 360 | expect(item[:status_source]).to eq 'process_type' |
335 | 361 | expect(item[:process_type]).to eq 'TRANSIT' |
336 | 362 | end |
337 | 363 |
|
338 | | - it 'uses the base_status to calculate status' do |
| 364 | + it 'when there is no process_type value it uses the base_status to calculate status' do |
339 | 365 | availability = adapter.get_availability_holding(id: '9943506421', holding_id: '22261963850006421') |
340 | 366 | item = availability.first |
341 | 367 | expect(item[:status]).to eq 'Available' |
|
0 commit comments