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,7 +13,8 @@
|
||||||
= turbo_stream.morph dom_id(champ_component.coordinate, :type_de_champ_editor) do
|
= turbo_stream.morph dom_id(champ_component.coordinate, :type_de_champ_editor) do
|
||||||
= render champ_component
|
= render champ_component
|
||||||
|
|
||||||
= turbo_stream.morph dom_id(@coordinate.revision, :estimated_fill_duration) do
|
- if @coordinate.present?
|
||||||
= render TypesDeChampEditor::EstimatedFillDurationComponent.new(revision: @coordinate.revision, is_annotation: @coordinate.private?)
|
= turbo_stream.morph dom_id(@coordinate.revision, :estimated_fill_duration) do
|
||||||
|
= render TypesDeChampEditor::EstimatedFillDurationComponent.new(revision: @coordinate.revision, is_annotation: @coordinate.private?)
|
||||||
|
|
||||||
= turbo_stream.dispatch 'sortable:sort'
|
= turbo_stream.dispatch 'sortable:sort'
|
||||||
|
|
|
@ -51,28 +51,21 @@ describe Administrateurs::TypesDeChampController, type: :controller do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "validate type_de_champ linked_drop_down_list" do
|
context "validate" do
|
||||||
let(:type_champ) { TypeDeChamp.type_champs.fetch(:linked_drop_down_list) }
|
let(:type_champ) { TypeDeChamp.type_champs.fetch(:text) }
|
||||||
|
let(:params) { default_params.deep_merge(type_de_champ: { libelle: '' }) }
|
||||||
|
|
||||||
it do
|
it do
|
||||||
is_expected.to have_http_status(:ok)
|
is_expected.to have_http_status(:ok)
|
||||||
expect(flash.alert).to eq(nil)
|
expect(assigns(:coordinate)).to be_nil
|
||||||
end
|
expect(flash.alert).to eq(["Libelle doit être rempli"])
|
||||||
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)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#update' do
|
describe '#update' do
|
||||||
let(:params) do
|
let(:params) { default_params }
|
||||||
|
let(:default_params) do
|
||||||
{
|
{
|
||||||
procedure_id: procedure.id,
|
procedure_id: procedure.id,
|
||||||
stable_id: second_coordinate.stable_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(assigns(:coordinate)).to eq(second_coordinate)
|
||||||
expect(morpheds).to eq([['updated', ['l1']], ['l3', ['l1', 'updated']]])
|
expect(morpheds).to eq([['updated', ['l1']], ['l3', ['l1', 'updated']]])
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
# l1, l2, l3 => l1, l3, l2
|
# l1, l2, l3 => l1, l3, l2
|
||||||
|
|
Loading…
Reference in a new issue