Sha256: 01b8c0e023b87a1a9af408da0070b8a2b857ffd077a5f5cab4388dca6b30cb85

Contents?: true

Size: 1.04 KB

Versions: 64

Compression:

Stored size: 1.04 KB

Contents

require 'rails_helper'

describe LHS::Record do
  context '#persisted?' do
    let(:datastore) { 'http://local.ch/v2' }

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

    context 'for new record' do
      subject { Feedback.new }

      it 'is false' do
        expect(subject.persisted?).to be(false)
      end
    end

    context 'for saved record' do
      let(:campaign_id) { 'aaa' }
      let(:parameters) { { recommended: true } }
      subject { Feedback.new(parameters.merge(campaign_id: campaign_id)) }

      before do
        stub_request(:post, "#{datastore}/content-ads/#{campaign_id}/feedbacks")
          .with(body: parameters.to_json)
          .to_return(status: 200, body: parameters.merge(href: "#{datastore}/content-ads/#{campaign_id}/feedbacks/123456789").to_json)
      end

      it 'is true' do
        subject.save
        expect(subject.persisted?).to be(true)
      end
    end
  end
end

Version data entries

64 entries across 64 versions & 1 rubygems

Version Path
lhs-6.1.0 spec/record/persisted_spec.rb
lhs-6.0.0 spec/record/persisted_spec.rb
lhs-5.7.1 spec/record/persisted_spec.rb
lhs-5.7.0 spec/record/persisted_spec.rb
lhs-5.6.6 spec/record/persisted_spec.rb
lhs-5.6.5 spec/record/persisted_spec.rb
lhs-5.6.4 spec/record/persisted_spec.rb
lhs-5.6.3 spec/record/persisted_spec.rb
lhs-5.6.2 spec/record/persisted_spec.rb
lhs-5.6.1 spec/record/persisted_spec.rb
lhs-5.6.0 spec/record/persisted_spec.rb
lhs-5.5.0 spec/record/persisted_spec.rb
lhs-5.4.2 spec/record/persisted_spec.rb
lhs-5.4.1 spec/record/persisted_spec.rb
lhs-5.4.0 spec/record/persisted_spec.rb
lhs-5.3.0 spec/record/persisted_spec.rb
lhs-5.2.0 spec/record/persisted_spec.rb
lhs-5.1.0 spec/record/persisted_spec.rb
lhs-5.0.4 spec/record/persisted_spec.rb
lhs-5.0.3 spec/record/persisted_spec.rb