errbit/errbit — pull request #631 by alvarobp (2013-12-26 19:16:43+00:00)
Title: Applications list is not ordered by problems count

After upgrading to an errbit version using Mongoid v3 we've observed that the applications list does not show up the applications ordered by the number of unresolved problems count. Since we have a considerable number of different applications playing together we were relying heavily on that list being ordered.

The issue comes from Mongoid v3 defining a ``sort`` method on the Criteria class masking the sort method defined in Enumerable, thus the ``<=>`` method is not used when sorting which is the one implementing the sort by unresolved problems count.

This suggested patch reverts only to sorting using the full array of App instances, which is the previous implementation.

Do you think this makes sense?

Note: The test suite was broken before applying this patch (121531cad). The test suite summary before and after applying these changes is the following:

```
523 examples, 3 failures, 3 pending

Failed examples:

rspec ./spec/controllers/api/v1/problems_controller_spec.rb:39 # Api::V1::ProblemsController when logged in GET /api/v1/problems given a date range should return only the problems open during the date range
rspec ./spec/models/problem_spec.rb:180 # Problem Scopes searching finds the correct record
rspec ./spec/models/problem_spec.rb:188 # Problem Scopes searching find on where message
```