ets-berkeley-edu/calcentral — pull request #2213 by chikoon (2014-03-05 03:56:33+00:00)
Title: CLC-3248-backend-for-user-alerts

https://jira.media.berkeley.edu/jira/browse/CLC-3248

Added AppAlertsProxy to get the latest alert into the status feed for both authenticated and anonymous users. When there are no alerts in the calcentral-alerts/feed, the alert element will be absent.

General tasks:
- fixture: added the fake xml for the app alerts feature in public/dummy/app_alerts.xml
- config: added app_alerts_proxy settings to main config file including a feature flag, a 2 minute expiration time, a fake mode option, and an api url
- confing: turned on the app_alerts feature for development

Addition of AppAlertProxy:
- Format timestamps using DatedFeed
- Use get_latest method to get the most recent alert (cached as "user/global-alert/AppAlertsProxy" for 2 minutes)
- Use get method to get all feed messages (cache key: "user/global-alerts/AppAlertsProxy")
!! This method isn't currently may never be used. Pending definitions and use of possible "type" parameter.
- Include camelCaseless entry example in dummy/status.json:
```
"alert": {
"title": "CalCentral Scheduled Maintenance 3/17",
"teaser": "CalCentral v32 release at 6 - 7am",
"url": "http://ets-dev.berkeley.edu/calcentral-scheduled-maintenance-317",
"timestamp": {
"epoch": 1393495946,
"date_time": "2014-02-27T02:12:26-08:00",
"date_string": "2/27"
}
}
```
* At the momement, the AppAlertyProxy raises no specific exceptions. It simply rescues them and logs them as errors. Result for AppAlertProxy.get_latest are either nil present.

? Question for Darlene, Eli or Chris: I'm unsure if we can rely on the feed to keep returning mutliple items in descending order by . If we can, then we don't have to sort, so I've kept that commented until I know the answer.

Tests for AppAlertsProxy: spec/lib/proxies/app_alerts_proxy_spec.rb
Added tests for AppAlertsProxy trying to cover
- failures
- unfound fake feed
- unfound real feed
- parsing invalid xml
- parsing unexpected xml
- sucesses
- find multiple messages -> aap_instance.get
- find latest message -> aap_instance.get_latest
- cache writing

? Question: for @chris. If I'm going to continue to shut up errors this way, I need to fix my tests that are not correctly detecting the messages writtent to the log files.

Tests for UserApiController
- for including an alert (or not) in the status feed depending on availability and feature flag.