From 1a1d55c78722f045830bf846184803f29bebb5c9 Mon Sep 17 00:00:00 2001 From: Jane Sandberg Date: Mon, 30 Dec 2024 12:50:57 -0800 Subject: [PATCH 1/2] Rails 7.2 --- Gemfile | 2 +- Gemfile.lock | 137 +++++++++++++++++++++++++-------------------------- README.md | 2 +- db/schema.rb | 2 +- 4 files changed, 69 insertions(+), 74 deletions(-) diff --git a/Gemfile b/Gemfile index b62095010..b345d36b7 100644 --- a/Gemfile +++ b/Gemfile @@ -2,7 +2,7 @@ source 'https://rubygems.org' -gem 'rails', '~> 7.1.0' +gem 'rails', '~> 7.2.2' gem 'alma' gem 'babel-transpiler' diff --git a/Gemfile.lock b/Gemfile.lock index 8f942ef3c..e17b50b8f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -8,88 +8,82 @@ GIT GEM remote: https://rubygems.org/ specs: - actioncable (7.1.5.1) - actionpack (= 7.1.5.1) - activesupport (= 7.1.5.1) + actioncable (7.2.2.1) + actionpack (= 7.2.2.1) + activesupport (= 7.2.2.1) nio4r (~> 2.0) websocket-driver (>= 0.6.1) zeitwerk (~> 2.6) - actionmailbox (7.1.5.1) - actionpack (= 7.1.5.1) - activejob (= 7.1.5.1) - activerecord (= 7.1.5.1) - activestorage (= 7.1.5.1) - activesupport (= 7.1.5.1) - mail (>= 2.7.1) - net-imap - net-pop - net-smtp - actionmailer (7.1.5.1) - actionpack (= 7.1.5.1) - actionview (= 7.1.5.1) - activejob (= 7.1.5.1) - activesupport (= 7.1.5.1) - mail (~> 2.5, >= 2.5.4) - net-imap - net-pop - net-smtp + actionmailbox (7.2.2.1) + actionpack (= 7.2.2.1) + activejob (= 7.2.2.1) + activerecord (= 7.2.2.1) + activestorage (= 7.2.2.1) + activesupport (= 7.2.2.1) + mail (>= 2.8.0) + actionmailer (7.2.2.1) + actionpack (= 7.2.2.1) + actionview (= 7.2.2.1) + activejob (= 7.2.2.1) + activesupport (= 7.2.2.1) + mail (>= 2.8.0) rails-dom-testing (~> 2.2) - actionpack (7.1.5.1) - actionview (= 7.1.5.1) - activesupport (= 7.1.5.1) + actionpack (7.2.2.1) + actionview (= 7.2.2.1) + activesupport (= 7.2.2.1) nokogiri (>= 1.8.5) racc - rack (>= 2.2.4) + rack (>= 2.2.4, < 3.2) rack-session (>= 1.0.1) rack-test (>= 0.6.3) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) - actiontext (7.1.5.1) - actionpack (= 7.1.5.1) - activerecord (= 7.1.5.1) - activestorage (= 7.1.5.1) - activesupport (= 7.1.5.1) + useragent (~> 0.16) + actiontext (7.2.2.1) + actionpack (= 7.2.2.1) + activerecord (= 7.2.2.1) + activestorage (= 7.2.2.1) + activesupport (= 7.2.2.1) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.1.5.1) - activesupport (= 7.1.5.1) + actionview (7.2.2.1) + activesupport (= 7.2.2.1) builder (~> 3.1) erubi (~> 1.11) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) - activejob (7.1.5.1) - activesupport (= 7.1.5.1) + activejob (7.2.2.1) + activesupport (= 7.2.2.1) globalid (>= 0.3.6) - activemodel (7.1.5.1) - activesupport (= 7.1.5.1) - activerecord (7.1.5.1) - activemodel (= 7.1.5.1) - activesupport (= 7.1.5.1) + activemodel (7.2.2.1) + activesupport (= 7.2.2.1) + activerecord (7.2.2.1) + activemodel (= 7.2.2.1) + activesupport (= 7.2.2.1) timeout (>= 0.4.0) - activestorage (7.1.5.1) - actionpack (= 7.1.5.1) - activejob (= 7.1.5.1) - activerecord (= 7.1.5.1) - activesupport (= 7.1.5.1) + activestorage (7.2.2.1) + actionpack (= 7.2.2.1) + activejob (= 7.2.2.1) + activerecord (= 7.2.2.1) + activesupport (= 7.2.2.1) marcel (~> 1.0) - activesupport (7.1.5.1) + activesupport (7.2.2.1) base64 benchmark (>= 0.3) bigdecimal - concurrent-ruby (~> 1.0, >= 1.0.2) + concurrent-ruby (~> 1.0, >= 1.3.1) connection_pool (>= 2.2.5) drb i18n (>= 1.6, < 2) logger (>= 1.4.2) minitest (>= 5.1) - mutex_m securerandom (>= 0.3) - tzinfo (~> 2.0) + tzinfo (~> 2.0, >= 2.0.5) addressable (2.8.7) public_suffix (>= 2.0.2, < 7.0) airbrussh (1.5.3) sshkit (>= 1.6.1, != 1.7.0) - alma (0.6.1) + alma (0.6.2) activesupport httparty xml-simple @@ -211,7 +205,7 @@ GEM csl-styles (2.0.1) csl (~> 2.0) csv (3.3.0) - datadog (2.7.0) + datadog (2.7.1) datadog-ruby_core_source (~> 3.3) libdatadog (~> 14.1.0.1.0) libddwaf (~> 1.15.0.0.0) @@ -305,7 +299,7 @@ GEM terminal-table (>= 1.8) friendly_id (5.4.2) activerecord (>= 4.0.0) - global (2.1.0) + global (3.0.0) activesupport (>= 2.0) globalid (1.2.1) activesupport (>= 6.1) @@ -489,20 +483,20 @@ GEM rack (>= 1.3) rackup (2.2.1) rack (>= 3) - rails (7.1.5.1) - actioncable (= 7.1.5.1) - actionmailbox (= 7.1.5.1) - actionmailer (= 7.1.5.1) - actionpack (= 7.1.5.1) - actiontext (= 7.1.5.1) - actionview (= 7.1.5.1) - activejob (= 7.1.5.1) - activemodel (= 7.1.5.1) - activerecord (= 7.1.5.1) - activestorage (= 7.1.5.1) - activesupport (= 7.1.5.1) + rails (7.2.2.1) + actioncable (= 7.2.2.1) + actionmailbox (= 7.2.2.1) + actionmailer (= 7.2.2.1) + actionpack (= 7.2.2.1) + actiontext (= 7.2.2.1) + actionview (= 7.2.2.1) + activejob (= 7.2.2.1) + activemodel (= 7.2.2.1) + activerecord (= 7.2.2.1) + activestorage (= 7.2.2.1) + activesupport (= 7.2.2.1) bundler (>= 1.15.0) - railties (= 7.1.5.1) + railties (= 7.2.2.1) rails-controller-testing (1.0.5) actionpack (>= 5.0.1.rc1) actionview (>= 5.0.1.rc1) @@ -514,10 +508,10 @@ GEM rails-html-sanitizer (1.6.2) loofah (~> 2.21) nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0) - railties (7.1.5.1) - actionpack (= 7.1.5.1) - activesupport (= 7.1.5.1) - irb + railties (7.2.2.1) + actionpack (= 7.2.2.1) + activesupport (= 7.2.2.1) + irb (~> 1.13) rackup (>= 1.0.0) rake (>= 12.2) thor (~> 1.0, >= 1.2.2) @@ -585,7 +579,7 @@ GEM rubocop-performance (1.23.0) rubocop (>= 1.48.1, < 2.0) rubocop-ast (>= 1.31.1, < 2.0) - rubocop-rails (2.27.0) + rubocop-rails (2.28.0) activesupport (>= 4.2.0) rack (>= 1.1) rubocop (>= 1.52.0, < 2.0) @@ -704,6 +698,7 @@ GEM unf (0.2.0) unicode-display_width (2.6.0) uri (1.0.2) + useragent (0.16.11) vcr (6.3.1) base64 view_component (2.83.0) @@ -811,7 +806,7 @@ DEPENDENCIES puma (~> 6.4) rack-attack rack-mini-profiler - rails (~> 7.1.0) + rails (~> 7.2.2) rails-controller-testing rake redis diff --git a/README.md b/README.md index 9a892b7f3..56832396e 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Status](https://coveralls.io/repos/github/pulibrary/orangelight/badge.svg?branch Versions: * Ruby: 3.3.6 -* Rails: 7.1 +* Rails: 7.2 * Blacklight: 8.7 ## Development pre-requisites diff --git a/db/schema.rb b/db/schema.rb index e47a29167..b3c87ce81 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.1].define(version: 2024_07_25_171021) do +ActiveRecord::Schema[7.2].define(version: 2024_07_25_171021) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" enable_extension "unaccent" From b528c41be8286d6e6b7b83bab8b70af276362a13 Mon Sep 17 00:00:00 2001 From: Jane Sandberg Date: Mon, 30 Dec 2024 14:05:22 -0800 Subject: [PATCH 2/2] Remove custom fixture method Rails 7.2 has one by the same name, which conflicts with ours. We can use the built-in file_fixture method instead. --- .../requests/form_controller_spec.rb | 6 ++--- spec/features/email_authentication_spec.rb | 2 +- spec/features/requests/form_spec.rb | 24 +++++++++---------- spec/features/requests/marquand_spec.rb | 2 +- spec/mailers/requests/request_mailer_spec.rb | 2 +- spec/models/concerns/requests/scsb_spec.rb | 2 +- spec/models/requests/alma_patron_spec.rb | 2 +- spec/models/requests/form_no_vcr_spec.rb | 2 +- spec/models/requests/full_patron_spec.rb | 2 +- spec/models/requests/patron_spec.rb | 8 +++---- spec/models/requests/router_spec.rb | 2 +- .../requests/submissions/hold_item_spec.rb | 6 ++--- .../models/requests/submissions/recap_spec.rb | 20 ++++++++-------- spec/rails_helper.rb | 4 ---- spec/support/stub_helpers.rb | 2 +- spec/views/feedback/feedback_spec.rb | 2 +- 16 files changed, 42 insertions(+), 46 deletions(-) diff --git a/spec/controllers/requests/form_controller_spec.rb b/spec/controllers/requests/form_controller_spec.rb index 48bfac674..450273308 100644 --- a/spec/controllers/requests/form_controller_spec.rb +++ b/spec/controllers/requests/form_controller_spec.rb @@ -3,9 +3,9 @@ require "mail" describe Requests::FormController, type: :controller, vcr: { cassette_name: 'form_controller', record: :none }, requests: true do - let(:valid_patron_response) { fixture('/bibdata_patron_response.json') } - let(:valid_barcode_patron_response) { fixture('/bibdata_patron_response_barcode.json') } - let(:invalid_patron_response) { fixture('/bibdata_not_found_patron_response.json') } + let(:valid_patron_response) { file_fixture('../bibdata_patron_response.json') } + let(:valid_barcode_patron_response) { file_fixture('../bibdata_patron_response_barcode.json') } + let(:invalid_patron_response) { file_fixture('../bibdata_not_found_patron_response.json') } let(:user) { FactoryBot.create(:user) } describe 'POST #generate' do diff --git a/spec/features/email_authentication_spec.rb b/spec/features/email_authentication_spec.rb index 79f0b779a..4005fcf50 100644 --- a/spec/features/email_authentication_spec.rb +++ b/spec/features/email_authentication_spec.rb @@ -5,7 +5,7 @@ describe 'email form' do let(:bibid) { '9979948663506421' } let(:user) { FactoryBot.create(:valid_princeton_patron) } - let(:valid_patron_response) { fixture('/bibdata_patron_response.json') } + let(:valid_patron_response) { file_fixture('../bibdata_patron_response.json') } before do current_illiad_user_uri = "#{Requests.config[:illiad_api_base]}/ILLiadWebPlatform/Users/jstudent" diff --git a/spec/features/requests/form_spec.rb b/spec/features/requests/form_spec.rb index aab615241..523722ee5 100644 --- a/spec/features/requests/form_spec.rb +++ b/spec/features/requests/form_spec.rb @@ -21,13 +21,13 @@ let(:transaction_url) { "https://lib-illiad.princeton.edu/ILLiadWebPlatform/transaction" } let(:transaction_note_url) { "https://lib-illiad.princeton.edu/ILLiadWebPlatform/transaction/1093806/notes" } - let(:valid_patron_response) { fixture('/bibdata_patron_response.json') } - let(:valid_patron_no_barcode_response) { fixture('/bibdata_patron_no_barcode_response.json') } - let(:valid_barcode_patron_response) { fixture('/bibdata_patron_response_barcode.json') } - let(:valid_patron_no_campus_response) { fixture('/bibdata_patron_response_no_campus.json') } - let(:valid_graduate_student_no_campus_response) { fixture('/bibdata_patron_response_graduate_no_campus.json') } - let(:invalid_patron_response) { fixture('/bibdata_not_found_patron_response.json') } - let(:valid_patron_response_no_ldap) { fixture('/bibdata_patron_response_no_ldap.json') } + let(:valid_patron_response) { file_fixture('../bibdata_patron_response.json') } + let(:valid_patron_no_barcode_response) { file_fixture('../bibdata_patron_no_barcode_response.json') } + let(:valid_barcode_patron_response) { file_fixture('../bibdata_patron_response_barcode.json') } + let(:valid_patron_no_campus_response) { file_fixture('../bibdata_patron_response_no_campus.json') } + let(:valid_graduate_student_no_campus_response) { file_fixture('../bibdata_patron_response_graduate_no_campus.json') } + let(:invalid_patron_response) { file_fixture('../bibdata_not_found_patron_response.json') } + let(:valid_patron_response_no_ldap) { file_fixture('../bibdata_patron_response_no_ldap.json') } let(:responses) do { @@ -106,7 +106,7 @@ end describe 'When visiting an Alma ID as a CAS User' do - let(:good_response) { fixture('/scsb_request_item_response.json') } + let(:good_response) { file_fixture('../scsb_request_item_response.json') } it 'Shows a ReCAP PUL item that is at "preservation and conservation" as a partner request' do stub_illiad_patron stub_request(:post, transaction_url) @@ -149,7 +149,7 @@ .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' }) + .to_return(status: 200, body: file_fixture("../alma_hold_response.json"), headers: { 'content-type': 'application/json' }) visit "/requests/#{mms_id}" expect(page).to have_content 'Electronic Delivery' # some weird issue with this and capybara examining the page source shows it is there. @@ -526,7 +526,7 @@ .to_return(status: 200, body: good_response, headers: {}) stub_request(:post, "#{Alma.configuration.region}/almaws/v1/bibs/99115783193506421/holdings/22534122440006421/items/23534122430006421/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' }) + .to_return(status: 200, body: file_fixture("../alma_hold_response.json"), headers: { 'content-type': 'application/json' }) visit '/requests/99115783193506421?mfhd=22534122440006421' expect(page).not_to have_content 'Item is not requestable.' expect(page).not_to have_content 'Electronic Delivery' @@ -1124,7 +1124,7 @@ expect(page).not_to have_content 'Only items available for digitization can be requested when you do not have a barcode registered with the Library. Library staff will work to try to get you access to a digital copy of the desired material.' end - let(:good_response) { fixture('/scsb_request_item_response.json') } + let(:good_response) { file_fixture('../scsb_request_item_response.json') } it 'disallows access to request a physical ReCAP item' do stub_scsb_availability(bib_id: "9999443553506421", institution_id: "PUL", barcode: '32101098722844') visit '/requests/9999443553506421?mfhd=22743365320006421' @@ -1247,7 +1247,7 @@ end context 'An Alma user that does not have a Net ID' do - let(:alma_login_response) { fixture('/alma_login_response.json') } + let(:alma_login_response) { file_fixture('../alma_login_response.json') } let(:user) { FactoryBot.create(:valid_alma_patron) } before do stub_request(:get, "#{Alma.configuration.region}/almaws/v1/users/#{user.uid}?expand=fees,requests,loans") diff --git a/spec/features/requests/marquand_spec.rb b/spec/features/requests/marquand_spec.rb index 955312deb..686024e32 100644 --- a/spec/features/requests/marquand_spec.rb +++ b/spec/features/requests/marquand_spec.rb @@ -96,7 +96,7 @@ stub_request(:post, "#{Requests.config[:scsb_base]}/requestItem/requestItem") .to_return(status: 200, body: good_response, headers: {}) end - let(:good_response) { fixture('/scsb_request_item_response.json') } + let(:good_response) { file_fixture('../scsb_request_item_response.json') } before do scsb_post_stub stub_scsb_availability(bib_id:, institution_id: "PUL", barcode: item_barcode) diff --git a/spec/mailers/requests/request_mailer_spec.rb b/spec/mailers/requests/request_mailer_spec.rb index b3a11244c..8beb089b8 100644 --- a/spec/mailers/requests/request_mailer_spec.rb +++ b/spec/mailers/requests/request_mailer_spec.rb @@ -5,7 +5,7 @@ # rubocop:disable RSpec/MultipleExpectations # rubocop:disable Metrics/BlockLength describe Requests::RequestMailer, type: :mailer, vcr: { cassette_name: 'mailer', record: :none }, requests: true do - let(:valid_patron_response) { fixture('/bibdata_patron_response.json') } + let(:valid_patron_response) { file_fixture('../bibdata_patron_response.json') } let(:user_info) do stub_request(:get, "#{Requests.config[:bibdata_base]}/patron/foo?ldap=true").to_return(status: 200, body: valid_patron_response, headers: {}) diff --git a/spec/models/concerns/requests/scsb_spec.rb b/spec/models/concerns/requests/scsb_spec.rb index a67e352e4..817d837db 100644 --- a/spec/models/concerns/requests/scsb_spec.rb +++ b/spec/models/concerns/requests/scsb_spec.rb @@ -11,7 +11,7 @@ let(:patron) do Requests::Patron.new(user:, patron_hash: valid_patron) end - let(:scsb_no_format) { fixture('/SCSB-7935196.json') } + let(:scsb_no_format) { file_fixture('../SCSB-7935196.json') } let(:location_code) { 'scsbnypl' } let(:params) do { diff --git a/spec/models/requests/alma_patron_spec.rb b/spec/models/requests/alma_patron_spec.rb index 9c1875419..7356f9730 100644 --- a/spec/models/requests/alma_patron_spec.rb +++ b/spec/models/requests/alma_patron_spec.rb @@ -4,7 +4,7 @@ RSpec.describe Requests::AlmaPatron, requests: true, patrons: true do context 'with a call to Alma' do let(:uid) { 'BC123456789' } - let(:patron_with_multiple_barcodes) { fixture('/BC123456789.json') } + let(:patron_with_multiple_barcodes) { file_fixture('../BC123456789.json') } let(:alma_stub) do stub_request(:get, "https://api-na.hosted.exlibrisgroup.com/almaws/v1/users/#{uid}?expand=fees,requests,loans") .to_return(status: 200, body: patron_with_multiple_barcodes, headers: { "Content-Type" => "application/json" }) diff --git a/spec/models/requests/form_no_vcr_spec.rb b/spec/models/requests/form_no_vcr_spec.rb index 09eb0a9bb..5aea61e11 100644 --- a/spec/models/requests/form_no_vcr_spec.rb +++ b/spec/models/requests/form_no_vcr_spec.rb @@ -27,7 +27,7 @@ stub_request(:get, "https://catalog.princeton.edu/catalog/#{document_id}/raw") .to_return(status: 200, body: catalog_raw_fixture) stub_request(:get, "#{Requests.config[:bibdata_base]}/locations/holding_locations/eastasian$cjk.json") - .to_return(status: 200, body: fixture('/bibdata/eastasian_cjk_holding_locations.json')) + .to_return(status: 200, body: file_fixture('../bibdata/eastasian_cjk_holding_locations.json')) stub_request(:get, "#{Requests.config[:bibdata_base]}/bibliographic/#{params[:system_id]}/holdings/#{params[:mfhd]}/availability.json").to_timeout stub_delivery_locations end diff --git a/spec/models/requests/full_patron_spec.rb b/spec/models/requests/full_patron_spec.rb index 0fed1bc6b..df1a316c7 100644 --- a/spec/models/requests/full_patron_spec.rb +++ b/spec/models/requests/full_patron_spec.rb @@ -10,7 +10,7 @@ context 'with a patron' do let(:patron) { described_class.new(user:) } - let(:valid_patron_response) { fixture('/bibdata_patron_response.json') } + let(:valid_patron_response) { file_fixture('../bibdata_patron_response.json') } let(:bibdata_mock) do stub_request(:get, "#{Requests.config[:bibdata_base]}/patron/abc123?ldap=true") .to_return(status: 200, body: valid_patron_response, headers: {}) diff --git a/spec/models/requests/patron_spec.rb b/spec/models/requests/patron_spec.rb index 50d74bca3..57b5478e8 100644 --- a/spec/models/requests/patron_spec.rb +++ b/spec/models/requests/patron_spec.rb @@ -18,16 +18,16 @@ instance_double(User, guest?: guest?, uid:, alma_provider?: false, provider:, valid?: true) end let(:bibdata_uri) { Requests.config[:bibdata_base] } - let(:valid_patron_response) { fixture('/bibdata_patron_response.json') } - let(:valid_barcode_patron_response) { fixture('/bibdata_patron_response_barcode.json') } - let(:invalid_patron_response) { fixture('/bibdata_not_found_patron_response.json') } + let(:valid_patron_response) { file_fixture('../bibdata_patron_response.json') } + let(:valid_barcode_patron_response) { file_fixture('../bibdata_patron_response_barcode.json') } + let(:invalid_patron_response) { file_fixture('../bibdata_not_found_patron_response.json') } context 'when the user is provided from Alma' do let(:uid) { 'BC123456789' } let(:user) do instance_double(User, guest?: guest?, uid:, alma_provider?: true, provider:) end - let(:patron_with_multiple_barcodes) { fixture('/BC123456789.json') } + let(:patron_with_multiple_barcodes) { file_fixture('../BC123456789.json') } before do stub_request(:get, "https://api-na.hosted.exlibrisgroup.com/almaws/v1/users/#{uid}?expand=fees,requests,loans") diff --git a/spec/models/requests/router_spec.rb b/spec/models/requests/router_spec.rb index 420c1914b..3149eaea3 100644 --- a/spec/models/requests/router_spec.rb +++ b/spec/models/requests/router_spec.rb @@ -9,7 +9,7 @@ Requests::Patron.new(user:, patron_hash: valid_patron) end - let(:scsb_single_holding_item) { fixture('/SCSB-2635660.json') } + let(:scsb_single_holding_item) { file_fixture('../SCSB-2635660.json') } let(:location_code) { 'scsbcul' } let(:params) do { diff --git a/spec/models/requests/submissions/hold_item_spec.rb b/spec/models/requests/submissions/hold_item_spec.rb index 711f36104..9207c6f7e 100644 --- a/spec/models/requests/submissions/hold_item_spec.rb +++ b/spec/models/requests/submissions/hold_item_spec.rb @@ -49,9 +49,9 @@ let(:responses) do { - error: fixture("alma_hold_error_response.json"), - error_malformed: fixture("alma_hold_error_no_library_response.json"), - success: fixture("alma_hold_response.json") + error: file_fixture("../alma_hold_error_response.json"), + error_malformed: file_fixture("../alma_hold_error_no_library_response.json"), + success: file_fixture("../alma_hold_response.json") } end diff --git a/spec/models/requests/submissions/recap_spec.rb b/spec/models/requests/submissions/recap_spec.rb index a30dd83cd..0a5d95f77 100644 --- a/spec/models/requests/submissions/recap_spec.rb +++ b/spec/models/requests/submissions/recap_spec.rb @@ -82,9 +82,9 @@ let(:recap_request) { described_class.new(submission) } let(:recap_edd_request) { described_class.new(submission, service_type: 'recap_edd') } - let(:good_request) { fixture('/scsb_find_request.json') } - let(:good_response) { fixture('/scsb_request_item_response.json') } - let(:bad_response) { fixture('/scsb_request_item_response_errors.json') } + let(:good_request) { file_fixture('../scsb_find_request.json') } + let(:good_response) { file_fixture('../scsb_request_item_response.json') } + let(:bad_response) { file_fixture('../scsb_request_item_response_errors.json') } describe 'All ReCAP Requests' do it "captures recap errors when the request is unsuccessful or malformed." do @@ -125,7 +125,7 @@ .to_return(status: 200, body: good_response, headers: {}) stub_request(:post, alma_url) .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' }) + .to_return(status: 200, body: file_fixture("../alma_hold_response.json"), headers: { 'content-type': 'application/json' }) expect { recap_request.handle }.to change { ActionMailer::Base.deliveries.count }.by(0) expect(recap_request.submitted.size).to eq(1) expect(recap_request.errors.size).to eq(0) @@ -138,7 +138,7 @@ .to_return(status: 200, body: good_response, headers: {}) stub_request(:post, alma_url) .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' }) + .to_return(status: 200, body: file_fixture("../alma_hold_response.json"), headers: { 'content-type': 'application/json' }) expect { recap_edd_request.handle }.to change { ActionMailer::Base.deliveries.count }.by(0) expect(recap_edd_request.submitted.size).to eq(1) expect(recap_edd_request.errors.size).to eq(0) @@ -151,7 +151,7 @@ .to_return(status: 200, body: good_response, headers: {}) stub_request(:post, alma_url) .with(body: hash_including(request_type: "HOLD", pickup_location_type: "LIBRARY", pickup_location_library: "firestone")) - .to_return(status: 400, body: fixture("alma_hold_error_no_library_response.json"), headers: { 'content-type': 'application/json' }) + .to_return(status: 400, body: file_fixture("../alma_hold_error_no_library_response.json"), headers: { 'content-type': 'application/json' }) expect do recap_request.handle perform_enqueued_jobs @@ -287,8 +287,8 @@ end let(:recap_request) { described_class.new(submission) } - let(:good_request) { fixture('/scsb_find_request.json') } - let(:good_response) { fixture('/scsb_request_item_response.json') } + let(:good_request) { file_fixture('../scsb_find_request.json') } + let(:good_response) { file_fixture('../scsb_request_item_response.json') } describe 'All ReCAP Requests' do it "captures successful request submissions." do @@ -296,10 +296,10 @@ .to_return(status: 200, body: good_response, headers: {}) stub_request(:post, alma_url) .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' }) + .to_return(status: 200, body: file_fixture("../alma_hold_response.json"), headers: { 'content-type': 'application/json' }) stub_request(:post, alma2_url) .with(body: hash_including(request_type: "HOLD", pickup_location_type: "LIBRARY", pickup_location_library: "mudd")) - .to_return(status: 200, body: fixture("alma_hold_response.json"), headers: { 'content-type': 'application/json' }) + .to_return(status: 200, body: file_fixture("../alma_hold_response.json"), headers: { 'content-type': 'application/json' }) expect { recap_request.handle }.to change { ActionMailer::Base.deliveries.count }.by(0) expect(recap_request.submitted.size).to eq(2) expect(recap_request.errors.size).to eq(0) diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index a4a02fe08..9358c365b 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -79,10 +79,6 @@ config.after { Rails.cache.clear } end -def fixture(file) - File.open(File.join(File.dirname(__FILE__), 'fixtures', file), 'rb') -end - def wait_for_ajax counter = 0 while page.execute_script('return $.active').to_i > 0 diff --git a/spec/support/stub_helpers.rb b/spec/support/stub_helpers.rb index 22921b3c7..a10bb8df2 100644 --- a/spec/support/stub_helpers.rb +++ b/spec/support/stub_helpers.rb @@ -19,7 +19,7 @@ def stub_alma_hold(id, mfhd, item_id, patron_id, status: 200, fixture_name: "alm stub_url = "#{Alma.configuration.region}/almaws/v1/bibs/#{id}/holdings/#{mfhd}/items/#{item_id}/requests?user_id=#{patron_id}" stub_request(:post, stub_url) .to_return(status:, - body: fixture(fixture_name), + body: file_fixture("../#{fixture_name}"), headers: { 'content-type': 'application/json' }) end # rubocop:enable Metrics/ParameterLists diff --git a/spec/views/feedback/feedback_spec.rb b/spec/views/feedback/feedback_spec.rb index 9370cc7c7..9f6771736 100644 --- a/spec/views/feedback/feedback_spec.rb +++ b/spec/views/feedback/feedback_spec.rb @@ -44,7 +44,7 @@ context 'Princeton Community User has signed in' do let(:user) { FactoryBot.create(:valid_princeton_patron) } - let(:valid_patron_response) { fixture('/bibdata_patron_response.json') } + let(:valid_patron_response) { file_fixture('../bibdata_patron_response.json') } it 'Populates Email Field' do stub_request(:get, "#{Requests.config['bibdata_base']}/patron/#{user.uid}")