diff --git a/spec/features/requests/requests_by_patron_group_spec.rb b/spec/features/requests/requests_by_patron_group_spec.rb new file mode 100644 index 000000000..eb9bcf248 --- /dev/null +++ b/spec/features/requests/requests_by_patron_group_spec.rb @@ -0,0 +1,95 @@ +# frozen_string_literal: true +require 'rails_helper' + +RSpec.shared_examples "can request", vcr: { cassette_name: 'request_features', record: :none } do + let(:mms_id) { '9994933183506421?mfhd=22558528920006421' } + let(:user) { FactoryBot.create(:user) } + let(:username) { "netid123" } + + # Make a decision (for this file) to use either stubs or VCR, not both + # Currently failing: + # @submission.service_errors + # [{:type=>"recap", :bibid=>"9994933183506421", :item=>["32101095798938"], :user_name=>"netid123", :barcode=>"22101000009999", :error=>"Request failed because Authentication Failed\n"}] + + before do + login_as user + stub_alma_holding_locations + stub_single_holding_location("recap$pa") + stub_availability_by_holding_id(bib_id:"9994933183506421", holding_id:"22558528920006421", body: true) + stub_delivery_locations + patron_record_uri = "#{Requests.config['bibdata_base']}/patron/#{user.uid}?ldap=true" + stub_request(:get, patron_record_uri) + .to_return(status: 200, body: patron_response, headers: {}) + end + + it "PUL ReCAP print item", js: true do + stub_catalog_raw(bib_id: '9994933183506421') + stub_scsb_availability(bib_id: "9994933183506421", institution_id: "PUL", barcode: '32101095798938') + scsb_url = "#{Requests::Config[:scsb_base]}/requestItem/requestItem" + stub_request(:post, scsb_url) + .with(body: hash_including(author: "", bibId: "9994933183506421", callNumber: "PJ7962.A5495 A95 2016", chapterTitle: "", deliveryLocation: "PA", emailAddress: 'a@b.com', endPage: "", issue: "", itemBarcodes: ["32101095798938"], itemOwningInstitution: "PUL", patronBarcode: "22101008199999", + requestNotes: "", requestType: "RETRIEVAL", requestingInstitution: "PUL", startPage: "", titleIdentifier: "ʻAwāṭif madfūnah عواطف مدفونة", username: username, volume: "")) + .to_return(status: 200, body: good_response, headers: {}) + stub_request(:post, Requests::Config[:scsb_base]) + .with(headers: { 'Accept' => '*/*' }) + .to_return(status: 200, body: "", headers: {}) + stub_request(:post, "#{Alma.configuration.region}/almaws/v1/bibs/9994933183506421/holdings/22558528920006421/items/23558528910006421/requests?user_id=960594184") + .with(body: hash_including(request_type: "HOLD", pickup_location_type: "LIBRARY", pickup_location_library: "firestone")) + .to_return(status: 200, body: fixture("alma_hold_response.json"), headers: { 'content-type': 'application/json' }) + visit "/requests/#{mms_id}" + expect(page).to have_content 'Electronic Delivery' + expect(page).to have_selector '#request_user_barcode', visible: :hidden + choose('requestable__delivery_mode_23558528910006421_print') # chooses 'print' radio button + select('Firestone Library', from: 'requestable__pick_up_23558528910006421') + expect { click_button 'Request this Item' }.to change { ActionMailer::Base.deliveries.count }.by(1) + expect(a_request(:post, scsb_url)).to have_been_made + expect(page).to have_content I18n.t("requests.submit.recap_success") + confirm_email = ActionMailer::Base.deliveries.last + expect(confirm_email.subject).to eq("Patron Initiated Catalog Request Confirmation") + expect(confirm_email.html_part.body.to_s).not_to have_content("translation missing") + expect(confirm_email.text_part.body.to_s).not_to have_content("translation missing") + expect(confirm_email.to).to eq(["a@b.com"]) + expect(confirm_email.cc).to be_blank + expect(confirm_email.html_part.body.to_s).to have_content("ʻAwāṭif madfūnah") + expect(confirm_email.html_part.body.to_s).not_to have_content("Remain only in the designated pick-up area") + end + +end + +describe 'Faculty and Professional (P)' do + let(:patron_response) { fixture('/bibdata/patron/faculty.json') } + let(:good_response) { fixture('/scsb_request_item_response.json') } + it_behaves_like "can request" +end + +describe 'Regular Staff (REG)' do +end + +describe 'Graduate Student (GRAD)' do +end + +describe 'Senior Undergraduate (SENR)' do +end + +describe 'Undergraduate (UGRAD)' do +end + +describe 'Faculty Affiliate (Affiliate-P)' do + context 'when logging in using a NetID in CAS' do + end + context 'when logging in using Alma' do + end +end + +describe 'Affiliate (Affiliate)' do + context 'when logging in using a NetID in CAS' do + end + context 'when logging in using Alma' do + end +end + +describe 'Guest Patron (GST)' do +end + +describe 'Casual Hourly (CASUAL)' do +end diff --git a/spec/fixtures/availability/by_holding_id/9994933183506421_22558528920006421.json b/spec/fixtures/availability/by_holding_id/9994933183506421_22558528920006421.json new file mode 100644 index 000000000..e4f0d961c --- /dev/null +++ b/spec/fixtures/availability/by_holding_id/9994933183506421_22558528920006421.json @@ -0,0 +1,22 @@ +[ +{ +"barcode": "32101095798938", +"id": "23558528910006421", +"holding_id": "22558528920006421", +"copy_number": "0", +"status": "Available", +"status_label": "Item in place", +"status_source": "base_status", +"process_type": null, +"on_reserve": "N", +"item_type": "Gen", +"pickup_location_id": "recap", +"pickup_location_code": "recap", +"location": "recap$pa", +"label": "ReCAP - Remote Storage", +"description": "", +"enum_display": "", +"chron_display": "", +"in_temp_library": false +} +] \ No newline at end of file diff --git a/spec/fixtures/bibdata/patron/faculty.json b/spec/fixtures/bibdata/patron/faculty.json new file mode 100644 index 000000000..c98a919f2 --- /dev/null +++ b/spec/fixtures/bibdata/patron/faculty.json @@ -0,0 +1,13 @@ +{ + "netid": "netid123", + "first_name": "Faculty", + "last_name": "Faculty", + "barcode": "22101000009999", + "university_id": "1234", + "patron_id": "5678", + "patron_group": "staff", + "patron_group_desc": "P Faculty & Professional", + "active_email": "netid123@Princeton.EDU", + "campus_authorized": true, + "campus_authorized_category": "full" +} diff --git a/spec/fixtures/raw/9994933183506421.json b/spec/fixtures/raw/9994933183506421.json new file mode 100644 index 000000000..1fb63d7d6 --- /dev/null +++ b/spec/fixtures/raw/9994933183506421.json @@ -0,0 +1,126 @@ +{ +"id": "9994933183506421", +"numeric_id_b": true, +"author_display": [ +"Samḥān, Najāt", +"سمحان، نجاة،" +], +"author_citation_display": [ +"Samḥān, Najāt" +], +"author_roles_1display": "{\"secondary_authors\":[\"سمحان، نجاة،\"],\"translators\":[],\"editors\":[],\"compilers\":[],\"primary_author\":\"Samḥān, Najāt\"}", +"author_s": [ +"Samḥān, Najāt", +"سمحان، نجاة،" +], +"marc_relator_display": [ +"Author" +], +"title_display": "ʻAwāṭif madfūnah / Najāt al-Samḥān.", +"title_vern_display": "عواطف مدفونة / نجاة السمحان.", +"title_t": [ +"ʻAwāṭif madfūnah / Najāt al-Samḥān." +], +"title_citation_display": [ +"ʻAwāṭif madfūnah", +"عواطف مدفونة" +], +"compiled_created_t": [ +"ʻAwāṭif madfūnah / Najāt al-Samḥān.", +"عواطف مدفونة / نجاة السمحان." +], +"pub_created_vern_display": [ +"القاهرة : دار الكتاب الحديث، 2016." +], +"pub_created_display": [ +"al-Qāhirah : Dār al-Kitāb al-Ḥadīth, 2016.", +"القاهرة : دار الكتاب الحديث، 2016." +], +"pub_created_s": [ +"al-Qāhirah : Dār al-Kitāb al-Ḥadīth, 2016.", +"القاهرة : دار الكتاب الحديث، 2016." +], +"pub_citation_display": [ +"al-Qāhirah: Dār al-Kitāb al-Ḥadīth", +"القاهرة: دار الكتاب الحديث،" +], +"pub_date_display": [ +"2016" +], +"pub_date_start_sort": 2016, +"cataloged_tdt": "2016-01-19T00:00:00Z", +"format": [ +"Book" +], +"description_display": [ +"230 pages ; 20 cm" +], +"description_t": [ +"230 pages ; 20 cm" +], +"number_of_pages_citation_display": [ +"230 pages" +], +"notes_display": [ +"Short stories." +], +"language_name_display": [ +"Arabic" +], +"language_facet": [ +"Arabic" +], +"language_iana_s": [ +"ar" +], +"lc_subject_display": [ +"Short stories, Arabic—21st century" +], +"subject_facet": [ +"Short stories, Arabic—21st century" +], +"isbn_display": [ +"9789773506827", +"9773506827" +], +"isbn_s": [ +"9789773506827" +], +"oclc_s": [ +"932335821" +], +"other_version_s": [ +"9789773506827", +"ocn932335821" +], +"subject_era_facet": [ +"21st century" +], +"holdings_1display": "{\"22558528920006421\":{\"location_code\":\"recap$pa\",\"location\":\"Remote Storage\",\"library\":\"ReCAP\",\"call_number\":\"PJ7962.A5495 A95 2016\",\"call_number_browse\":\"PJ7962.A5495 A95 2016\",\"items\":[{\"holding_id\":\"22558528920006421\",\"id\":\"23558528910006421\",\"status_at_load\":\"1\",\"barcode\":\"32101095798938\",\"copy_number\":\"0\"}]}}", +"location_code_s": [ +"recap$pa" +], +"location": [ +"ReCAP" +], +"location_display": [ +"Remote Storage" +], +"advanced_location_s": [ +"recap$pa", +"ReCAP" +], +"name_title_browse_s": [ +"Samḥān, Najāt. ʻAwāṭif madfūnah", +"سمحان، نجاة،. عواطف مدفونة" +], +"call_number_display": [ +"PJ7962.A5495 A95 2016" +], +"call_number_browse_s": [ +"PJ7962.A5495 A95 2016" +], +"call_number_locator_display": [ +"PJ7962.A5495 A95 2016" +] +} \ No newline at end of file