Merge pull request #7624 from tchak/fix-types-de-champ-insert
fix(types_de_champ): fix exception on validation errors
This commit is contained in:
commit
7e27dffdca
2 changed files with 20 additions and 16 deletions
|
@ -13,6 +13,7 @@
|
|||
= turbo_stream.morph dom_id(champ_component.coordinate, :type_de_champ_editor) do
|
||||
= render champ_component
|
||||
|
||||
- if @coordinate.present?
|
||||
= turbo_stream.morph dom_id(@coordinate.revision, :estimated_fill_duration) do
|
||||
= render TypesDeChampEditor::EstimatedFillDurationComponent.new(revision: @coordinate.revision, is_annotation: @coordinate.private?)
|
||||
|
||||
|
|
|
@ -51,28 +51,21 @@ describe Administrateurs::TypesDeChampController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
context "validate type_de_champ linked_drop_down_list" do
|
||||
let(:type_champ) { TypeDeChamp.type_champs.fetch(:linked_drop_down_list) }
|
||||
context "validate" do
|
||||
let(:type_champ) { TypeDeChamp.type_champs.fetch(:text) }
|
||||
let(:params) { default_params.deep_merge(type_de_champ: { libelle: '' }) }
|
||||
|
||||
it do
|
||||
is_expected.to have_http_status(:ok)
|
||||
expect(flash.alert).to eq(nil)
|
||||
end
|
||||
end
|
||||
|
||||
context "create type_de_champ linked_drop_down_list" do
|
||||
let(:type_champ) { TypeDeChamp.type_champs.fetch(:linked_drop_down_list) }
|
||||
let(:params) { default_params.deep_merge(type_de_champ: { drop_down_list_value: '--value--' }) }
|
||||
|
||||
it do
|
||||
is_expected.to have_http_status(:ok)
|
||||
expect(flash.alert).to eq(nil)
|
||||
expect(assigns(:coordinate)).to be_nil
|
||||
expect(flash.alert).to eq(["Libelle doit être rempli"])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#update' do
|
||||
let(:params) do
|
||||
let(:params) { default_params }
|
||||
let(:default_params) do
|
||||
{
|
||||
procedure_id: procedure.id,
|
||||
stable_id: second_coordinate.stable_id,
|
||||
|
@ -94,6 +87,16 @@ describe Administrateurs::TypesDeChampController, type: :controller do
|
|||
expect(assigns(:coordinate)).to eq(second_coordinate)
|
||||
expect(morpheds).to eq([['updated', ['l1']], ['l3', ['l1', 'updated']]])
|
||||
end
|
||||
|
||||
context "validate" do
|
||||
let(:params) { default_params.deep_merge(type_de_champ: { libelle: '' }) }
|
||||
|
||||
it do
|
||||
is_expected.to have_http_status(:ok)
|
||||
expect(assigns(:coordinate)).to be_nil
|
||||
expect(flash.alert).to eq(["Libelle doit être rempli"])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# l1, l2, l3 => l1, l3, l2
|
||||
|
|
Loading…
Reference in a new issue