feat(type_de_champ_editor.explication): add a Attached::One to TypeDeChamp.explication, named notice_explicative [cf, cerfa wording]

This commit is contained in:
Martin 2023-12-19 09:51:49 +01:00
parent 7ba13507ff
commit 37e8772eab
8 changed files with 70 additions and 1 deletions

View file

@ -188,4 +188,20 @@ describe Administrateurs::TypesDeChampController, type: :controller do
end
end
end
describe '#notice_explicative' do
let(:procedure) { create(:procedure, types_de_champ_public: [{ type: :explication }]) }
let(:coordinate) { procedure.draft_revision.types_de_champ.first }
let(:file) { Tempfile.new }
let(:blob) { ActiveStorage::Blob.create_before_direct_upload!(filename: File.basename(file.path), byte_size: file.size, checksum: Digest::SHA256.file(file.path), content_type: 'text/plain') }
context 'when sending a valid blob' do
it 'attaches the blob and responds with 200' do
expect { put :notice_explicative, format: :turbo_stream, params: { stable_id: coordinate.stable_id, procedure_id: procedure.id, blob_signed_id: blob.signed_id } }
.to change { coordinate.reload.notice_explicative.attached? }
.from(false).to(true)
expect(response).to have_http_status(:success)
end
end
end
end