[openstreetmap/openstreetmap-website] Move tracepoint ordering logic into tracepoint model, and add tests (#2068)

Andy Allan notifications at github.com
Tue Nov 20 12:16:18 UTC 2018

> Meanwhile maybe @gravitystorm will let us know what he had in mind.

It was just a general point. Moving complex logic to models makes it easier to test, among other things. For example, it's easier to check that the code selects the correct objects from the database in a model test, rather than having to parse the XML output of a controller to check if the correct objects were retrieved (and e.g. not extra objects).

Tom's suggestion of using scopes to abstract away the complexity from the controller is the kind of thing that I had in mind. The scopes are a good way to ensure that we don't end up making complex queries in multiple places, as well as being a natural home for custom Tracepoint finder methods that go being straightforward `find ... order ... limit` that you normally get in controllers.

Anyway, it was more of a "if you're working on this then moving the code would help" rather than any major problem.

You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20181120/0f5f9e4c/attachment.html>

More information about the rails-dev mailing list