Commit 663a6c2c by Ivan Lan

fix excel pagination

parent 6266c3a8
......@@ -69,9 +69,9 @@ module TalltyImportExport
def initialize ary, page: ,per_page:
@raw_ary = ary
@current_page = page
@current_page = page.to_i
@total_pages = (@raw_ary.count / per_page.to_f).ceil
parsed_ary = @raw_ary[(page - 1) * per_page ... (page) * per_page]
parsed_ary = @raw_ary[(page.to_i - 1) * per_page.to_i ... (page.to_i) * per_page.to_i]
super(parsed_ary)
end
......
......@@ -8,7 +8,7 @@ RSpec.describe TalltyImportExport::Excel do
end
it 'Excel::Pagination' do
pagination = TalltyImportExport::Excel::Pagination.new([1,2,3,4,5,6], page: 2, per_page: 2)
pagination = TalltyImportExport::Excel::Pagination.new([1,2,3,4,5,6], page: '2', per_page: '2')
expect(pagination.count).to eq(6)
expect(pagination.current_page).to eq(2)
expect(pagination.total_pages).to eq(3)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment