Merge pull request #877 from sgmap/fix_attestation

Fix attestation
This commit is contained in:
LeSim 2017-10-19 15:06:25 +02:00 committed by GitHub
commit 475675f75d
4 changed files with 21 additions and 5 deletions

View file

@ -17,4 +17,14 @@ class AttestationUploader < BaseUploader
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}" "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end end
end end
def filename
"attestation-#{secure_token}.pdf"
end
private
def secure_token
model.content_secure_token ||= SecureRandom.uuid
end
end end

View file

@ -0,0 +1,5 @@
class AddContentSecureTokenColumnToAttestation < ActiveRecord::Migration[5.0]
def change
add_column :attestations, :content_secure_token, :string
end
end

View file

@ -10,7 +10,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20170927092716) do ActiveRecord::Schema.define(version: 20171019085515) do
# These are extensions that must be enabled in order to support this database # These are extensions that must be enabled in order to support this database
enable_extension "plpgsql" enable_extension "plpgsql"
@ -90,6 +90,7 @@ ActiveRecord::Schema.define(version: 20170927092716) do
t.integer "dossier_id", null: false t.integer "dossier_id", null: false
t.datetime "created_at", null: false t.datetime "created_at", null: false
t.datetime "updated_at", null: false t.datetime "updated_at", null: false
t.string "content_secure_token"
t.index ["dossier_id"], name: "index_attestations_on_dossier_id", using: :btree t.index ["dossier_id"], name: "index_attestations_on_dossier_id", using: :btree
end end

View file

@ -142,7 +142,7 @@ describe AttestationTemplate, type: :model do
it 'provides a pseudo file' do it 'provides a pseudo file' do
expect(attestation.pdf.file).to exist expect(attestation.pdf.file).to exist
expect(attestation.pdf.filename).to eq('attestation') expect(attestation.pdf.filename).to start_with('attestation')
end end
context 'when the dossier and the procedure has an individual' do context 'when the dossier and the procedure has an individual' do