Merge branch 'dev'
This commit is contained in:
commit
9dc06446c8
6 changed files with 21 additions and 2 deletions
|
@ -70,7 +70,7 @@ module NewAdministrateur
|
||||||
private
|
private
|
||||||
|
|
||||||
def service_params
|
def service_params
|
||||||
params.require(:service).permit(:nom, :organisme, :type_organisme, :email, :telephone, :horaires, :adresse)
|
params.require(:service).permit(:nom, :organisme, :siret, :type_organisme, :email, :telephone, :horaires, :adresse)
|
||||||
end
|
end
|
||||||
|
|
||||||
def service
|
def service
|
||||||
|
|
|
@ -18,6 +18,7 @@ class Service < ApplicationRecord
|
||||||
validates :nom, presence: { message: 'doit être renseigné' }, allow_nil: false
|
validates :nom, presence: { message: 'doit être renseigné' }, allow_nil: false
|
||||||
validates :nom, uniqueness: { scope: :administrateur, message: 'existe déjà' }
|
validates :nom, uniqueness: { scope: :administrateur, message: 'existe déjà' }
|
||||||
validates :organisme, presence: { message: 'doit être renseigné' }, allow_nil: false
|
validates :organisme, presence: { message: 'doit être renseigné' }, allow_nil: false
|
||||||
|
validates :siret, length: { is: 14, message: 'doit être une suite de 14 chiffres' }, allow_nil: true
|
||||||
validates :type_organisme, presence: { message: 'doit être renseigné' }, allow_nil: false
|
validates :type_organisme, presence: { message: 'doit être renseigné' }, allow_nil: false
|
||||||
validates :email, presence: { message: 'doit être renseigné' }, allow_nil: false
|
validates :email, presence: { message: 'doit être renseigné' }, allow_nil: false
|
||||||
validates :telephone, presence: { message: 'doit être renseigné' }, allow_nil: false
|
validates :telephone, presence: { message: 'doit être renseigné' }, allow_nil: false
|
||||||
|
|
|
@ -10,6 +10,16 @@
|
||||||
%span.mandatory *
|
%span.mandatory *
|
||||||
= f.text_field :organisme, placeholder: "mairie de Mours, préfecture de l'Oise, ministère de la Culture", required: true
|
= f.text_field :organisme, placeholder: "mairie de Mours, préfecture de l'Oise, ministère de la Culture", required: true
|
||||||
|
|
||||||
|
= f.label :siret do
|
||||||
|
SIRET
|
||||||
|
%span.mandatory *
|
||||||
|
%p
|
||||||
|
Pour trouver votre numéro SIRET, utilisez
|
||||||
|
%a{ href: 'https://entreprise.data.gouv.fr/', target: '_blank' }
|
||||||
|
entreprise.data.gouv.fr
|
||||||
|
ou renseignez-vous auprès de votre service comptable
|
||||||
|
= f.number_field :siret, required: true
|
||||||
|
|
||||||
= f.label :type_organisme do
|
= f.label :type_organisme do
|
||||||
Type d’organisme
|
Type d’organisme
|
||||||
%span.mandatory *
|
%span.mandatory *
|
||||||
|
|
5
db/migrate/20180719125038_add_siret_to_services.rb
Normal file
5
db/migrate/20180719125038_add_siret_to_services.rb
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
class AddSiretToServices < ActiveRecord::Migration[5.2]
|
||||||
|
def change
|
||||||
|
add_column :services, :siret, :string
|
||||||
|
end
|
||||||
|
end
|
|
@ -10,7 +10,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 2018_06_27_092237) do
|
ActiveRecord::Schema.define(version: 2018_07_19_125038) do
|
||||||
|
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
|
@ -541,6 +541,7 @@ ActiveRecord::Schema.define(version: 2018_06_27_092237) do
|
||||||
t.string "telephone"
|
t.string "telephone"
|
||||||
t.text "horaires"
|
t.text "horaires"
|
||||||
t.text "adresse"
|
t.text "adresse"
|
||||||
|
t.string "siret"
|
||||||
t.index ["administrateur_id", "nom"], name: "index_services_on_administrateur_id_and_nom", unique: true
|
t.index ["administrateur_id", "nom"], name: "index_services_on_administrateur_id_and_nom", unique: true
|
||||||
t.index ["administrateur_id"], name: "index_services_on_administrateur_id"
|
t.index ["administrateur_id"], name: "index_services_on_administrateur_id"
|
||||||
end
|
end
|
||||||
|
|
|
@ -13,6 +13,7 @@ describe NewAdministrateur::ServicesController, type: :controller do
|
||||||
service: {
|
service: {
|
||||||
nom: 'super service',
|
nom: 'super service',
|
||||||
organisme: 'organisme',
|
organisme: 'organisme',
|
||||||
|
siret: '01234567891234',
|
||||||
type_organisme: 'region',
|
type_organisme: 'region',
|
||||||
email: 'email@toto.com',
|
email: 'email@toto.com',
|
||||||
telephone: '1234',
|
telephone: '1234',
|
||||||
|
@ -27,6 +28,7 @@ describe NewAdministrateur::ServicesController, type: :controller do
|
||||||
it { expect(flash.notice).to eq('super service créé') }
|
it { expect(flash.notice).to eq('super service créé') }
|
||||||
it { expect(Service.last.nom).to eq('super service') }
|
it { expect(Service.last.nom).to eq('super service') }
|
||||||
it { expect(Service.last.organisme).to eq('organisme') }
|
it { expect(Service.last.organisme).to eq('organisme') }
|
||||||
|
it { expect(Service.last.siret).to eq('01234567891234') }
|
||||||
it { expect(Service.last.type_organisme).to eq('region') }
|
it { expect(Service.last.type_organisme).to eq('region') }
|
||||||
it { expect(Service.last.email).to eq('email@toto.com') }
|
it { expect(Service.last.email).to eq('email@toto.com') }
|
||||||
it { expect(Service.last.telephone).to eq('1234') }
|
it { expect(Service.last.telephone).to eq('1234') }
|
||||||
|
|
Loading…
Reference in a new issue