add justificatif_motivation field to batch operation accepter
This commit is contained in:
parent
1bc0609543
commit
59468fe351
4 changed files with 23 additions and 3 deletions
|
@ -24,6 +24,10 @@
|
||||||
|
|
||||||
.motivation.hidden{ class: 'accept' }
|
.motivation.hidden{ class: 'accept' }
|
||||||
= form.text_area :motivation, class: 'motivation-text-area'
|
= form.text_area :motivation, class: 'motivation-text-area'
|
||||||
|
.optional-justificatif{ id: "justificatif_motivation_suggest_accept", onclick: "DS.showImportJustificatif('accept');" }
|
||||||
|
.button Ajouter un justificatif (optionnel)
|
||||||
|
.hidden{ id: "justificatif_motivation_import_accept" }
|
||||||
|
= form.file_field :justificatif_motivation, direct_upload: true
|
||||||
|
|
||||||
.text-right
|
.text-right
|
||||||
%span{ onclick: 'DS.motivationCancel();', class: 'fr-btn fr-btn--secondary' } Annuler
|
%span{ onclick: 'DS.motivationCancel();', class: 'fr-btn fr-btn--secondary' } Annuler
|
||||||
|
|
|
@ -13,7 +13,7 @@ module Instructeurs
|
||||||
|
|
||||||
def batch_operation_params
|
def batch_operation_params
|
||||||
params.require(:batch_operation)
|
params.require(:batch_operation)
|
||||||
.permit(:operation, :motivation, dossier_ids: [])
|
.permit(:operation, :motivation, :justificatif_motivation, dossier_ids: [])
|
||||||
.merge(instructeur: current_instructeur)
|
.merge(instructeur: current_instructeur)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ class BatchOperation < ApplicationRecord
|
||||||
has_many :groupe_instructeurs, through: :dossier_operations
|
has_many :groupe_instructeurs, through: :dossier_operations
|
||||||
belongs_to :instructeur
|
belongs_to :instructeur
|
||||||
|
|
||||||
store_accessor :payload, :motivation
|
store_accessor :payload, :motivation, :justificatif_motivation
|
||||||
|
|
||||||
validates :operation, presence: true
|
validates :operation, presence: true
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ class BatchOperation < ApplicationRecord
|
||||||
when BatchOperation.operations.fetch(:passer_en_instruction)
|
when BatchOperation.operations.fetch(:passer_en_instruction)
|
||||||
dossier.passer_en_instruction(instructeur: instructeur)
|
dossier.passer_en_instruction(instructeur: instructeur)
|
||||||
when BatchOperation.operations.fetch(:accepter)
|
when BatchOperation.operations.fetch(:accepter)
|
||||||
dossier.accepter(instructeur: instructeur, motivation: motivation)
|
dossier.accepter(instructeur: instructeur, motivation: motivation, justificatif: justificatif_motivation)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -67,6 +67,22 @@ describe BatchOperationProcessOneJob, type: :job do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'when operation is "accepter" with justificatif' do
|
||||||
|
let(:fake_justificatif) { ActiveStorage::Blob.create_and_upload!(io: StringIO.new("ma justification"), filename: 'piece_justificative_0.pdf', content_type: 'application/pdf') }
|
||||||
|
|
||||||
|
let(:batch_operation) do
|
||||||
|
create(:batch_operation, :accepter,
|
||||||
|
options.merge(instructeur: create(:instructeur), motivation: 'motivation', justificatif_motivation: fake_justificatif.signed_id))
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'accepts the dossier in the batch with a justificatif' do
|
||||||
|
expect { subject.perform_now }
|
||||||
|
.to change { dossier_job.reload.justificatif_motivation.filename }
|
||||||
|
.from(nil)
|
||||||
|
.to(fake_justificatif.filename)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context 'when the dossier is out of sync (ie: someone applied a transition somewhere we do not know)' do
|
context 'when the dossier is out of sync (ie: someone applied a transition somewhere we do not know)' do
|
||||||
let(:instructeur) { create(:instructeur) }
|
let(:instructeur) { create(:instructeur) }
|
||||||
let(:procedure) { create(:simple_procedure, instructeurs: [instructeur]) }
|
let(:procedure) { create(:simple_procedure, instructeurs: [instructeur]) }
|
||||||
|
|
Loading…
Reference in a new issue