diff --git a/app/controllers/champs/dossier_link_controller.rb b/app/controllers/champs/dossier_link_controller.rb index d4297c733..1ba3823e1 100644 --- a/app/controllers/champs/dossier_link_controller.rb +++ b/app/controllers/champs/dossier_link_controller.rb @@ -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 diff --git a/app/views/champs/dossier_link/show.js.erb b/app/views/champs/dossier_link/show.js.erb index d561ee26a..dece3758a 100644 --- a/app/views/champs/dossier_link/show.js.erb +++ b/app/views/champs/dossier_link/show.js.erb @@ -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 }) %> diff --git a/app/views/shared/dossiers/editable_champs/_dossier_link.html.haml b/app/views/shared/dossiers/editable_champs/_dossier_link.html.haml index 40d830ad8..37e67954c 100644 --- a/app/views/shared/dossiers/editable_champs/_dossier_link.html.haml +++ b/app/views/shared/dossiers/editable_champs/_dossier_link.html.haml @@ -1,4 +1,4 @@ -.dossier-link +.dossier-link{ class: "dossier-link-#{form.index}" } = form.number_field :value, placeholder: "Numéro de dossier", autocomplete: 'off', diff --git a/spec/controllers/champs/dossier_link_controller_spec.rb b/spec/controllers/champs/dossier_link_controller_spec.rb index f2f5be448..f4cda12de 100644 --- a/spec/controllers/champs/dossier_link_controller_spec.rb +++ b/spec/controllers/champs/dossier_link_controller_spec.rb @@ -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