Sha256: 909bb1e6d26db3d9d79a725f29f1ced1bd80b3154f2534d5f67c2347f2303c9f

Contents?: true

Size: 1.12 KB

Versions: 71

Compression:

Stored size: 1.12 KB

Contents

require 'rails_helper'

describe LHS::Record do
  context 'save!' do
    context 'without href' do
      before do
        LHC.config.placeholder('datastore', datastore)
        class Feedback < LHS::Record
          endpoint ':datastore/content-ads/:campaign_id/feedbacks'
        end
      end

      let(:datastore) { 'http://local.ch/v2' }
      let(:campaign_id) { 12345 }
      let(:object) { { recommended: true } }
      let(:item) { Feedback.new(object.merge(campaign_id: campaign_id)) }
      let!(:request) do
        stub_request(:post, "#{datastore}/content-ads/#{campaign_id}/feedbacks")
          .with(body: object.to_json)
          .to_return(status: 200, body: object.to_json)
      end

      it 'removes params used to compute url from send data' do
        item.save!
        expect(request).to have_been_made.once
      end

      context 'item without data' do
        let(:item) { Feedback.new(object) }

        it 'takes params to find endpoint also from the options' do
          item.save!(params: { campaign_id: campaign_id })
          expect(request).to have_been_made.once
        end
      end
    end
  end
end

Version data entries

71 entries across 71 versions & 1 rubygems

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