Sha256: 9b84e907f91db9dc304f2ae69a896d13e099224c6c22ef8c39515116e3a77020

Contents?: true

Size: 1.25 KB

Versions: 47

Compression:

Stored size: 1.25 KB

Contents

require 'rails_helper'

describe LHS::Record do
  context 'includes warning' do
    before(:each) do
      class Customer < LHS::Record
        endpoint 'http://datastore/customers/:id'
      end
    end

    let!(:customer_request) do
      stub_request(:get, 'http://datastore/customers/1')
        .to_return(
          body: {
            contracts: { href: 'http://datastore/customers/1/contracts' }
          }.to_json
        )
    end

    let!(:contracts_request) do
      stub_request(:get, "http://datastore/customers/1/contracts")
        .to_return(
          body: {
            items: 10.times.map do
              {
                products: { href: 'http://datastore/products' }
              }
            end,
            limit: 10,
            offset: 0,
            total: 33
          }.to_json
        )
    end

    it 'warns if linked data was simply included but is paginated' do
      expect(lambda {
        Customer.includes(:contracts).find(1)
      }).to output(
        %r{\[WARNING\] You included `http://datastore/customers/1/contracts`, but this endpoint is paginated. You might want to use `includes_all` instead of `includes` \(https://github.com/local-ch/lhs#includes_all-for-paginated-endpoints\)\.}
      ).to_stderr
    end
  end
end

Version data entries

47 entries across 47 versions & 1 rubygems

Version Path
lhs-14.6.5 spec/record/includes_warning_spec.rb
lhs-14.6.4 spec/record/includes_warning_spec.rb
lhs-14.6.3 spec/record/includes_warning_spec.rb
lhs-14.6.2 spec/record/includes_warning_spec.rb
lhs-14.6.1 spec/record/includes_warning_spec.rb
lhs-14.6.0 spec/record/includes_warning_spec.rb
lhs-14.5.0 spec/record/includes_warning_spec.rb
lhs-14.4.0 spec/record/includes_warning_spec.rb
lhs-14.3.4 spec/record/includes_warning_spec.rb
lhs-14.3.3 spec/record/includes_warning_spec.rb
lhs-14.3.2 spec/record/includes_warning_spec.rb
lhs-14.3.1 spec/record/includes_warning_spec.rb
lhs-14.3.0 spec/record/includes_warning_spec.rb
lhs-14.2.0 spec/record/includes_warning_spec.rb
lhs-14.1.1 spec/record/includes_warning_spec.rb
lhs-14.1.0 spec/record/includes_warning_spec.rb
lhs-14.0.3 spec/record/includes_warning_spec.rb
lhs-14.0.2 spec/record/includes_warning_spec.rb
lhs-14.0.1 spec/record/includes_warning_spec.rb
lhs-14.0.0 spec/record/includes_warning_spec.rb