diff --git a/app/models/procedure.rb b/app/models/procedure.rb index 8587ece27..a8aa195cb 100644 --- a/app/models/procedure.rb +++ b/app/models/procedure.rb @@ -2,4 +2,8 @@ class Procedure < ActiveRecord::Base has_many :types_de_piece_justificative has_many :dossiers belongs_to :evenement_vie + + validates :libelle, presence: true, allow_blank: false, allow_nil: false + validates :description, presence: true, allow_blank: false, allow_nil: false + validates :lien_demarche, presence: true, allow_blank: false, allow_nil: false end diff --git a/spec/factories/procedure.rb b/spec/factories/procedure.rb index d0f18d442..7a60ee69d 100644 --- a/spec/factories/procedure.rb +++ b/spec/factories/procedure.rb @@ -1,5 +1,7 @@ FactoryGirl.define do factory :procedure do + libelle 'Demande de subvention' + description 'Description demande de subvention' lien_demarche 'http://localhost' trait :with_two_type_de_piece_justificative do diff --git a/spec/models/procedure_spec.rb b/spec/models/procedure_spec.rb index 74b6491ed..5f05ec267 100644 --- a/spec/models/procedure_spec.rb +++ b/spec/models/procedure_spec.rb @@ -13,4 +13,24 @@ describe Procedure do it { is_expected.to have_db_column(:direction) } it { is_expected.to have_db_column(:test) } end + + describe 'validation' do + context 'libelle' do + it { is_expected.not_to allow_value(nil).for(:libelle) } + it { is_expected.not_to allow_value('').for(:libelle) } + it { is_expected.to allow_value('Demande de subvention').for(:libelle) } + end + + context 'description' do + it { is_expected.not_to allow_value(nil).for(:description) } + it { is_expected.not_to allow_value('').for(:description) } + it { is_expected.to allow_value('Description Demande de subvention').for(:description) } + end + + context 'lien_demarche' do + it { is_expected.not_to allow_value(nil).for(:lien_demarche) } + it { is_expected.not_to allow_value('').for(:lien_demarche) } + it { is_expected.to allow_value('http://localhost').for(:lien_demarche) } + end + end end