From df7acdcee516d6321a40c0f1cbc55c41b039e3c7 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Tue, 6 Feb 2024 07:47:04 -0500 Subject: [PATCH] Update markers API spec for error case (#29096) --- spec/requests/api/v1/markers_spec.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/spec/requests/api/v1/markers_spec.rb b/spec/requests/api/v1/markers_spec.rb index a1ca4ba754..b04adf2594 100644 --- a/spec/requests/api/v1/markers_spec.rb +++ b/spec/requests/api/v1/markers_spec.rb @@ -52,5 +52,19 @@ RSpec.describe 'API Markers' do expect(user.markers.first.last_read_id).to eq 70_120 end end + + context 'when database object becomes stale' do + before do + allow(Marker).to receive(:transaction).and_raise(ActiveRecord::StaleObjectError) + post '/api/v1/markers', headers: headers, params: { home: { last_read_id: '69420' } } + end + + it 'returns error json' do + expect(response) + .to have_http_status(409) + expect(body_as_json) + .to include(error: /Conflict during update/) + end + end end end