Skip to content

Commit

Permalink
Merge pull request #1511 from NYPL/item-api-changes
Browse files Browse the repository at this point in the history
Uncommented after testing
  • Loading branch information
gonuguntla authored Feb 5, 2025
2 parents 53a8944 + f457d8b commit 5d782d3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions app/controllers/api/v01/bibs_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def create_or_update_teacher_sets
message = e.message
response = SYS_FAILURE.call(e.code, e.message, e.detailed_msg, "Bib id: #{req_body["id"]}")
rescue SuppressedBibRecordException, BibRecordNotFoundException => e
http_status = 500 #this is for testing
http_status = 404
message = e.message
response = SYS_FAILURE.call(e.code, e.message, e.detailed_msg, "Bib id: #{req_body["id"]}")
rescue DBException, ElasticsearchException => e
Expand Down Expand Up @@ -81,7 +81,7 @@ def delete_teacher_sets
message = e.message
response = SYS_FAILURE.call(e.code, message, e.detailed_msg, "Bib id: #{req_body["id"]}")
rescue BibRecordNotFoundException => e
http_status = 500 #this is for testing
http_status = 404
message = e.message
response = SYS_FAILURE.call(e.code, message, e.detailed_msg, "Bib id: #{req_body["id"]}")
rescue DBException, ElasticsearchException => e
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/api/v01/items_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def update_availability

teacher_set = TeacherSet.find_by_bnumber("b#{t_set_bnumber}")
unless teacher_set.present?
http_status = 500 #this is for testing
http_status = 404
message = "BIB id not found in MLN DB. Bib id b#{t_set_bnumber},"
http_response = SYS_FAILURE.call(http_status, message, "Item id: #{req_body["id"]}")
end
Expand Down
20 changes: 10 additions & 10 deletions test/functional/api/v01/items_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,17 @@ def setup
end
end

# test "Bib id is empty" do
# @controller.stub :parse_request_body, req_body_for_item do
# @valid_teacher_set.stub :update_available_and_total_count, true do
# post :update_availability, params: { items: @request_body }
test "Bib id is empty" do
@controller.stub :parse_request_body, req_body_for_item do
@valid_teacher_set.stub :update_available_and_total_count, true do
post :update_availability, params: { items: @request_body }

# assert_response :success
# response_body = JSON.parse(@response.body)
# assert_equal 404, response_body["items"][0]["status"]
# end
# end
# end
assert_response :success
response_body = JSON.parse(@response.body)
assert_equal 404, response_body["items"][0]["status"]
end
end
end

test "NYPL source is empty" do
@request_body = [{
Expand Down

0 comments on commit 5d782d3

Please sign in to comment.