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