Fix procedures with multiple dossier link champs
This commit is contained in:
parent
f0610c493c
commit
c0344fc30e
4 changed files with 10 additions and 4 deletions
|
@ -2,6 +2,8 @@ class Champs::DossierLinkController < ApplicationController
|
|||
before_action :authenticate_logged_user!
|
||||
|
||||
def show
|
||||
@position = params[:position]
|
||||
|
||||
if params[:dossier].key?(:champs_attributes)
|
||||
@dossier_id = params[:dossier][:champs_attributes][params[:position]][:value]
|
||||
else
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
<%= render_to_element('.dossier-link .help-block',
|
||||
<%= render_to_element(".dossier-link-#{@position} .help-block",
|
||||
partial: 'shared/champs/dossier_link/help_block',
|
||||
locals: { id: @dossier_id }) %>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
.dossier-link
|
||||
.dossier-link{ class: "dossier-link-#{form.index}" }
|
||||
= form.number_field :value,
|
||||
placeholder: "Numéro de dossier",
|
||||
autocomplete: 'off',
|
||||
|
|
|
@ -28,10 +28,11 @@ describe Champs::DossierLinkController, type: :controller do
|
|||
get :show, params: params, format: 'js'
|
||||
}
|
||||
|
||||
it 'returns the procedure name' do
|
||||
it 'renders the procedure name' do
|
||||
expect(response.body).to include('Dossier en brouillon')
|
||||
expect(response.body).to include(procedure.libelle)
|
||||
expect(response.body).to include(procedure.organisation)
|
||||
expect(response.body).to include('.dossier-link-1 .help-block')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -41,7 +42,10 @@ describe Champs::DossierLinkController, type: :controller do
|
|||
get :show, params: params, format: 'js'
|
||||
}
|
||||
|
||||
it { expect(response.body).to include('Ce dossier est inconnu') }
|
||||
it 'renders error message' do
|
||||
expect(response.body).to include('Ce dossier est inconnu')
|
||||
expect(response.body).to include('.dossier-link-1 .help-block')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue