Sha256: 6a2d8cd119ac93969c08fab25455bbc88f71214e31102866f09f9f313e6bd048

Contents?: true

Size: 1.14 KB

Versions: 19

Compression:

Stored size: 1.14 KB

Contents

require File.expand_path('spec_helper', File.dirname(__FILE__))

describe "PaginatedCollection" do
  subject { Sunspot::Search::PaginatedCollection.new [], 1, 10, 20 }

  it { subject.should be_an(Array) }

  context "behaves like a WillPaginate::Collection" do
    it { subject.total_entries.should eql(20) }
    it { subject.total_pages.should eql(2) }
    it { subject.current_page.should eql(1) }
    it { subject.per_page.should eql(10) }
    it { subject.previous_page.should be_nil }
    it { subject.next_page.should eql(2) }
    it { subject.out_of_bounds?.should_not be_true }
    it { subject.offset.should eql(0) }

    it 'should allow setting total_count' do
      subject.total_count = 1
      subject.total_count.should eql(1)
    end

    it 'should allow setting total_entries' do
      subject.total_entries = 1
      subject.total_entries.should eql(1)
    end
  end

  context "behaves like Kaminari" do
    it { subject.total_count.should eql(20) }
    it { subject.num_pages.should eql(2) }
    it { subject.limit_value.should eql(10) }
    it { subject.first_page?.should be_true }
    it { subject.last_page?.should_not be_true }
  end
end

Version data entries

19 entries across 19 versions & 6 rubygems

Version Path
gojee-sunspot-2.0.5 spec/api/search/paginated_collection_spec.rb
sunspot-2.0.0.pre.120925 spec/api/search/paginated_collection_spec.rb
sunspot_solr-2.0.0.pre.120924 sunspot/spec/api/search/paginated_collection_spec.rb
sunspot_rails-2.0.0.pre.120924 sunspot/spec/api/search/paginated_collection_spec.rb
sunspot-2.0.0.pre.120924 sunspot/spec/api/search/paginated_collection_spec.rb
gojee-sunspot-2.0.4 spec/api/search/paginated_collection_spec.rb
gojee-sunspot-2.0.2 spec/api/search/paginated_collection_spec.rb
sunspot-2.0.0.pre.120720 spec/api/search/paginated_collection_spec.rb
sunspot-2.0.0.pre.120417 spec/api/search/paginated_collection_spec.rb
sunspot-2.0.0.pre.120415 spec/api/search/paginated_collection_spec.rb
erichummel-sunspot-2.0.0.pre.111215d spec/api/search/paginated_collection_spec.rb
erichummel-sunspot-2.0.0.pre.111215c spec/api/search/paginated_collection_spec.rb
erichummel-sunspot-2.0.0.pre.111215b spec/api/search/paginated_collection_spec.rb
erichummel-sunspot-2.0.0.pre.111215a spec/api/search/paginated_collection_spec.rb
erichummel-sunspot-2.0.0.pre.111215 spec/api/search/paginated_collection_spec.rb
sunspot-2.0.0.pre.111215 spec/api/search/paginated_collection_spec.rb
cb_sunspot-2.0.0.pre.5 spec/api/search/paginated_collection_spec.rb
cb_sunspot-2.0.0.pre.3 spec/api/search/paginated_collection_spec.rb
cb_sunspot-2.0.0.pre3 spec/api/search/paginated_collection_spec.rb