Sha256: 398fc39bdf3569e22bc650c43f8ae1d1b44d90d9777f6b2f74b471c49a2a0bf8

Contents?: true

Size: 1.18 KB

Versions: 19

Compression:

Stored size: 1.18 KB

Contents

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-16.1.5 spec/record/where_spec.rb
lhs-16.1.4 spec/record/where_spec.rb
lhs-16.1.3 spec/record/where_spec.rb
lhs-16.1.2 spec/record/where_spec.rb
lhs-16.1.1 spec/record/where_spec.rb
lhs-16.1.0 spec/record/where_spec.rb
lhs-16.0.1 spec/record/where_spec.rb
lhs-16.0.0 spec/record/where_spec.rb
lhs-15.7.0 spec/record/where_spec.rb
lhs-15.6.1 spec/record/where_spec.rb
lhs-15.6.0 spec/record/where_spec.rb
lhs-15.5.1 spec/record/where_spec.rb
lhs-15.5.0 spec/record/where_spec.rb
lhs-15.4.1 spec/record/where_spec.rb
lhs-15.4.0 spec/record/where_spec.rb
lhs-15.4.0.pre.hasone.1 spec/record/where_spec.rb
lhs-15.3.3 spec/record/where_spec.rb
lhs-15.3.3.pre.fixoptions.1 spec/record/where_spec.rb
lhs-15.3.2 spec/record/where_spec.rb