Skip to content

Commit

Permalink
Merge pull request #1047 from sul-dlss/rm-resource
Browse files Browse the repository at this point in the history
Remove FolioRecord#resource method that was added for parity with Symphony; no longer used.
  • Loading branch information
cbeer authored Feb 12, 2024
2 parents 6373c2c + 9ca6761 commit f463be9
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 30 deletions.
6 changes: 0 additions & 6 deletions app/models/concerns/folio/folio_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,6 @@ def barcode
item['barcode']
end

def resource
# ? FOLIO: This was required for Symphony renew_item requests.
# Setting this to the instanceId for now.
bib['instanceId']
end

def item_key
bib['itemId']
end
Expand Down
1 change: 0 additions & 1 deletion app/views/checkouts/_checkout.json.jbuilder
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ json.attributes do
json.renewable checkout.renewable?
json.renewable_at checkout.renewable_at
json.renew_from_period checkout.renew_from_period
json.resource checkout.resource
json.item_key checkout.item_key
json.overdue checkout.overdue?
json.accrued checkout.accrued
Expand Down
27 changes: 12 additions & 15 deletions spec/controllers/renewals_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,19 @@
end

describe '#create' do
it 'requires resource and item_key params' do
it 'requires item_key params' do
expect { post :create, params: {} }.to raise_error(ActionController::ParameterMissing)
end

context 'when everything is good' do
it 'renews the item and sets flash messages' do
post :create, params: { resource: 'abc', item_key: '123' }
post :create, params: { item_key: '123' }

expect(flash[:success]).to match(/Success!/)
end

it 'renews the item and redirects to checkouts_path' do
post :create, params: { resource: 'abc', item_key: '123' }
post :create, params: { item_key: '123' }

expect(response).to redirect_to checkouts_path
end
Expand All @@ -45,35 +45,35 @@
let(:api_response) { instance_double('Response', status: 401, content_type: :json) }

it 'does not renew the item and sets flash messages' do
post :create, params: { resource: 'abc', item_key: '123' }
post :create, params: { item_key: '123' }

expect(flash[:error]).to match(/Sorry!/)
end

it 'does not renew the item and redirects to checkouts_path' do
post :create, params: { resource: 'abc', item_key: '123' }
post :create, params: { item_key: '123' }

expect(response).to redirect_to checkouts_path
end
end

context 'with a group request' do
it 'renews the item and redirects to checkouts_path' do
post :create, params: { resource: 'abc', item_key: '123', group: true }
post :create, params: { item_key: '123', group: true }

expect(response).to redirect_to checkouts_path(group: true)
end
end

context 'when the requested item is not checked out to the patron' do
it 'does not renew the item and sets flash messages' do
post :create, params: { resource: 'abc', item_key: 'some_made_up_item_key' }
post :create, params: { item_key: 'some_made_up_item_key' }

expect(flash[:error]).to match('An unexpected error has occurred')
end

it 'does not renew the item and redirects to checkouts_path' do
post :create, params: { resource: 'abc', item_key: 'some_made_up_item_key' }
post :create, params: { item_key: 'some_made_up_item_key' }

expect(response).to redirect_to checkouts_path
end
Expand All @@ -83,7 +83,7 @@
let(:checkouts) { [instance_double(Folio::Checkout, item_key: '123', item_category_non_renewable?: true)] }

it 'does not renew the item and sets flash messages' do
post :create, params: { resource: 'abc', item_key: '123' }
post :create, params: { item_key: '123' }

expect(flash[:error]).to match('An unexpected error has occurred')
end
Expand All @@ -98,14 +98,11 @@
let(:mock_patron) { instance_double(Folio::Patron, checkouts:) }
let(:checkouts) do
[
instance_double(Folio::Checkout, key: '1', renewable?: true, item_key: '123', title: 'ABC',
resource: 'item'),
instance_double(Folio::Checkout, key: '1', renewable?: true, item_key: '123', title: 'ABC'),
instance_double(Folio::Checkout, key: '2', renewable?: true, item_key: '456',
title: 'Principles of optics : electromagnetic theory of ' \
'propagation, interference and diffraction of light',
resource: 'item'),
instance_double(Folio::Checkout, key: '3', renewable?: false, item_key: '789', title: 'Not',
resource: 'item')
'propagation, interference and diffraction of light'),
instance_double(Folio::Checkout, key: '3', renewable?: false, item_key: '789', title: 'Not')
]
end

Expand Down
3 changes: 1 addition & 2 deletions spec/features/renew_item_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@

let(:api_response) { instance_double('Response', status: 201, content_type: :json) }
let(:bulk_renew_response) do
{ success: [instance_double(Folio::Checkout, key: '1', renewable?: true, item_key: '123', title: 'ABC',
resource: 'item')] }
{ success: [instance_double(Folio::Checkout, key: '1', renewable?: true, item_key: '123', title: 'ABC')] }
end

before do
Expand Down
4 changes: 0 additions & 4 deletions spec/models/concerns/folio/folio_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@
it { expect(model.barcode).to eq '36105110374977' }
end

describe '#resource' do
it { expect(model.resource).to eq '948b80ac-a7fa-5577-87b4-7494ee4c7482' }
end

describe '#item_key' do
it { expect(model.item_key).to eq '6d9a4f99-d144-51cf-92d7-3edbfc588abe' }
end
Expand Down
1 change: 0 additions & 1 deletion spec/views/checkouts/_checkout.html.erb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
recalled_date: nil,
renewable?: false,
renewal_date: nil,
resource: nil,
short_term_loan?: false,
sort_key: nil,
title: 'Checkout Title',
Expand Down
1 change: 0 additions & 1 deletion spec/views/requests/edit.html.erb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
Folio::Request,
title: 'Request Title',
key: 'abc123',
resource: nil,
fill_by_date: nil,
service_point_id: 'a5dbb3dc-84f8-4eb3-8bfe-c61f74a9e92d',
restricted_pickup_service_points: [],
Expand Down

0 comments on commit f463be9

Please sign in to comment.