Sha256: 4553e541ac9660ed7a8a98e70bbae44a75855fd13fdc7e26607295a39449e6f9
Contents?: true
Size: 1.2 KB
Versions: 7
Compression:
Stored size: 1.2 KB
Contents
require 'spec_helper' describe Balanced::Pager do describe '#adjust_pagination_params' do subject { Balanced::Pager.new 'a uri' } it 'sets limit based on per' do params = subject.send(:adjust_pagination_params, :per => 5) params[:limit].should == 5 end it 'sets offset based on page and default limit' do params = subject.send(:adjust_pagination_params, :page => 2) params[:offset].should == 10 end it 'sets offset based on page and per' do params = subject.send(:adjust_pagination_params, :page => 2, :per => 4) params[:offset].should == 4 end it 'prefers per to limit' do params = subject.send(:adjust_pagination_params, :per => 5, :limit => 10) params[:limit].should == 5 end it 'falls back to limit' do params = subject.send(:adjust_pagination_params, :limit => 3) params[:limit].should == 3 end it 'prefers page to offset' do params = subject.send(:adjust_pagination_params, :page => 2, :offset => 0) params[:offset].should == 10 end it 'falls back to offset' do params = subject.send(:adjust_pagination_params, :offset => 6) params[:offset].should == 6 end end end
Version data entries
7 entries across 7 versions & 1 rubygems