Skip to content

Commit

Permalink
WIP who knows
Browse files Browse the repository at this point in the history
  • Loading branch information
niquerio committed Sep 13, 2023
1 parent a1531a2 commit a8d3bb4
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion lib/routes/pending_requests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
end
post "/u-m-library/cancel-request" do
response = Request.cancel(uniqname: session[:uniqname], request_id: params["request_id"])
if response.code == 204
if response.status == 204
status 200
{}.to_json
else
Expand Down
4 changes: 2 additions & 2 deletions models/fines/fines.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ def self.verify_payment(uniqname:, order_number:, client: AlmaRestClient.client)
def self.for(uniqname:, client: AlmaRestClient.client)
url = "/users/#{uniqname}/fees"
response = client.get_all(url: url, record_key: "fee")
raise StandardError if response.code != 200
Fines.new(parsed_response: response.parsed_response)
raise StandardError if response.status != 200
Fines.new(parsed_response: response.body)
end
end

Expand Down
2 changes: 1 addition & 1 deletion models/fines/receipt.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def self.for(uniqname:, nelnet_params:, order_number:, is_valid: Nelnet.verify(n
ErrorReceipt.new("You do not have a balance. Your payment order number is: #{order_number}.")
else # has not already paid
resp = Fines.pay(uniqname: uniqname, amount: payment.amount, order_number: order_number)
if resp.code != 200
if resp.status != 200
error = AlmaError.new(resp)
ErrorReceipt.new("#{error.message}<br>Your payment order number is: #{order_number}")
else
Expand Down
8 changes: 4 additions & 4 deletions spec/requests/fines_and_fees_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
context "in alma user" do
it "contains 'Fines'" do
stub_alma_get_request(url: "users/tutor/fees", query: {limit: 100, offset: 0},
body: File.read("spec/fixtures/jbister_fines.json"))
output: File.read("spec/fixtures/jbister_fines.json"))
get "/fines-and-fees"
expect(last_response.body).to include("Fines")
end
Expand All @@ -50,7 +50,7 @@
end
context "post /fines-and-fees/pay" do
before(:each) do
@stub = stub_alma_get_request(url: "users/tutor/fees", body: File.read("./spec/fixtures/jbister_fines.json"), query: {limit: 100, offset: 0})
@stub = stub_alma_get_request(url: "users/tutor/fees", output: File.read("./spec/fixtures/jbister_fines.json"), query: {limit: 100, offset: 0})
end
it "for pay in full redirects to nelnet with total amountDue" do
post "/fines-and-fees/pay", {"pay_in_full" => "true", "partial_amount" => "0.00"}
Expand Down Expand Up @@ -108,10 +108,10 @@
it "for valid params, updates Alma, sets success flash, prints receipt" do
with_modified_env NELNET_SECRET_KEY: "secret" do
stub_alma_get_request(url: "users/tutor/fees", query: {limit: 100, offset: 0},
body: File.read("spec/fixtures/jbister_fines.json"))
output: File.read("spec/fixtures/jbister_fines.json"))
@session[:order_number] = "382481568"
env "rack.session", @session
stub_alma_post_request(url: "users/tutor/fees/all", query: {op: "pay", amount: "22.50", method: "ONLINE", external_transaction_id: "382481568"}, body: File.read("spec/fixtures/fines_pay_amount.json"))
stub_alma_post_request(url: "users/tutor/fees/all", query: {op: "pay", amount: "22.50", method: "ONLINE", external_transaction_id: "382481568"}, output: File.read("spec/fixtures/fines_pay_amount.json"))

get "/fines-and-fees/receipt", @params
expect(last_response.body).to include("Fines successfully paid")
Expand Down
6 changes: 3 additions & 3 deletions spec/requests/pending_requests_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
context "get /pending-requests/u-m-library" do
context "in alma" do
it "contains 'U-M Library'" do
stub_alma_get_request(url: "users/tutor/requests", body: File.read("./spec/fixtures/requests.json"), query: {limit: 100, offset: 0})
stub_alma_get_request(url: "users/tutor/requests", output: File.read("./spec/fixtures/requests.json"), query: {limit: 100, offset: 0})
stub_illiad_get_request(url: "Users/tutor", status: 404)
stub_illiad_get_request(url: "Transaction/UserRequests/tutor",
body: "[]", query: hash_excluding({just_pass: "for_real"}))
Expand Down Expand Up @@ -75,10 +75,10 @@
end
context "post /pending-requests/u-m-library/cancel-request" do
before(:each) do
@req = stub_alma_get_request(url: "users/tutor/requests", body: File.read("./spec/fixtures/requests.json"))
@req = stub_alma_get_request(url: "users/tutor/requests", output: File.read("./spec/fixtures/requests.json"))
end
it "handles good cancel request" do
stub_alma_delete_request(url: "users/tutor/requests/1234", status: 204, body: "{}", query: {reason: "CancelledAtPatronRequest"})
stub_alma_delete_request(url: "users/tutor/requests/1234", status: 204, output: "{}", query: {reason: "CancelledAtPatronRequest"})
post "/pending-requests/u-m-library/cancel-request", {"request_id" => "1234"}
expect(last_response.status).to eq(200)
end
Expand Down

0 comments on commit a8d3bb4

Please sign in to comment.