Merge pull request #5792 from betagouv/dev

2020-12-11-03
This commit is contained in:
LeSim 2020-12-11 16:03:09 +01:00 committed by GitHub
commit b6dd1bcf26
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 1 deletions

View file

@ -49,7 +49,7 @@ class BillSignature < ApplicationRecord
end end
def set_signature(signature, day) def set_signature(signature, day)
signature.attach( self.signature.attach(
io: StringIO.new(signature), io: StringIO.new(signature),
filename: "demarches-simplifiees-signature-#{day.to_date.iso8601}.der", filename: "demarches-simplifiees-signature-#{day.to_date.iso8601}.der",
content_type: 'application/x-x509-ca-cert' content_type: 'application/x-x509-ca-cert'

View file

@ -161,4 +161,16 @@ RSpec.describe BillSignature, type: :model do
it { expect(bill_signature.serialized.filename).to eq('demarches-simplifiees-operations-1871-03-18.json') } it { expect(bill_signature.serialized.filename).to eq('demarches-simplifiees-operations-1871-03-18.json') }
end end
end end
describe '#set_signature' do
let(:bill_signature) { BillSignature.new }
let(:signature) { 'une belle signature' }
let(:day) { Time.zone.parse('12/12/2012') }
before { bill_signature.set_signature(signature, day) }
it { expect(bill_signature.signature.attached?).to be(true) }
it { expect(bill_signature.signature.filename.to_s).to eq('demarches-simplifiees-signature-2012-12-12.der') }
it { expect(bill_signature.signature.content_type).to eq('application/x-x509-ca-cert') }
end
end end