Skip to content

Commit 9e3de46

Browse files
Ap 592 fees route (#40)
* redirecting if jwt is not see for /fees path * moved missing_params under private * removed empty space * only redirecting if jwt is missing for the index action for fees * fixed rubocop indentation error
1 parent 479c2c9 commit 9e3de46

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

app/controllers/fees_controller.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
require 'jwt'
22

33
class FeesController < ApplicationController
4+
45
# This will be needed for transaction_complete since Paypal will hit that
56
protect_from_forgery with: :null_session
67

@@ -9,6 +10,8 @@ def index
910
decoded_token = JWT.decode @jwt, nil, false
1011
@alma_id = decoded_token.first['userName']
1112
@fees = FeesPayment.new(alma_id: @alma_id)
13+
rescue ActionController::ParameterMissing
14+
redirect_to 'https://www.lib.berkeley.edu/find/borrow-renew?section=pay-fees', allow_other_host: true
1215
rescue JWT::DecodeError
1316
redirect_to(action: :transaction_error)
1417
end

spec/request/fees_request_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ def base_url_for(user_id = nil)
1212
allow(Rails.application.config).to receive(:alma_api_key).and_return(alma_api_key)
1313
end
1414

15-
it 'shows a Bad Request error if request has no jwt' do
15+
it 'redirects to the fallback URL if there is no jwt' do
1616
get fees_path
17-
expect(response).to have_http_status(:bad_request)
17+
expect(response).to redirect_to('https://www.lib.berkeley.edu/find/borrow-renew?section=pay-fees')
1818
end
1919

2020
it 'redirects to error page if request has a non-existant alma id' do

0 commit comments

Comments
 (0)