From 731e1b67878aa962b2bc37012017d3c6841b760e Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Thu, 23 Nov 2017 11:37:41 +0100 Subject: [PATCH 1/2] [Fix #164] Make the organisme field mandatory --- app/models/procedure.rb | 1 + app/views/admin/procedures/_informations.html.haml | 2 +- config/locales/models/procedure/fr.yml | 5 +++++ spec/features/admin/procedure_cloning_spec.rb | 1 + spec/features/admin/procedure_creation_spec.rb | 2 ++ spec/models/procedure_spec.rb | 6 ++++++ 6 files changed, 16 insertions(+), 1 deletion(-) diff --git a/app/models/procedure.rb b/app/models/procedure.rb index 1667bb00e..62502233e 100644 --- a/app/models/procedure.rb +++ b/app/models/procedure.rb @@ -40,6 +40,7 @@ class Procedure < ActiveRecord::Base validates :libelle, presence: true, allow_blank: false, allow_nil: false validates :description, presence: true, allow_blank: false, allow_nil: false + validates :organisation, presence: true, allow_blank: false, allow_nil: false def hide! now = DateTime.now diff --git a/app/views/admin/procedures/_informations.html.haml b/app/views/admin/procedures/_informations.html.haml index 706f90135..ab7e8e494 100644 --- a/app/views/admin/procedures/_informations.html.haml +++ b/app/views/admin/procedures/_informations.html.haml @@ -2,7 +2,7 @@ .alert.alert-info Cette procédure est publiée, certains éléments de la description ne sont plus modifiables -- { libelle: 'Libellé*', description: 'Description*', organisation: 'Organisme', direction: 'Direction', lien_site_web: 'Lien site internet', lien_notice: 'Lien notice' }.each do |key, value| +- { libelle: 'Libellé*', description: 'Description*', organisation: 'Organisme*', direction: 'Direction', lien_site_web: 'Lien site internet', lien_notice: 'Lien notice' }.each do |key, value| .form-group %h4 = value diff --git a/config/locales/models/procedure/fr.yml b/config/locales/models/procedure/fr.yml index 399f8da40..6ff2c0368 100644 --- a/config/locales/models/procedure/fr.yml +++ b/config/locales/models/procedure/fr.yml @@ -1,5 +1,8 @@ fr: activerecord: + attributes: + procedure: + organisation: Organisme errors: models: procedure: @@ -10,3 +13,5 @@ fr: blank: Attribut manquant lien_demarche: blank: Attribut manquant + organisation: + blank: Attribut manquant diff --git a/spec/features/admin/procedure_cloning_spec.rb b/spec/features/admin/procedure_cloning_spec.rb index 15530b161..fc66029dc 100644 --- a/spec/features/admin/procedure_cloning_spec.rb +++ b/spec/features/admin/procedure_cloning_spec.rb @@ -13,6 +13,7 @@ feature 'As an administrateur I wanna clone a procedure', js: true do page.find_by_id('new-procedure').click fill_in 'procedure_libelle', with: 'libelle de la procedure' page.execute_script("$('#procedure_description').data('wysihtml5').editor.setValue('description de la procedure')") + fill_in 'procedure_organisation', with: 'organisme de la procedure' page.find_by_id('save-procedure').click end diff --git a/spec/features/admin/procedure_creation_spec.rb b/spec/features/admin/procedure_creation_spec.rb index 987030e7c..c5edfce80 100644 --- a/spec/features/admin/procedure_creation_spec.rb +++ b/spec/features/admin/procedure_creation_spec.rb @@ -37,6 +37,7 @@ feature 'As an administrateur I wanna create a new procedure', js: true do page.find_by_id('flash_message').visible? fill_in 'procedure_libelle', with: 'libelle de la procedure' page.execute_script("$('#procedure_description').data('wysihtml5').editor.setValue('description de la procedure')") + fill_in 'procedure_organisation', with: 'organisme de la procedure' page.find_by_id('save-procedure').click expect(page).to have_current_path(admin_procedure_types_de_champ_path(Procedure.first.id.to_s)) end @@ -47,6 +48,7 @@ feature 'As an administrateur I wanna create a new procedure', js: true do page.find_by_id('new-procedure').click fill_in 'procedure_libelle', with: 'libelle de la procedure' page.execute_script("$('#procedure_description').data('wysihtml5').editor.setValue('description de la procedure')") + fill_in 'procedure_organisation', with: 'organisme de la procedure' page.find_by_id('save-procedure').click end diff --git a/spec/models/procedure_spec.rb b/spec/models/procedure_spec.rb index 632a295c8..0a51c96cf 100644 --- a/spec/models/procedure_spec.rb +++ b/spec/models/procedure_spec.rb @@ -57,6 +57,12 @@ describe Procedure do it { is_expected.to allow_value('').for(:lien_demarche) } it { is_expected.to allow_value('http://localhost').for(:lien_demarche) } end + + context 'organisation' do + it { is_expected.not_to allow_value(nil).for(:organisation) } + it { is_expected.not_to allow_value('').for(:organisation) } + it { is_expected.to allow_value('URRSAF').for(:organisation) } + end end describe '#types_de_champ_ordered' do From dc439933d8ecba9bc6d34f97c123653e584ac4f1 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Thu, 23 Nov 2017 13:56:09 +0100 Subject: [PATCH 2/2] =?UTF-8?q?Make=20the=20procedures=E2=80=99=20table=20?= =?UTF-8?q?organisation=20column=20not=20null?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...0171123125346_make_procedures_organisation_not_null.rb | 5 +++++ db/schema.rb | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) create mode 100644 db/migrate/20171123125346_make_procedures_organisation_not_null.rb diff --git a/db/migrate/20171123125346_make_procedures_organisation_not_null.rb b/db/migrate/20171123125346_make_procedures_organisation_not_null.rb new file mode 100644 index 000000000..011abe7df --- /dev/null +++ b/db/migrate/20171123125346_make_procedures_organisation_not_null.rb @@ -0,0 +1,5 @@ +class MakeProceduresOrganisationNotNull < ActiveRecord::Migration[5.0] + def change + change_column_null :procedures, :organisation, false + end +end diff --git a/db/schema.rb b/db/schema.rb index 5a81e1b0f..5088f6f89 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20171117165748) do +ActiveRecord::Schema.define(version: 20171123125346) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -78,8 +78,8 @@ ActiveRecord::Schema.define(version: 20171117165748) do t.string "logo" t.string "signature" t.boolean "activated" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.integer "procedure_id" t.string "logo_secure_token" t.string "signature_secure_token" @@ -404,7 +404,7 @@ ActiveRecord::Schema.define(version: 20171117165748) do create_table "procedures", force: :cascade do |t| t.string "libelle" t.string "description" - t.string "organisation" + t.string "organisation", null: false t.string "direction" t.string "lien_demarche" t.datetime "created_at", null: false