Sha256: db87fed6566a74645b55a815a4cfe592a256cd30ab7ccb464ef9981cf7780511

Contents?: true

Size: 1.21 KB

Versions: 19

Compression:

Stored size: 1.21 KB

Contents

# frozen_string_literal: true

require 'rails_helper'

describe LHS::Record do
  let(:datastore) do
    'http://datastore/v2'
  end

  before do
    LHC.config.placeholder('datastore', datastore)
    class Record < LHS::Record
      endpoint '{+datastore}/content-ads/{campaign_id}/feedbacks'
      endpoint '{+datastore}/feedbacks'
    end
  end

  context 'where' do
    it 'is querying relevant endpoint when using where' do
      stub_request(:get, "#{datastore}/feedbacks?has_review=true").to_return(status: 200, body: { items: [] }.to_json)
      Record.where(has_review: true)
      stub_request(:get, "#{datastore}/content-ads/123/feedbacks?has_review=true").to_return(status: 200, body: [].to_json)
      Record.where(campaign_id: '123', has_review: true)
      stub_request(:get, "#{datastore}/feedbacks").to_return(status: 200, body: [].to_json)
      records = Record.where
      expect(records).to be_kind_of Record
    end

    it 'is using params as query params explicitly when provided in params namespace' do
      stub_request(:get, "#{datastore}/content-ads/123/feedbacks?campaign_id=456").to_return(status: 200, body: [].to_json)
      Record.where(campaign_id: '123', params: { campaign_id: '456' })
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
lhs-19.4.1 spec/record/where_spec.rb
lhs-19.4.0 spec/record/where_spec.rb
lhs-19.3.1 spec/record/where_spec.rb
lhs-19.3.0 spec/record/where_spec.rb
lhs-19.2.0 spec/record/where_spec.rb
lhs-19.1.0 spec/record/where_spec.rb
lhs-19.0.2 spec/record/where_spec.rb
lhs-19.0.1 spec/record/where_spec.rb
lhs-19.0.0 spec/record/where_spec.rb
lhs-19.0.0.pre.endpoint.1 spec/record/where_spec.rb
lhs-18.0.3 spec/record/where_spec.rb
lhs-18.0.2 spec/record/where_spec.rb
lhs-18.0.1 spec/record/where_spec.rb
lhs-18.0.0 spec/record/where_spec.rb
lhs-17.0.1 spec/record/where_spec.rb
lhs-17.0.1.pre1 spec/record/where_spec.rb
lhs-18.0.0.pre.pre1 spec/record/where_spec.rb
lhs-17.0.0 spec/record/where_spec.rb
lhs-16.1.6 spec/record/where_spec.rb