models: require belong_to associations on attestation_template
This commit is contained in:
parent
1ea4c2aa36
commit
aefdd5d2a1
4 changed files with 6 additions and 4 deletions
|
@ -15,7 +15,7 @@ class AttestationTemplate < ApplicationRecord
|
||||||
include ActionView::Helpers::NumberHelper
|
include ActionView::Helpers::NumberHelper
|
||||||
include TagsSubstitutionConcern
|
include TagsSubstitutionConcern
|
||||||
|
|
||||||
belongs_to :procedure
|
belongs_to :procedure, optional: false
|
||||||
|
|
||||||
has_one_attached :logo
|
has_one_attached :logo
|
||||||
has_one_attached :signature
|
has_one_attached :signature
|
||||||
|
|
|
@ -4,6 +4,8 @@ FactoryBot.define do
|
||||||
body { 'body' }
|
body { 'body' }
|
||||||
footer { 'footer' }
|
footer { 'footer' }
|
||||||
activated { true }
|
activated { true }
|
||||||
|
|
||||||
|
association :procedure
|
||||||
end
|
end
|
||||||
|
|
||||||
trait :with_files do
|
trait :with_files do
|
||||||
|
|
|
@ -183,9 +183,9 @@ FactoryBot.define do
|
||||||
end
|
end
|
||||||
|
|
||||||
trait :with_attestation do
|
trait :with_attestation do
|
||||||
after(:create) do |dossier, _evaluator|
|
after(:build) do |dossier, _evaluator|
|
||||||
if dossier.procedure.attestation_template.blank?
|
if dossier.procedure.attestation_template.blank?
|
||||||
dossier.procedure.attestation_template = create(:attestation_template)
|
dossier.procedure.attestation_template = build(:attestation_template)
|
||||||
end
|
end
|
||||||
dossier.attestation = dossier.build_attestation
|
dossier.attestation = dossier.build_attestation
|
||||||
end
|
end
|
||||||
|
|
|
@ -563,7 +563,7 @@ describe Dossier do
|
||||||
# - with a dash in the champ libelle / tag
|
# - with a dash in the champ libelle / tag
|
||||||
let(:title) { "voici --specified champ-in-title-- un --unspecified champ-in-title-- beau --specified annotation privée-in-title-- titre --unspecified annotation privée-in-title-- non --numéro du dossier--" }
|
let(:title) { "voici --specified champ-in-title-- un --unspecified champ-in-title-- beau --specified annotation privée-in-title-- titre --unspecified annotation privée-in-title-- non --numéro du dossier--" }
|
||||||
let(:body) { "voici --specified champ-in-body-- un --unspecified champ-in-body-- beau --specified annotation privée-in-body-- body --unspecified annotation privée-in-body-- non ?" }
|
let(:body) { "voici --specified champ-in-body-- un --unspecified champ-in-body-- beau --specified annotation privée-in-body-- body --unspecified annotation privée-in-body-- non ?" }
|
||||||
let(:attestation_template) { create(:attestation_template, title: title, body: body, activated: activated) }
|
let(:attestation_template) { build(:attestation_template, title: title, body: body, activated: activated) }
|
||||||
|
|
||||||
context "which is disabled" do
|
context "which is disabled" do
|
||||||
let(:activated) { false }
|
let(:activated) { false }
|
||||||
|
|
Loading…
Reference in a new issue