diff --git a/app/controllers/champs/piece_justificative_controller.rb b/app/controllers/champs/piece_justificative_controller.rb index 92e776370..b75ed8f88 100644 --- a/app/controllers/champs/piece_justificative_controller.rb +++ b/app/controllers/champs/piece_justificative_controller.rb @@ -10,7 +10,7 @@ class Champs::PieceJustificativeController < ApplicationController end def update - if attach_piece_justificative_or_retry + if attach_piece_justificative render :show else render json: { errors: @champ.errors.full_messages }, status: 422 @@ -46,10 +46,4 @@ class Champs::PieceJustificativeController < ApplicationController save_succeed end - - def attach_piece_justificative_or_retry - attach_piece_justificative - rescue ActiveRecord::StaleObjectError - attach_piece_justificative - end end diff --git a/app/lib/active_job/retry_on_transient_errors.rb b/app/lib/active_job/retry_on_transient_errors.rb index 38a704a52..cf714174a 100644 --- a/app/lib/active_job/retry_on_transient_errors.rb +++ b/app/lib/active_job/retry_on_transient_errors.rb @@ -5,8 +5,7 @@ module ActiveJob::RetryOnTransientErrors Excon::Error::InternalServerError, Excon::Error::GatewayTimeout, Excon::Error::BadRequest, - Excon::Error::Socket, - ActiveRecord::StaleObjectError + Excon::Error::Socket ] included do diff --git a/app/models/concerns/blob_virus_scanner_concern.rb b/app/models/concerns/blob_virus_scanner_concern.rb index b77a55d3b..7c9a0d2c1 100644 --- a/app/models/concerns/blob_virus_scanner_concern.rb +++ b/app/models/concerns/blob_virus_scanner_concern.rb @@ -2,6 +2,7 @@ module BlobVirusScannerConcern extend ActiveSupport::Concern included do + self.ignored_columns = [:lock_version] before_create :set_pending end diff --git a/app/services/commentaire_service.rb b/app/services/commentaire_service.rb index e51e55692..5fb2e9821 100644 --- a/app/services/commentaire_service.rb +++ b/app/services/commentaire_service.rb @@ -36,14 +36,10 @@ class CommentaireService def self.save(dossier, params) build_and_save(dossier, params) - rescue ActiveRecord::StaleObjectError - build_and_save(dossier, params) end def self.save!(dossier, params) build_and_save(dossier, params, raise_exception: true) - rescue ActiveRecord::StaleObjectError - build_and_save(dossier, params, raise_exception: true) end def self.build_and_save(dossier, params, raise_exception: false) diff --git a/spec/jobs/virus_scanner_job_spec.rb b/spec/jobs/virus_scanner_job_spec.rb index 9de830373..4384acd1d 100644 --- a/spec/jobs/virus_scanner_job_spec.rb +++ b/spec/jobs/virus_scanner_job_spec.rb @@ -15,18 +15,6 @@ describe VirusScannerJob, type: :job do end it { expect(blob.virus_scanner.safe?).to be_truthy } it { expect(blob.analyzed?).to be_truthy } - it { expect(blob.lock_version).to eq(2) } - end - - context "should raise ActiveRecord::StaleObjectError" do - let(:blob_2) { ActiveStorage::Blob.find(blob.id) } - before do - blob_2.virus_scan_result = ActiveStorage::VirusScanner::INFECTED - blob.virus_scan_result = ActiveStorage::VirusScanner::SAFE - blob.save - end - - it { expect { blob_2.save }.to raise_error(ActiveRecord::StaleObjectError) } end context "when there is an integrity error" do