nrichand/BrownBagLunch — pull request #127 by janosgyerik (2013-12-06 13:53:41+00:00)
Title: Made it possible to have a bagger in multiple cities without duplication, with unit tests

At first I tried to normalize the `data`, but that didn't really look pretty. So I chose a different solution: if a bagger is in multiple cities, you add the full details in only one of the cities (any of them), and in other locations you add just the name and a `ref_ville` attribute with the name of the city that has the full details. Take for example Camille Roux, his full details are now in Paris, and in Montpellier there's only this:
```
{
name: "Camille Roux",
ref_ville: "Paris"
}
```
To make this work, I added a new utility method `denormalize_data(data)` which find the baggers with `ref_ville` element, and copy all elements from their other entry. So on `baggers.html`, before using the `data`, I call `denormalize_data(data)` to duplicate the data of baggers when necessary.

- I added unit tests, look at `tests/baggers.html` or on [my demo page](http://janosgyerik.github.io/BrownBagLunch/tests/baggers.html)
- As an added bonus, the unit tests cover other cases too, so it's a good sanity check after editing `js/baggers.js`. I think you should add on the front page that whenever somebody edits the `js/baggers.js`, they should check the `tests/baggers.html` page to make sure there are no errors.
- I did the same for RH too, and you can find the unit tests for that in `tests/baggers-rh.html` or on [my demo page](http://janosgyerik.github.io/BrownBagLunch/tests/baggers-rh.html) The unit tests are exactly the same for both cases, only the html is different to include the different `baggers.js` files