Preview should reflect revision changes

This commit is contained in:
Paul Chavard 2021-06-23 15:57:11 +02:00
parent 8b2c2c6466
commit 0ca5e1abe2
5 changed files with 12 additions and 14 deletions

View file

@ -44,7 +44,7 @@ module NewAdministrateur
end
def apercu
@dossier = procedure_without_control.new_dossier
@dossier = procedure_without_control.draft_revision.new_dossier
@tab = apercu_tab
end

View file

@ -81,7 +81,7 @@ module Users
end
def generate_empty_pdf(procedure)
@dossier = procedure.new_dossier
@dossier = procedure.active_revision.new_dossier
s = render_to_string(template: 'dossiers/dossier_vide', formats: [:pdf])
send_data(s, :filename => "#{procedure.libelle}.pdf")
end

View file

@ -406,17 +406,6 @@ class Procedure < ApplicationRecord
Flipper.enabled?(feature, self)
end
# Warning: dossier after_save build_default_champs must be removed
# to save a dossier created from this method
def new_dossier
Dossier.new(
revision: active_revision,
champs: active_revision.build_champs,
champs_private: active_revision.build_champs_private,
groupe_instructeur: defaut_groupe_instructeur
)
end
def path_customized?
!path.match?(/[[:xdigit:]]{8}-[[:xdigit:]]{4}-[[:xdigit:]]{4}-[[:xdigit:]]{4}-[[:xdigit:]]{12}/)
end

View file

@ -112,6 +112,15 @@ class ProcedureRevision < ApplicationRecord
changes
end
def new_dossier
Dossier.new(
revision: self,
champs: build_champs,
champs_private: build_champs_private,
groupe_instructeur: procedure.defaut_groupe_instructeur
)
end
private
def compare_types_de_champ(from_tdc, to_tdc)

View file

@ -927,7 +927,7 @@ describe Procedure do
])
end
let(:dossier) { procedure.new_dossier }
let(:dossier) { procedure.active_revision.new_dossier }
it { expect(dossier.procedure).to eq(procedure) }