Sha256: f87e8cd01bd2b20b4fe28168b24163ceb41f7eac4b2e956e32fbf9f372e6e63f

Contents?: true

Size: 1.11 KB

Versions: 15

Compression:

Stored size: 1.11 KB

Contents

require 'rails_helper'

describe LHS::Service do

  let(:datastore) do
    'http://datastore/v2'
  end

  before(:each) do
    LHC.config.placeholder('datastore', datastore)
    class SomeService < LHS::Service
      endpoint ':datastore/v2/content-ads/:campaign_id/feedbacks'
      endpoint ':datastore/v2/feedbacks'
    end
  end

  context 'where' do

    it 'is querying relevant endpoint when using where' do
      stub_request(:get, "#{datastore}/v2/feedbacks?has_review=true").to_return(status: 200)
      SomeService.where(has_review: true)
      stub_request(:get, "#{datastore}/v2/content-ads/123/feedbacks?has_review=true").to_return(status: 200)
      SomeService.where(campaign_id: '123', has_review: true)
      stub_request(:get, "#{datastore}/v2/feedbacks").to_return(status: 200, body: '')
      SomeService.where
    end

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

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
lhs-2.2.2 spec/service/where_spec.rb
lhs-1.6.1 spec/service/where_spec.rb
lhs-2.2.1 spec/service/where_spec.rb
lhs-2.2.0 spec/service/where_spec.rb
lhs-1.6.0 spec/service/where_spec.rb
lhs-2.1.1 spec/service/where_spec.rb
lhs-2.1.0 spec/service/where_spec.rb
lhs-2.0.5 spec/service/where_spec.rb
lhs-2.0.4 spec/service/where_spec.rb
lhs-2.0.3 spec/service/where_spec.rb
lhs-2.0.2 spec/service/where_spec.rb
lhs-2.0.1 spec/service/where_spec.rb
lhs-2.0.0 spec/service/where_spec.rb
lhs-1.5.0 spec/service/where_spec.rb
lhs-1.4.0 spec/service/where_spec.rb