From 1615a3750a32f751ef4cc1280b6551c6a352ffbf Mon Sep 17 00:00:00 2001 From: Christina Chortaria Date: Mon, 16 Sep 2024 09:05:05 -0400 Subject: [PATCH] [#4303] Remove commented code and comments that are not needed anymore --- app/models/requests/illiad_client.rb | 3 -- app/models/requests/patron.rb | 2 -- app/models/requests/requestable/item.rb | 2 -- app/models/requests/requestable_decorator.rb | 2 -- app/models/requests/submission.rb | 8 ++--- spec/models/requests/requestable_spec.rb | 8 ++--- .../models/requests/submissions/recap_spec.rb | 35 ++++++++----------- 7 files changed, 20 insertions(+), 40 deletions(-) diff --git a/app/models/requests/illiad_client.rb b/app/models/requests/illiad_client.rb index 3adaa747a..f46f353ce 100644 --- a/app/models/requests/illiad_client.rb +++ b/app/models/requests/illiad_client.rb @@ -1,8 +1,5 @@ # frozen_string_literal: true -# require 'faraday' -# require 'faraday-cookie_jar' - module Requests class IlliadClient attr_reader :illiad_api_base, :illiad_api_key, :error diff --git a/app/models/requests/patron.rb b/app/models/requests/patron.rb index 7b7068bd6..199c7ab37 100644 --- a/app/models/requests/patron.rb +++ b/app/models/requests/patron.rb @@ -95,8 +95,6 @@ def to_h def load_patron(user:) patron_hash = current_patron_hash(user.uid) errors << "A problem occurred looking up your library account." if patron_hash.blank? - # Uncomment to fake being a non barcoded user - # patron_hash[:barcode] = nil patron_hash || {} end diff --git a/app/models/requests/requestable/item.rb b/app/models/requests/requestable/item.rb index 2fa40e95c..0919966c7 100644 --- a/app/models/requests/requestable/item.rb +++ b/app/models/requests/requestable/item.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true class Requests::Requestable class Item < SimpleDelegator - # pick_up_location_code on the item level def pick_up_location_code self['pickup_location_code'] || "" end @@ -64,7 +63,6 @@ def enumerated? enum_value.present? end - # item type on the item level def item_type_non_circulate? ['NoCirc', 'Closed', 'Res-No'].include? item_type end diff --git a/app/models/requests/requestable_decorator.rb b/app/models/requests/requestable_decorator.rb index 05240c588..ca0af0489 100644 --- a/app/models/requests/requestable_decorator.rb +++ b/app/models/requests/requestable_decorator.rb @@ -143,8 +143,6 @@ def delivery_location_code "PJ" elsif requestable.cul_music? "PK" - # elsif requestable.recap_pf? - # "PF" else first_delivery_location[:gfa_pickup] || "PA" end diff --git a/app/models/requests/submission.rb b/app/models/requests/submission.rb index 2f36d2b00..a86577b32 100644 --- a/app/models/requests/submission.rb +++ b/app/models/requests/submission.rb @@ -5,11 +5,11 @@ module Requests class Submission include ActiveModel::Validations - validates :email, presence: true, email: true, length: { minimum: 5, maximum: 50 } # , format: { message: "Supply a Valid Email Address" } #, on: :submit - validates :user_name, presence: true, length: { minimum: 1, maximum: 50 } # , format: { message: "Name Can't be Blank" } #, on: :submit + validates :email, presence: true, email: true, length: { minimum: 5, maximum: 50 } + validates :user_name, presence: true, length: { minimum: 1, maximum: 50 } validates :user_barcode, allow_blank: true, presence: true, length: { minimum: 5, maximum: 14 }, format: { with: /(^\d{14}$)/i, message: "Please supply a valid library barcode" } - validate :item_validations # , presence: true, length: { minimum: 1 }, on: :submit + validate :item_validations def initialize(params, patron) @patron = patron @@ -92,7 +92,6 @@ def marquand? end def edd?(item) - # return false if item["type"] == "digitize_fill_in" delivery_mode = delivery_mode(item) delivery_mode.present? && delivery_mode == "edd" end @@ -140,7 +139,6 @@ def categorize_by_delivery_and_location(item) end def in_library?(item) - # return false if item["type"] == "digitize_fill_in" delivery_mode = delivery_mode(item) delivery_mode.present? && delivery_mode == "in_library" end diff --git a/spec/models/requests/requestable_spec.rb b/spec/models/requests/requestable_spec.rb index 982fa4d71..df92bdf4c 100644 --- a/spec/models/requests/requestable_spec.rb +++ b/spec/models/requests/requestable_spec.rb @@ -137,7 +137,6 @@ context 'A non circulating item' do let(:request) { FactoryBot.build(:mfhd_with_no_circ_and_circ_item, patron:) } let(:requestable) { request.requestable[12] } - # let(:item) { barcode :"32101024595744", id: 282_632, location: "f", copy_number: 1, item_sequence_number: 14, status: "Not Charged", on_reserve: "N", item_type: "NoCirc", pickup_location_id: 299, pickup_location_code: "fcirc", enum: "vol.22", "chron": "1996", enum_display: "vol.22 (1996)", label: "Firestone Library" } let(:no_circ_item_id) { requestable.item['id'] } let(:no_circ_item_type) { requestable.item['item_type'] } let(:no_circ_pick_up_location_code) { requestable.item['pickup_location_code'] } @@ -156,7 +155,6 @@ context 'A circulating item' do let(:request) { FactoryBot.build(:mfhd_with_no_circ_and_circ_item, patron:) } let(:requestable) { request.requestable[0] } - # let(:item) {"barcode":"32101022548893","id":282628,"location":"f","copy_number":1,"item_sequence_number":10,"status":"Not Charged","on_reserve":"N","item_type":"Gen","pickup_location_id":299,"pickup_location_code":"fcirc","enum_display":"vol.18","chron":"1992","enum_display":"vol.18 (1992)","label":"Firestone Library"} let(:no_circ_item_id) { requestable.item['id'] } let(:no_circ_item_type) { requestable.item['item_type'] } let(:no_circ_pick_up_location_code) { requestable.item['pickup_location_code'] } @@ -573,7 +571,7 @@ context 'A requestable item from Forrestal Annex with no item data' do let(:request) { FactoryBot.build(:request_no_items, patron:) } - let(:requestable) { request.requestable.first } # assume only one requestable + let(:requestable) { request.requestable.first } describe 'requestable with no items ' do it 'does not have item data' do @@ -603,7 +601,7 @@ end ## The JSON response for holding w/no items is empty now. We used to check the availability at the bib level, but that is not available in alma - ## We must therefore assume that a holding with no itesm is not available + ## We must therefore assume that a holding with no items is not available ## https://bibdata-alma-staging.princeton.edu/bibliographic/9944928463506421/holdings/22490610730006421/availability.json describe "#available?" do it "is not available" do @@ -759,7 +757,7 @@ let(:requestable_charged) { requestable_holding.first } describe '#checked-out requestable' do - # Barcode users should NOT have the following privileges ... + # Barcode users should NOT have the following privileges it "does not have ILL request service available" do expect(requestable_charged.services.include?('ill')).to be false diff --git a/spec/models/requests/submissions/recap_spec.rb b/spec/models/requests/submissions/recap_spec.rb index 8fc21c019..7c9194e8a 100644 --- a/spec/models/requests/submissions/recap_spec.rb +++ b/spec/models/requests/submissions/recap_spec.rb @@ -86,9 +86,8 @@ describe 'All ReCAP Requests' do it "captures recap errors when the request is unsuccessful or malformed." do - stub_request(:post, scsb_url). - # with(headers: { 'Accept' => '*/*', 'Content-Type' => "application/json", 'api_key' => 'TESTME' }). - to_return(status: 401, body: "Unauthorized", headers: {}) + stub_request(:post, scsb_url) + .to_return(status: 401, body: "Unauthorized", headers: {}) expect { recap_request.handle }.to change { ActionMailer::Base.deliveries.count }.by(0) expect(recap_request.submitted.size).to eq(0) expect(recap_request.errors.size).to eq(1) @@ -98,9 +97,8 @@ end it "captures recap edd errors when the request is unsuccessful or malformed." do - stub_request(:post, scsb_url). - # with(headers: { 'Accept' => '*/*', 'Content-Type' => "application/json", 'api_key' => 'TESTME' }). - to_return(status: 401, body: "Unauthorized", headers: {}) + stub_request(:post, scsb_url) + .to_return(status: 401, body: "Unauthorized", headers: {}) expect { recap_edd_request.handle }.to change { ActionMailer::Base.deliveries.count }.by(0) expect(recap_edd_request.submitted.size).to eq(0) expect(recap_edd_request.errors.size).to eq(1) @@ -110,9 +108,8 @@ end it "captures errors when response is a 200 but the request is unsuccessful" do - stub_request(:post, scsb_url). - # with(body: good_request, headers: { 'Accept' => '*/*', 'Content-Type' => "application/json", 'api_key' => 'TESTME' }). - to_return(status: 200, body: bad_response, headers: {}) + stub_request(:post, scsb_url) + .to_return(status: 200, body: bad_response, headers: {}) expect { recap_request.handle }.to change { ActionMailer::Base.deliveries.count }.by(0) expect(recap_request.submitted.size).to eq(0) expect(recap_request.errors.size).to eq(1) @@ -122,9 +119,8 @@ end it "captures successful request submission" do - stub_request(:post, scsb_url). - # with(body: good_request, headers: { 'Accept' => '*/*', 'Content-Type' => "application/json", 'api_key' => 'TESTME' }). - to_return(status: 200, body: good_response, headers: {}) + stub_request(:post, scsb_url) + .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' }) @@ -136,9 +132,8 @@ end it "captures successful edd request submission" do - stub_request(:post, scsb_url). - # with(body: good_request, headers: { 'Accept' => '*/*', 'Content-Type' => "application/json", 'api_key' => 'TESTME' }). - to_return(status: 200, body: good_response, headers: {}) + stub_request(:post, scsb_url) + .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' }) @@ -150,9 +145,8 @@ end it "captures errors in the alma hold request" do - stub_request(:post, scsb_url). - # with(body: good_request, headers: { 'Accept' => '*/*', 'Content-Type' => "application/json", 'api_key' => 'TESTME' }). - to_return(status: 200, body: good_response, headers: {}) + stub_request(:post, scsb_url) + .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' }) @@ -275,9 +269,8 @@ describe 'All ReCAP Requests' do it "captures successful request submissions." do - stub_request(:post, scsb_url). - # with(body: good_request, headers: { 'Accept' => '*/*', 'Content-Type' => "application/json", 'api_key' => 'TESTME' }). - to_return(status: 200, body: good_response, headers: {}) + stub_request(:post, scsb_url) + .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' })