Skip to content

Commit

Permalink
Merge pull request #1159 from qqshfox/fix_order_for_association2
Browse files Browse the repository at this point in the history
Fix order for association2
  • Loading branch information
bbenezech committed May 24, 2012
2 parents 8fe0e3e + 8bc7264 commit 8d7d7bc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/controllers/rails_admin/main_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
15 changes: 15 additions & 0 deletions spec/controllers/main_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 8d7d7bc

Please sign in to comment.