Skip to content

Commit

Permalink
Merge pull request #969 from sul-dlss/test-fixup
Browse files Browse the repository at this point in the history
Fix test descriptions and params
  • Loading branch information
marlo-longley authored Sep 29, 2023
2 parents e419f32 + 1e4b2b7 commit 1f67e12
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions spec/controllers/requests_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,14 @@
let(:mock_client) { instance_double(FolioClient, not_needed_after: api_response, ping: true) }

it 'updates the not needed after and sets the flash message' do
patch :update, params: { resource: 'abc', id: '123', not_needed_after: '1999/01/01' }
patch :update, params: { resource: '123', id: '123', not_needed_after: '1999/01/01' }

expect(flash[:success].first).to match(/Success!.*not needed after date was updated/)
end

it 'does not update the not needed after if dates are not changed' do
patch :update, params: {
resource: 'abc', id: '123', not_needed_after: '1999/01/01', current_fill_by_date: '1999/01/01'
resource: '123', id: '123', not_needed_after: '1999/01/01', current_fill_by_date: '1999/01/01'
}

expect(flash[:success]).to eq []
Expand All @@ -115,22 +115,22 @@
context 'with a group request' do
let(:mock_client) { instance_double(FolioClient, change_pickup_library: api_response, ping: true) }

it 'renews the item and redirects to checkouts_path' do
it 'renews the item and redirects to requests_path' do
patch :update, params: { resource: '123', id: '123', service_point: 'Other library', group: true }

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

context 'when the requested item is not available to the patron' do
context "when the request key does not match any of the patron's requests" do
it 'does not renew the item and sets flash messages' do
patch :update, params: { resource: 'abc', id: 'some_made_up_item_key' }
patch :update, params: { resource: 'some_other_request_key', id: 'some_other_request_key' }

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

it 'does not renew the item and redirects to checkouts_path' do
patch :update, params: { resource: 'abc', id: 'some_made_up_item_key' }
it 'does not renew the item and redirects to requests_path' do
patch :update, params: { resource: 'some_other_request_key', id: 'some_other_request_key' }

expect(response).to redirect_to requests_path
end
Expand All @@ -151,12 +151,12 @@

context 'when everything is good' do
it 'cancels the hold and sets flash messages' do
delete :destroy, params: { resource: 'abc', id: '123' }
delete :destroy, params: { resource: '123', id: '123' }
expect(flash[:success]).to match(/Success!/)
end

it 'cancels the hold and redirects to requests_path' do
delete :destroy, params: { resource: 'abc', id: '123' }
delete :destroy, params: { resource: '123', id: '123' }
expect(response).to redirect_to requests_path
end
end
Expand All @@ -165,34 +165,34 @@
let(:api_response) { instance_double('Response', status: 401, content_type: :json, body: 'foo') }

it 'does not cancel the hold and sets flash messages' do
delete :destroy, params: { resource: 'abc', id: '123' }
delete :destroy, params: { resource: '123', id: '123' }
expect(flash[:error]).to match(/Sorry!/)
end

it 'does not cancel the hold and redirects to checkouts_path' do
delete :destroy, params: { resource: 'abc', id: '123' }
it 'does not cancel the hold and redirects to requests_path' do
delete :destroy, params: { resource: '123', id: '123' }
expect(response).to redirect_to requests_path
end
end
end

context 'with a group request' do
it 'renews the item and redirects to checkouts_path' do
delete :destroy, params: { resource: 'abc', id: '123', group: true }
it 'renews the item and redirects to requests_path' do
delete :destroy, params: { resource: '123', id: '123', group: true }

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

context 'when the requested item is not avaiable to the patron' do
context "when the request key does not match any of the patron's requests" do
it 'does not renew the item and sets flash messages' do
delete :destroy, params: { resource: 'abc', id: 'some_made_up_item_key' }
delete :destroy, params: { resource: 'some_other_request_key', id: 'some_other_request_key' }

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

it 'does not renew the item and redirects to checkouts_path' do
delete :destroy, params: { resource: 'abc', id: 'some_made_up_item_key' }
it 'does not renew the item and redirects to requests_path' do
delete :destroy, params: { resource: 'some_other_request_key', id: 'some_other_request_key' }

expect(response).to redirect_to requests_path
end
Expand All @@ -217,7 +217,7 @@
warden.set_user(user)
end

it 'assigns a list of checkouts' do
it 'assigns a list of requests' do
get(:index, params: { group: true })

expect(assigns(:requests)).to eq requests
Expand Down

0 comments on commit 1f67e12

Please sign in to comment.