diff --git a/app/views/admin/types_de_champ/_form.html.haml b/app/views/admin/types_de_champ/_form.html.haml index 463fb60cf..ab9d29255 100644 --- a/app/views/admin/types_de_champ/_form.html.haml +++ b/app/views/admin/types_de_champ/_form.html.haml @@ -1,5 +1,5 @@ = form_for [:admin, @procedure], url: admin_procedure_types_de_champ_path(@procedure) , remote: true do |f| - = render partial: 'fields', locals: { types_de_champ: @procedure.types_de_champ, f: f } + = render partial: 'fields', locals: { types_de_champ: @procedure.types_de_champ_ordered, f: f } #new_type_de_champ = render partial: 'fields', locals: { types_de_champ: TypeDeChamp.new, f: f } = f.submit "Ajouter un champ", class: 'btn btn-success', id: :add_type_de_champ \ No newline at end of file diff --git a/spec/views/admin/types_de_champ/show.html.haml_spec.rb b/spec/views/admin/types_de_champ/show.html.haml_spec.rb new file mode 100644 index 000000000..0e2dfea66 --- /dev/null +++ b/spec/views/admin/types_de_champ/show.html.haml_spec.rb @@ -0,0 +1,17 @@ +require 'spec_helper' + +describe 'admin/types_de_champ/show.html.haml', type: :view do + let(:procedure) { create(:procedure) } + let(:first_libelle) { 'salut la compagnie' } + let(:last_libelle) { 'je suis bien sur la page' } + let!(:type_de_champ_1) { create(:type_de_champ, procedure: procedure, order_place: 1, libelle: last_libelle) } + let!(:type_de_champ_0) { create(:type_de_champ, procedure: procedure, order_place: 0, libelle: first_libelle) } + before do + procedure.reload + assign(:procedure, procedure) + render + end + it 'sorts by order place' do + expect(rendered).to match(/#{first_libelle}.*#{last_libelle}/m) + end +end \ No newline at end of file