codeforamerica/ohana-web-search — pull request #521 by monfresh (2014-07-27 22:18:07+00:00)
Title: Refactor error handling. Closes #248.

- Added alert-manager JS to app-init so that an alert can be dismissed
on any page.

- If geolocation fails and an alert is displayed, the “Services near
me” button text gets reverted back to its default instead of leaving it
showing “Please wait…”

- The most common exceptions (based on error logs from SMC-Connect) are
handled by application_controller and how each exception is handled can
easily be configured. By default, the user is redirected to either the
home page or the same page they were on, and an alert is displayed. The
text of the alert is customizable in `config/locales/en.yml` in the
`errors` section.

- By rescuing exceptions at the application level, we can clean up the
organizations model and controller code, and we also get rid of the
duplicate calls to the same location, which fixes #248.

- Now that the location details page is only making the 1 expected API
call, the `url_dynamic` cassette had to be fixed to only include 1
call. It was failing because the ERB was only applied to the second
call in the cassette.

- Refactored the alert HTML.

- Set `config.consider_all_requests_local` to `false` in `test.rb` to
allow testing redirects and alerts when exceptions occur.
Note, to test this in development, you will need to set this same
setting to `false` in `development.rb`. When done testing, it should be
reverted back to `true`.

- Also closes #135, closes #144.