Skip to content

Commit

Permalink
code review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
pcai committed Jul 12, 2023
1 parent d90183f commit b1343c2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
11 changes: 5 additions & 6 deletions lib/rails_admin/support/csv_converter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,15 @@ def generate_csv_string(options)

if @objects.respond_to?(:page)
page_num = 1
batch = @objects.page(page_num)
while batch.any?
loop do
batch = @objects.page(page_num)
break if batch.blank?

batch.each { |object| csv << generate_csv_row(object) }
page_num += 1
batch = @objects.page(page_num)
end
else
@objects.each do |object|
csv << generate_csv_row(object)
end
@objects.each { |object| csv << generate_csv_row(object) }
end
end
end
Expand Down
6 changes: 4 additions & 2 deletions spec/rails_admin/support/csv_converter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,13 @@

context 'when objects are ordered' do
before do
FactoryBot.create_list :player, 30
FactoryBot.create_list :player, 2 do |player, index|
player.name = "Player #{index}"
end
FactoryBot.create :player, name: 'Player zzz'
end

let(:objects) { Player.all.order('name desc') }
let(:objects) { Player.all.order(name: :desc) }
let(:options) { {} }

it 'preserves the ordering' do
Expand Down

0 comments on commit b1343c2

Please sign in to comment.