Sha256: 6a9b7a7388783ee9ac131f0cb7633a67698e5a08a4968712cebfdce28728ebc8

Contents?: true

Size: 917 Bytes

Versions: 53

Compression:

Stored size: 917 Bytes

Contents

# frozen_string_literal: true

require 'rails_helper'

describe LHS::Record do
  let(:handler) { spy('handler') }

  before do
    class Record < LHS::Record
      endpoint 'http://local.ch/v2/records/{id}'
    end
    class NestedRecord < LHS::Record
      endpoint 'http://local.ch/v2/other_records/{id}'
    end
    stub_request(:get, "http://local.ch/v2/records/1")
      .to_return(body: {
        href: 'http://local.ch/v2/records/1',
        other: {
          href: 'http://local.ch/v2/other_records/2'
        }
      }.to_json)
    stub_request(:get, "http://local.ch/v2/other_records/2")
      .to_return(status: 404)
  end

  it 'allows to pass error_handling for includes to LHC' do
    handler = ->(_) { return { deleted: true } }
    record = Record.includes(:other).references(other: { error_handler: { LHC::NotFound => handler } }).find(id: 1)

    expect(record.other.deleted).to be(true)
  end
end

Version data entries

53 entries across 53 versions & 1 rubygems

Version Path
lhs-21.3.1 spec/record/handle_includes_errors_spec.rb
lhs-21.3.0 spec/record/handle_includes_errors_spec.rb
lhs-21.3.0.pre.autoauth.1 spec/record/handle_includes_errors_spec.rb
lhs-21.2.4 spec/record/handle_includes_errors_spec.rb
lhs-21.2.3 spec/record/handle_includes_errors_spec.rb
lhs-21.2.3.pre.preload.pre.providers.pre.too.1 spec/record/handle_includes_errors_spec.rb
lhs-21.2.2 spec/record/handle_includes_errors_spec.rb
lhs-21.2.1 spec/record/handle_includes_errors_spec.rb
lhs-21.2.0 spec/record/handle_includes_errors_spec.rb
lhs-21.1.4 spec/record/handle_includes_errors_spec.rb
lhs-21.1.3 spec/record/handle_includes_errors_spec.rb
lhs-21.1.2 spec/record/handle_includes_errors_spec.rb
lhs-21.1.2.pre.keyfix.2 spec/record/handle_includes_errors_spec.rb
lhs-21.1.2.pre.keyfix.1 spec/record/handle_includes_errors_spec.rb
lhs-21.1.2.pre.fix.pre.cant.pre.add.pre.new.pre.key.pre.during.pre.iteration.1 spec/record/handle_includes_errors_spec.rb
lhs-21.1.1.pre.pre.fix.pre.cant.pre.add.pre.new.pre.key.pre.during.pre.iteration.1 spec/record/handle_includes_errors_spec.rb
lhs-21.1.0 spec/record/handle_includes_errors_spec.rb
lhs-21.0.0 spec/record/handle_includes_errors_spec.rb
lhs-20.1.4 spec/record/handle_includes_errors_spec.rb
lhs-20.1.3.pre.paginationfix.3 spec/record/handle_includes_errors_spec.rb