Sha256: 0cfa072a760652d480293a5947e324112f3a60be8b0b2e0228a567f00b8af466

Contents?: true

Size: 1.15 KB

Versions: 53

Compression:

Stored size: 1.15 KB

Contents

# frozen_string_literal: true

require 'rails_helper'

describe LHS::Proxy do
  before do
    class Search < LHS::Record
      endpoint 'http://search/results', items_key: :docs
    end

    class Feedback < LHS::Record
      endpoint 'http://datastore/places/{place_id}/feedbacks'
    end
  end

  context 'identifying records' do
    it 'identifies records correctly even if parent record has another configuration set' do
      stub_request(:get, "http://search/results?what=Blumen")
        .to_return(body: {
          place: { href: 'http://datastore/places/1' }
        }.to_json)
      stub_request(:get, "http://datastore/places/1")
        .to_return(body: {
          feedbacks: { href: 'http://datastore/places/1/feedbacks?limit=10&offset=0' }
        }.to_json)
      stub_request(:get, "http://datastore/places/1/feedbacks?limit=10&offset=0")
        .to_return(body: {
          items: [{ review: 'Nice restaurant' }]
        }.to_json)
      result = Search.where(what: 'Blumen').includes(place: :feedbacks)
      expect(result.place.feedbacks).to be_kind_of Feedback
      expect(result.place.feedbacks.first.review).to eq 'Nice restaurant'
    end
  end
end

Version data entries

53 entries across 53 versions & 1 rubygems

Version Path
lhs-21.3.1 spec/proxy/record_identification_spec.rb
lhs-21.3.0 spec/proxy/record_identification_spec.rb
lhs-21.3.0.pre.autoauth.1 spec/proxy/record_identification_spec.rb
lhs-21.2.4 spec/proxy/record_identification_spec.rb
lhs-21.2.3 spec/proxy/record_identification_spec.rb
lhs-21.2.3.pre.preload.pre.providers.pre.too.1 spec/proxy/record_identification_spec.rb
lhs-21.2.2 spec/proxy/record_identification_spec.rb
lhs-21.2.1 spec/proxy/record_identification_spec.rb
lhs-21.2.0 spec/proxy/record_identification_spec.rb
lhs-21.1.4 spec/proxy/record_identification_spec.rb
lhs-21.1.3 spec/proxy/record_identification_spec.rb
lhs-21.1.2 spec/proxy/record_identification_spec.rb
lhs-21.1.2.pre.keyfix.2 spec/proxy/record_identification_spec.rb
lhs-21.1.2.pre.keyfix.1 spec/proxy/record_identification_spec.rb
lhs-21.1.2.pre.fix.pre.cant.pre.add.pre.new.pre.key.pre.during.pre.iteration.1 spec/proxy/record_identification_spec.rb
lhs-21.1.1.pre.pre.fix.pre.cant.pre.add.pre.new.pre.key.pre.during.pre.iteration.1 spec/proxy/record_identification_spec.rb
lhs-21.1.0 spec/proxy/record_identification_spec.rb
lhs-21.0.0 spec/proxy/record_identification_spec.rb
lhs-20.1.4 spec/proxy/record_identification_spec.rb
lhs-20.1.3.pre.paginationfix.3 spec/proxy/record_identification_spec.rb