diff --git a/app/views/administrateurs/types_de_champ/_insert.turbo_stream.haml b/app/views/administrateurs/types_de_champ/_insert.turbo_stream.haml index 9001c602b..8e9643849 100644 --- a/app/views/administrateurs/types_de_champ/_insert.turbo_stream.haml +++ b/app/views/administrateurs/types_de_champ/_insert.turbo_stream.haml @@ -13,7 +13,8 @@ = turbo_stream.morph dom_id(champ_component.coordinate, :type_de_champ_editor) do = render champ_component -= turbo_stream.morph dom_id(@coordinate.revision, :estimated_fill_duration) do - = render TypesDeChampEditor::EstimatedFillDurationComponent.new(revision: @coordinate.revision, is_annotation: @coordinate.private?) +- 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?) = turbo_stream.dispatch 'sortable:sort' diff --git a/spec/controllers/administrateurs/types_de_champ_controller_spec.rb b/spec/controllers/administrateurs/types_de_champ_controller_spec.rb index cf801428f..c5bb5f5de 100644 --- a/spec/controllers/administrateurs/types_de_champ_controller_spec.rb +++ b/spec/controllers/administrateurs/types_de_champ_controller_spec.rb @@ -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