commit
475675f75d
4 changed files with 21 additions and 5 deletions
|
@ -17,4 +17,14 @@ class AttestationUploader < BaseUploader
|
|||
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
|
||||
end
|
||||
end
|
||||
|
||||
def filename
|
||||
"attestation-#{secure_token}.pdf"
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def secure_token
|
||||
model.content_secure_token ||= SecureRandom.uuid
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class AddContentSecureTokenColumnToAttestation < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
add_column :attestations, :content_secure_token, :string
|
||||
end
|
||||
end
|
|
@ -10,7 +10,7 @@
|
|||
#
|
||||
# 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
|
||||
enable_extension "plpgsql"
|
||||
|
@ -87,9 +87,10 @@ ActiveRecord::Schema.define(version: 20170927092716) do
|
|||
create_table "attestations", force: :cascade do |t|
|
||||
t.string "pdf"
|
||||
t.string "title"
|
||||
t.integer "dossier_id", null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.integer "dossier_id", null: false
|
||||
t.datetime "created_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
|
||||
end
|
||||
|
||||
|
|
|
@ -142,7 +142,7 @@ describe AttestationTemplate, type: :model do
|
|||
|
||||
it 'provides a pseudo file' do
|
||||
expect(attestation.pdf.file).to exist
|
||||
expect(attestation.pdf.filename).to eq('attestation')
|
||||
expect(attestation.pdf.filename).to start_with('attestation')
|
||||
end
|
||||
|
||||
context 'when the dossier and the procedure has an individual' do
|
||||
|
|
Loading…
Reference in a new issue