rubyforgood / playtime

Supporting children and families experiencing homelessness in Washington, DC. Live app - https://wishlist.playtimeproject.org Organization Website:
http://www.playtimeproject.org/
MIT License
89 stars 50 forks source link

Fixes issue 60. Connection errors and non successful responses from … #177

Closed josephbhunt closed 6 years ago

josephbhunt commented 7 years ago

…Amazon are handled by redirecting the user to the search page and providing an error message.

Resolves #60

Description

Currently if searching Amazon fails to connect or returns a non-success http response code (such as 500), we do not handle it. This PR will catch network connection errors as well as error code responses and redirect the user to the search page and flash a message.

This solution allows any http response in the 200 range and 302, and 304. All 200's are considered successful, so we should accept them. 302 and 304 are less common, but they sometimes occur because of http caching (I think), so we should catch them too. Being more restrictive might cause good, useful responses to be lost and frustrate the user.

Type of change

How Has This Been Tested?

Can be tested by running rspec. New specs have been written to cover response code cases and http error cases.

Manual testing network errors:

  1. Go to the search page.
  2. Disconnect from the internet.
  3. Do a search. You will see the error message.

Manual testing http response errors:

  1. Edit the SearchResponse#error? method to always return true.
  2. Go to the search page and do a search. You will see the error message.
josephbhunt commented 6 years ago

I'll work on some of these issues, but they will need a bit of time.

josephbhunt commented 6 years ago

@invacuo I finally got around to fixing the conflicts. Please merge when you have time.