Skip to content

Commit

Permalink
revert 204 change
Browse files Browse the repository at this point in the history
  • Loading branch information
terrywbrady committed Dec 19, 2023
1 parent df748a4 commit feb6e45
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 6 deletions.
4 changes: 3 additions & 1 deletion app/controllers/collection_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ def local_id_search
@results = find_by_localid(collection_ark, params[:terms])
return render_object_info(@results[0].ark) if @results.length == 1
end
render status: 204, json: {}.to_json
# Not sure why 201, this probably should have returned a 204 (Empty Result).
# The Api has been returning the 201 (Accepted) for some time, so this will remain unchanged.
render status: 201, json: {}.to_json
end

private
Expand Down
4 changes: 3 additions & 1 deletion app/controllers/owner_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ def search_results
@results = find_by_file_name(@request_owner, term) if @results.empty?
@results = find_by_full_text(@request_owner, terms) if @results.empty?
end
render status: @results.empty? ? 204 : 200
# The 201 (Accepted) being returned should have probably been a 204 (Empty Result).
# The collection search API has been returning 201 for some time, so this will be unchanged.
render status: @results.empty? ? 201 : 200
end

private
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/collection_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
mock_permissions_all(user_id, collection_id)
request.session.merge!({ uid: user_id })
get(:local_id_search, params: { group: @collection.group, terms: 'my-local-id-not-found' })
expect(response.status).to eq(204)
expect(response.status).to eq(201)
end

it 'localid search - result found' do
Expand Down
4 changes: 2 additions & 2 deletions spec/controllers/owner_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,15 @@ def mock_owner_name(name)
mock_owner_name(@owner.name)
request.session.merge!({ uid: user_id })
get(:search_results, params: { terms: 'my-local-id-not-found', owner: @owner.name })
expect(response.status).to eq(204)
expect(response.status).to eq(201)
end

it 'empty terms search no results' do
mock_permissions_all(user_id, collection_id)
mock_owner_name(@owner.name)
request.session.merge!({ uid: user_id })
get(:search_results, params: { terms: '', owner: @owner.name })
expect(response.status).to eq(204)
expect(response.status).to eq(201)
end

it 'localid search - result found' do
Expand Down
2 changes: 1 addition & 1 deletion spec/features/owner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def mock_owner_name(_user, name)
it 'finds by substring, no objects found' do
fill_in('terms', with: 'Jan')
click_button 'Go'
expect(page).to have_content('here were no items that had the text matching')
expect(page).to have_content('There were no items that had the text matching')
end

it 'finds by ark' do
Expand Down

0 comments on commit feb6e45

Please sign in to comment.