spec/collection_spec.rb in magic_grid-0.12.4 vs spec/collection_spec.rb in magic_grid-0.12.5
- old
+ new
@@ -125,11 +125,11 @@
end
describe "#perform_pagination" do
context "page counts" do
- let(:array) { Array.new(100) { 1 } }
+ let(:array) { Array.new(100) { 1 } }
subject { MagicGrid::Collection.new(array, nil) }
it "should correctly calculate uneven page splits" do
subject.per_page = 33
subject.total_pages.should == 4
@@ -146,27 +146,34 @@
subject { MagicGrid::Collection.new(array, nil) }
it "should round down to the last page if a later page is requested" do
subject.per_page = 3
subject.total_pages.should == 4
- subject.apply_pagination(5).perform_pagination(array)
+ subject.apply_pagination(5)
+ subject.perform_pagination(array)
subject.current_page.should == 4
end
context "providing the correct data" do
before(:each) { subject.per_page = 3 }
it "handles pages beyond lower bound" do
- subject.apply_pagination(0).perform_pagination(array).should == [1,2,3]
+ subject.apply_pagination(0)
+ subject.perform_pagination(array).should == [1,2,3]
end
it "handles pages in bounds" do
- subject.apply_pagination(1).perform_pagination(array).should == [1,2,3]
- subject.apply_pagination(2).perform_pagination(array).should == [4,5,6]
- subject.apply_pagination(3).perform_pagination(array).should == [7,8,9]
- subject.apply_pagination(4).perform_pagination(array).should == [10]
+ subject.apply_pagination(1)
+ subject.perform_pagination(array).should == [1,2,3]
+ subject.apply_pagination(2)
+ subject.perform_pagination(array).should == [4,5,6]
+ subject.apply_pagination(3)
+ subject.perform_pagination(array).should == [7,8,9]
+ subject.apply_pagination(4)
+ subject.perform_pagination(array).should == [10]
end
it "handles pages above bounds" do
- subject.apply_pagination(5).perform_pagination(array).should == [10]
+ subject.apply_pagination(5)
+ subject.perform_pagination(array).should == [10]
end
end
end
#TODO these tests will only really work properly once we have the ability
@@ -174,10 +181,11 @@
# version of RSpec (as in post 2.11.1)
context "when #paginate (aka WillPaginate) is available" do
it "should call paginate helper when it is detected" do
array = [1].tap do |a|
- a.should_receive(:paginate).with(:page => 1, :per_page => 1, :total_entries => 1) { a }
+ a.should_receive(:paginate).with(:page => 1, :per_page => 1,
+ :total_entries => 1) { a }
end
collection = MagicGrid::Collection.new(array, nil)
collection.per_page = 1
collection.apply_pagination 1
collection.perform_pagination(array).should == array