moneyadviceservice/frontend — pull request #386 by jongilbraith (2014-05-21 15:34:07+00:00)
Title: Changes to related content on articles

The approach to related content is to pick 8 links as equally as possible from each of the parent categories of the article (starting at the first article in the category).

So for example:

- the article has one parent category, there would be the first 8 entries
- the article has two parent categories, there would be the 4 entries in each
- the article has two parent categories but only 2 articles in one and lots in the other, there would be the 2 from one and 6 from the others

There are a few edge cases and special conditions but you get the drift...

Because all of that is quite lengthy to check, I've moved all that into unit tests and in turn simplified the feature coverage for the related links. We now instantiate a decorator for the article and use the related categories produced by that to set expectations on the output.

For the specs I've added a few custom matchers to test decorated objects which are quite handy, but the unit tests are still quite lengthy. (Which is why I stuck them in their own file.)