Merge pull request #5791 from betagouv/fix_bill_signature

Répare l'horodatage
This commit is contained in:
LeSim 2020-12-11 15:59:11 +01:00 committed by GitHub
commit f0b1832845
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
def set_signature(signature, day)
signature.attach(
self.signature.attach(
io: StringIO.new(signature),
filename: "demarches-simplifiees-signature-#{day.to_date.iso8601}.der",
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') }
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