Sha256: e11b43e5bdb2a6fe0e0ffcd4fa0b1a596ec9e003fe5a51cd0600d3a23b2eb6bc
Contents?: true
Size: 893 Bytes
Versions: 10
Compression:
Stored size: 893 Bytes
Contents
require 'rails_helper' describe LHS::Record do let(:handler) { spy('handler') } before(:each) 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
10 entries across 10 versions & 1 rubygems