Sha256: 417b3797d598198f7ad8c85d7e55f2faba2110dee39ac3b5d47bfcb5f7e1c196
Contents?: true
Size: 1.26 KB
Versions: 12
Compression:
Stored size: 1.26 KB
Contents
# frozen_string_literal: true require 'rails_helper' describe DHS::Record do before do class Record < DHS::Record endpoint 'http://datastore/records' endpoint 'http://datastore/records/{id}' end class AnotherRecord < DHS::Record endpoint 'http://datastore/otherrecords' endpoint 'http://datastore/otherrecords/{id}' def id another_id end end end context 'reload!' do it 'reloads the record by id' do stub_request(:post, 'http://datastore/records') .to_return(body: { id: 1, name: 'Steve' }.to_json) record = Record.create!(name: 'Steve') stub_request(:get, 'http://datastore/records/1') .to_return(body: { id: 1, name: 'Steve', async: 'data' }.to_json) record.reload! expect(record.async).to eq 'data' end it 'reloads the record by id if a record method defines the actual id' do stub_request(:post, 'http://datastore/otherrecords') .to_return(body: { another_id: 2, name: 'Can' }.to_json) record = AnotherRecord.create!(name: 'Can') stub_request(:get, 'http://datastore/otherrecords/2') .to_return(body: { id: 2, name: 'Can', async: 'data' }.to_json) record.reload! expect(record.async).to eq 'data' end end end
Version data entries
12 entries across 12 versions & 1 rubygems