-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ability for patrons to opt into wage garnishment (#488)
A new page has been added which allows a patron to accept the University Libraries' Lending Policy, which, if the user is eligible, opts them into wage garnishment. Currently, only faculty and staff are eligible to opt into this agreement. Opting in sets the patron standing to 'OK' and sets the GARNISH-DT (garnish date) to the current date.
- Loading branch information
1 parent
d5c93ee
commit 3524cb5
Showing
17 changed files
with
398 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# frozen_string_literal: true | ||
|
||
class LendingPolicyController < ApplicationController | ||
before_action :authenticate_user! | ||
|
||
def accept | ||
if patron.eligible_for_wage_garnishment? | ||
client = SymphonyClient.new | ||
client.accept_lending_policy(patron: patron, session_token: current_user.session_token) | ||
end | ||
|
||
# even if the patron is not eligible for wage garnishment (already opted in or some other reason), | ||
# just redirect them to the thank you path to avoid further user confusion | ||
redirect_to lending_policy_thank_you_path | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
const acceptLendingPolicy = () => { | ||
const acceptLendingPolicyForm = document.getElementById('accept-lending-policy-form'); | ||
|
||
if (acceptLendingPolicyForm) { | ||
const checkbox = document.getElementById('accept-lending-policy-checkbox'); | ||
const button = document.getElementById('accept-lending-policy-submit'); | ||
|
||
checkbox.addEventListener('change', (event) => { | ||
button.disabled = !event.currentTarget.checked; | ||
}); | ||
} | ||
}; | ||
|
||
export default acceptLendingPolicy; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<h1>Acceptance of University Libraries Lending Policy</h1> | ||
|
||
<p> | ||
The University Libraries has revised its Lending Policy to include the following statement: | ||
</p> | ||
|
||
<p class="mx-5"> | ||
"For lost materials, if payment is not received for replacement costs within 6 months from notification that the money is due at the Libraries, payment will be payroll deducted for current University employees. For all other fees, if payment is not received within 60 days, payment will be payroll deducted. Additional fees may be charged for this process." | ||
</p> | ||
|
||
<p> | ||
The Lending Policy can be seen in its entirety on the Pennsylvania State University Libraries Web Page at <a href="https://libraries.psu.edu/services/borrow-renew/borrowing-privileges">https://libraries.psu.edu/services/borrow-renew/borrowing-privileges</a>. The policy is subject to change without individual notice. Any change in borrower status or address should be reported to the Libraries immediately. | ||
</p> | ||
|
||
<p> | ||
By accepting these terms, the applicant agrees to the policies of the Pennsylvania State University Libraries. Please note that acceptance of this policy is necessary to maintain your borrowing privileges. | ||
</p> | ||
|
||
<hr class="my-4" /> | ||
|
||
<%= form_with url: lending_policy_accept_path, method: :post, id: 'accept-lending-policy-form', local: true do %> | ||
<div class="form-group form-check"> | ||
<input type="checkbox" class="form-check-input" id="accept-lending-policy-checkbox"> | ||
<label class="form-check-label" for="accept-lending-policy-checkbox"> | ||
I authorize the Libraries, after appropriate notice, to deduct from my paycheck any fees incurred. Additional fees may be charged for this process. Upon acceptance of this policy, my borrowing privileges will be re-instated. | ||
</label> | ||
</div> | ||
|
||
<%= submit_tag('Accept & Continue', class: 'btn btn-primary', id: 'accept-lending-policy-submit', disabled: true) %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<h1>Thank You</h1> | ||
|
||
<p>Thank you for accepting the Libraries' Fee Policy.</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
RSpec.describe LendingPolicyController do | ||
let(:mock_patron) { instance_double(Patron, eligible_for_wage_garnishment?: false) } | ||
let(:mock_client) { instance_double(SymphonyClient, ping?: true) } | ||
|
||
context 'with unauthenticated user' do | ||
it 'goes to the application root' do | ||
get(:show) | ||
expect(response).to redirect_to root_url | ||
end | ||
end | ||
|
||
context 'with an authenticated request' do | ||
let(:user) { | ||
instance_double(User, | ||
username: 'zzz123', | ||
name: 'Zeke', | ||
patron_key: '1234567', | ||
session_token: 'e0b5e1a3e86a399112b9eb893daeacfd') | ||
} | ||
|
||
before do | ||
warden.set_user(user) | ||
allow(controller).to receive(:patron).and_return(mock_patron) | ||
allow(controller).to receive(:current_user).and_return(user) | ||
allow(SymphonyClient).to receive(:new).and_return(mock_client) | ||
allow(mock_client).to receive(:accept_lending_policy) | ||
end | ||
|
||
describe 'GET #show' do | ||
it 'renders the show template' do | ||
expect(get(:show)).to render_template 'show' | ||
end | ||
end | ||
|
||
describe 'POST #accept' do | ||
context 'when the patron is not eligible for wage garnishment' do | ||
it 'renders the thank you template' do | ||
expect(post(:accept)).to redirect_to lending_policy_thank_you_path | ||
end | ||
end | ||
|
||
context 'when the patron is eligible for wage garnishment' do | ||
let(:mock_patron) { instance_double(Patron, eligible_for_wage_garnishment?: true) } | ||
|
||
it 'accepts the lending policy' do | ||
post(:accept) | ||
|
||
expect(mock_client).to have_received(:accept_lending_policy) | ||
.with(patron: mock_patron, session_token: user.session_token) | ||
end | ||
|
||
it 'renders the thank you template' do | ||
expect(post(:accept)).to redirect_to lending_policy_thank_you_path | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
RSpec.describe 'Lending Policy', type: :feature do | ||
let(:mock_user) { 'patron1' } | ||
|
||
before do | ||
login_permanently_as username: 'PATRON1', patron_key: mock_user | ||
visit lending_policy_show_path | ||
end | ||
|
||
after do | ||
Warden::Manager._on_request.clear | ||
Redis.current.flushall | ||
end | ||
|
||
describe 'when the user clicks the checkbox', js: true do | ||
it 'toggles the enabled state of the button' do | ||
expect(page).to have_button('Accept & Continue', disabled: true) | ||
|
||
page.check 'accept-lending-policy-checkbox' | ||
|
||
expect(page).to have_button('Accept & Continue', disabled: false) | ||
end | ||
end | ||
|
||
describe 'when the user submits the form', js: true do | ||
it 'redirects the user to the thank you page' do | ||
page.check 'accept-lending-policy-checkbox' | ||
page.click_button 'Accept & Continue' | ||
|
||
expect(page).to have_current_path lending_policy_thank_you_path, ignore_query: true | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.