Use active storage load hook to extend blob
This commit is contained in:
parent
d5f54de0a0
commit
42235e81b1
7 changed files with 58 additions and 40 deletions
|
@ -59,23 +59,32 @@ describe Gestionnaires::AvisController, type: :controller do
|
|||
avis_without_answer.reload
|
||||
end
|
||||
|
||||
it { expect(response).to redirect_to(instruction_gestionnaire_avis_path(avis_without_answer)) }
|
||||
it { expect(avis_without_answer.answer).to eq('answer') }
|
||||
it { expect(avis_without_answer.piece_justificative_file).to_not be_attached }
|
||||
it { expect(flash.notice).to eq('Votre réponse est enregistrée.') }
|
||||
it 'should be ok' do
|
||||
expect(response).to redirect_to(instruction_gestionnaire_avis_path(avis_without_answer))
|
||||
expect(avis_without_answer.answer).to eq('answer')
|
||||
expect(avis_without_answer.piece_justificative_file).to_not be_attached
|
||||
expect(flash.notice).to eq('Votre réponse est enregistrée.')
|
||||
end
|
||||
end
|
||||
|
||||
describe 'with attachment' do
|
||||
include ActiveJob::TestHelper
|
||||
let(:file) { Rack::Test::UploadedFile.new("./spec/fixtures/files/piece_justificative_0.pdf", 'application/pdf') }
|
||||
|
||||
before do
|
||||
post :update, params: { id: avis_without_answer.id, avis: { answer: 'answer', piece_justificative_file: file } }
|
||||
expect(ClamavService).to receive(:safe_file?).and_return(true)
|
||||
perform_enqueued_jobs do
|
||||
post :update, params: { id: avis_without_answer.id, avis: { answer: 'answer', piece_justificative_file: file } }
|
||||
end
|
||||
avis_without_answer.reload
|
||||
end
|
||||
|
||||
it { expect(response).to redirect_to(instruction_gestionnaire_avis_path(avis_without_answer)) }
|
||||
it { expect(avis_without_answer.answer).to eq('answer') }
|
||||
it { expect(avis_without_answer.piece_justificative_file).to be_attached }
|
||||
it { expect(flash.notice).to eq('Votre réponse est enregistrée.') }
|
||||
it 'should be ok' do
|
||||
expect(response).to redirect_to(instruction_gestionnaire_avis_path(avis_without_answer))
|
||||
expect(avis_without_answer.answer).to eq('answer')
|
||||
expect(avis_without_answer.piece_justificative_file).to be_attached
|
||||
expect(flash.notice).to eq('Votre réponse est enregistrée.')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -388,7 +388,7 @@ describe Champ do
|
|||
champ.save
|
||||
end
|
||||
|
||||
it { expect(champ.piece_justificative_file.virus_scanner.analyzed?).to be_truthy }
|
||||
it { expect(champ.piece_justificative_file.virus_scanner.started?).to be_truthy }
|
||||
end
|
||||
|
||||
context 'and there is no blob' do
|
||||
|
|
|
@ -10,7 +10,7 @@ describe ChampSerializer do
|
|||
|
||||
before do
|
||||
champ.piece_justificative_file.attach({ filename: __FILE__, io: File.open(__FILE__) })
|
||||
champ.piece_justificative_file.virus_scanner.analyze_later
|
||||
champ.piece_justificative_file.blob.send(:enqueue_virus_scan)
|
||||
end
|
||||
after { champ.piece_justificative_file.purge }
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue