Sha256: bd1f0d979e7933a5b9cb29ec08c854bbd30739439bbaf5183f65d32c0e8b5610
Contents?: true
Size: 1.42 KB
Versions: 9
Compression:
Stored size: 1.42 KB
Contents
require 'spec_helper' describe UpdateDossier do let(:session) { Fabricate :roqua_core_api_oauth_session } let(:dossier) { Fabricate :roqua_core_api_dossier } let(:response) { double } before do allow(response).to receive(:code) { 200 } expect(session).to receive(:patch).with("/dossiers/#{dossier.id}", dossier: dossier.serializable_hash) .and_return(response) end describe 'performs a patch on the /dossiers api path' do before do @result = UpdateDossier.run!(session: session, dossier: dossier) end it 'returns true when the call was correct' do expect(@result).to be_truthy end it 'should not have any errors' do expect(dossier.errors).to be_empty end end describe 'returns false when the call was incorrect' do let(:error) { {'dossier' => { 'id' => ['empty']}} } before do allow(response).to receive(:[]).with('errors').and_return(error) expect(response).to receive(:code).and_return(422) @result = UpdateDossier.run!(session: session, dossier: dossier) end it 'should return false' do expect(@result).to be_falsey end it 'should add the errors to the dossier' do expect(dossier.errors).to_not be_empty expect(dossier.errors[:id][0]).to eq 'moet opgegeven zijn' end end end
Version data entries
9 entries across 9 versions & 1 rubygems