Skip to content

Commit

Permalink
[#4303] Remove commented code and comments that are not needed anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
christinach authored and maxkadel committed Sep 16, 2024
1 parent e8548e6 commit 1615a37
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 40 deletions.
3 changes: 0 additions & 3 deletions app/models/requests/illiad_client.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 0 additions & 2 deletions app/models/requests/patron.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 0 additions & 2 deletions app/models/requests/requestable/item.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions app/models/requests/requestable_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 3 additions & 5 deletions app/models/requests/submission.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 3 additions & 5 deletions spec/models/requests/requestable_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'] }
Expand All @@ -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'] }
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
35 changes: 14 additions & 21 deletions spec/models/requests/submissions/recap_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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' })
Expand All @@ -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' })
Expand All @@ -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' })
Expand Down Expand Up @@ -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' })
Expand Down

0 comments on commit 1615a37

Please sign in to comment.