Commit acc16a5f1d593a3768d4930c5aa9eb054ec243dd
1 parent
a8af7b22
Exists in
master
Ensure that App#<=> is used for sorting
Prior to this change, the `#sort` method was being handled by Mongoid and sent to MongoDB, resulting in the `App#<=>` method being ignored for this purpose.
Showing
2 changed files
with
3 additions
and
3 deletions
Show diff stats
app/controllers/apps_controller.rb
... | ... | @@ -9,7 +9,7 @@ class AppsController < ApplicationController |
9 | 9 | expose(:app_scope) { App } |
10 | 10 | |
11 | 11 | expose(:apps) do |
12 | - app_scope.all.sort.map { |app| AppDecorator.new(app) } | |
12 | + app_scope.all.to_a.sort.map { |app| AppDecorator.new(app) } | |
13 | 13 | end |
14 | 14 | |
15 | 15 | expose(:app, ancestor: :app_scope, attributes: :app_params) | ... | ... |
spec/controllers/apps_controller_spec.rb
... | ... | @@ -34,7 +34,7 @@ describe AppsController, type: 'controller' do |
34 | 34 | sign_in admin |
35 | 35 | unwatched_app && watched_app1 && watched_app2 |
36 | 36 | get :index |
37 | - expect(controller.apps.entries).to eq App.all.sort.entries | |
37 | + expect(controller.apps.entries).to eq App.all.to_a.sort.entries | |
38 | 38 | end |
39 | 39 | end |
40 | 40 | |
... | ... | @@ -43,7 +43,7 @@ describe AppsController, type: 'controller' do |
43 | 43 | sign_in user |
44 | 44 | unwatched_app && watched_app1 && watched_app2 |
45 | 45 | get :index |
46 | - expect(controller.apps.entries).to eq App.all.sort.entries | |
46 | + expect(controller.apps.entries).to eq App.all.to_a.sort.entries | |
47 | 47 | end |
48 | 48 | end |
49 | 49 | end | ... | ... |