Skip to content

Commit 2c13948

Browse files
committed
Handle case where alma user lookup returns a 400
1 parent 339ba48 commit 2c13948

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

app/models/alma/user.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ def find_if_active(id)
4444
end
4545
rescue Error::AlmaRecordNotFoundError => e
4646
return if e.message.include?('Alma query failed with response: 404')
47+
return if e.message.include?('Alma query failed with response: 400')
4748

4849
raise
4950
end

spec/forms_helper.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,18 @@ def show_path(id)
7373
end
7474
end
7575

76+
it 'forbids users when active patron lookup returns Alma 400' do
77+
patron_id = Alma::Type.sample_id_for(allowed_patron_types.first)
78+
allow(AlmaServices::Patron).to receive(:get_user).with(patron_id)
79+
.and_raise(Error::AlmaRecordNotFoundError,
80+
'Alma query failed with response: 400')
81+
82+
with_patron_login(patron_id) do
83+
get new_form_path
84+
expect(response).to have_http_status(:forbidden)
85+
end
86+
end
87+
7688
describe 'with a valid user' do
7789
attr_reader :patron_id
7890
attr_reader :patron

0 commit comments

Comments
 (0)