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