Sha256: cc8c74ce8262c872f833fbbdba6c8f07e73a8e60148233b70b00309a7f9cac9e
Contents?: true
Size: 1.38 KB
Versions: 2
Compression:
Stored size: 1.38 KB
Contents
require 'spec_helper' describe UpdateDossier do let(:session) { Fabricate :oauth_session } let(:dossier) { Fabricate :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) { { '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 match(error['id'][0]) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
roqua-core-api-0.0.39 | spec/lib/roqua/core_api/update_dossier_spec.rb |
roqua-core-api-0.0.38 | spec/lib/roqua/core_api/update_dossier_spec.rb |