Sha256: b4ea32a834f1f586b516fb4c317e18eb69304bcef7e4d21376b5d9cb1f46bcc7

Contents?: true

Size: 976 Bytes

Versions: 8

Compression:

Stored size: 976 Bytes

Contents

require 'spec_helper'

describe Chewy::Query::Pagination do
  before { Chewy.massacre }

  before do
    stub_index(:products) do
      define_type(:product) do
        field :name
        field :age, type: 'integer'
      end
    end
  end

  let(:search) { ProductsIndex.order(:age) }

  specify { expect(search.total_count).to eq(0) }

  context do
    let(:data) { 10.times.map { |i| {id: i.next.to_s, name: "Name#{i.next}", age: 10 * i.next}.stringify_keys! } }

    before { ProductsIndex::Product.import!(data.map { |h| double(h) }) }

    describe '#total_count' do
      specify { expect(search.total_count).to eq(10) }
      specify { expect(search.limit(5).total_count).to eq(10) }
      specify { expect(search.filter(numeric_range: {age: {gt: 20}}).limit(3).total_count).to eq(8) }
    end

    describe '#load' do
      specify { expect(search.load.total_count).to eq(10) }
      specify { expect(search.limit(5).load.total_count).to eq(10) }
    end
  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
chewy-0.8.3 spec/chewy/query/pagination_spec.rb
chewy-0.8.2 spec/chewy/query/pagination_spec.rb
chewy-0.8.1 spec/chewy/query/pagination_spec.rb
chewy-0.8.0 spec/chewy/query/pagination_spec.rb
chewy-0.7.0 spec/chewy/query/pagination_spec.rb
chewy-0.6.2 spec/chewy/query/pagination_spec.rb
chewy-0.6.1 spec/chewy/query/pagination_spec.rb
chewy-0.6.0 spec/chewy/query/pagination_spec.rb