2011-12-10 11:15:18 -05:00
|
|
|
require 'spec_helper'
|
2011-04-21 02:30:34 -04:00
|
|
|
|
|
|
|
describe Kaminari::Configuration do
|
|
|
|
subject { Kaminari.config }
|
|
|
|
describe 'default_per_page' do
|
|
|
|
context 'by default' do
|
|
|
|
its(:default_per_page) { should == 25 }
|
|
|
|
end
|
|
|
|
context 'configured via config block' do
|
|
|
|
before do
|
|
|
|
Kaminari.configure {|c| c.default_per_page = 17}
|
|
|
|
end
|
|
|
|
its(:default_per_page) { should == 17 }
|
|
|
|
after do
|
|
|
|
Kaminari.configure {|c| c.default_per_page = 25}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2011-04-21 02:49:45 -04:00
|
|
|
|
2012-08-28 01:15:19 -04:00
|
|
|
describe 'max_per_page' do
|
|
|
|
context 'by default' do
|
2012-08-28 03:54:45 -04:00
|
|
|
its(:max_per_page) { should == nil }
|
2012-08-28 01:15:19 -04:00
|
|
|
end
|
|
|
|
context 'configure via config block' do
|
|
|
|
before do
|
|
|
|
Kaminari.configure {|c| c.max_per_page = 100}
|
|
|
|
end
|
|
|
|
its(:max_per_page) { should == 100 }
|
|
|
|
after do
|
2012-08-28 03:54:45 -04:00
|
|
|
Kaminari.configure {|c| c.max_per_page = nil}
|
2012-08-28 01:15:19 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-04-21 02:49:45 -04:00
|
|
|
describe 'window' do
|
|
|
|
context 'by default' do
|
|
|
|
its(:window) { should == 4 }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'outer_window' do
|
|
|
|
context 'by default' do
|
|
|
|
its(:outer_window) { should == 0 }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'left' do
|
|
|
|
context 'by default' do
|
|
|
|
its(:left) { should == 0 }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'right' do
|
|
|
|
context 'by default' do
|
|
|
|
its(:right) { should == 0 }
|
|
|
|
end
|
|
|
|
end
|
2011-04-22 06:26:11 -04:00
|
|
|
|
|
|
|
describe 'param_name' do
|
|
|
|
context 'by default' do
|
|
|
|
its(:param_name) { should == :page }
|
|
|
|
end
|
2011-05-02 13:37:18 -04:00
|
|
|
|
2011-05-03 09:10:35 -04:00
|
|
|
context 'configured via config block' do
|
2011-05-02 13:37:18 -04:00
|
|
|
before do
|
|
|
|
Kaminari.configure {|c| c.param_name = lambda { :test } }
|
|
|
|
end
|
|
|
|
|
|
|
|
its(:param_name) { should == :test }
|
|
|
|
|
2011-05-03 11:19:51 -04:00
|
|
|
after do
|
2011-05-02 13:37:18 -04:00
|
|
|
Kaminari.configure {|c| c.param_name = :page }
|
|
|
|
end
|
|
|
|
end
|
2011-04-22 06:26:11 -04:00
|
|
|
end
|
2012-10-22 10:16:54 -04:00
|
|
|
|
|
|
|
describe 'max_pages' do
|
|
|
|
context 'by default' do
|
|
|
|
its(:max_pages) { should == nil }
|
|
|
|
end
|
|
|
|
context 'configure via config block' do
|
|
|
|
before do
|
|
|
|
Kaminari.configure {|c| c.max_pages = 5}
|
|
|
|
end
|
|
|
|
its(:max_pages) { should == 5 }
|
|
|
|
after do
|
|
|
|
Kaminari.configure {|c| c.max_pages = nil}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2011-04-21 02:30:34 -04:00
|
|
|
end
|