diff --git a/app/controllers/rails_admin/main_controller.rb b/app/controllers/rails_admin/main_controller.rb index 678ba34c3c..50851fcd4b 100644 --- a/app/controllers/rails_admin/main_controller.rb +++ b/app/controllers/rails_admin/main_controller.rb @@ -123,7 +123,7 @@ def get_collection(model_config, scope, pagination) options = {} options = options.merge(:page => (params[:page] || 1).to_i, :per => (params[:per] || model_config.list.items_per_page)) if pagination options = options.merge(:include => associations) unless associations.blank? - options = options.merge(get_sort_hash(model_config)) unless params[:associated_collection] + options = options.merge(get_sort_hash(model_config)) options = options.merge(:query => params[:query]) if params[:query].present? options = options.merge(:filters => params[:f]) if params[:f].present? options = options.merge(:bulk_ids => params[:bulk_ids]) if params[:bulk_ids] diff --git a/spec/controllers/main_controller_spec.rb b/spec/controllers/main_controller_spec.rb index 62de161c92..f51625b454 100644 --- a/spec/controllers/main_controller_spec.rb +++ b/spec/controllers/main_controller_spec.rb @@ -107,7 +107,22 @@ end end controller.list_entries.length.should == @players.size + end + + it "ordering of associated collection records number less than 100 shoud be grouped by desc" do + @players = 99.times.map do + FactoryGirl.create :player + end + + controller.list_entries.to_a.first.should == @players.last + end + + it "ordering of associated collection records number over 100 shoud be grouped by desc" do + @players = 100.times.map do + FactoryGirl.create :player + end + controller.list_entries.to_a.first.should == @players.last end end