refactor(virus_scan): remove lock
This commit is contained in:
parent
6e18090fb3
commit
c4a30084fe
5 changed files with 3 additions and 25 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -2,6 +2,7 @@ module BlobVirusScannerConcern
|
|||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
self.ignored_columns = [:lock_version]
|
||||
before_create :set_pending
|
||||
end
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue