validation à la création d'une procédure sur les attributs 'libelle', 'description' et 'lien démarche'
This commit is contained in:
parent
ca4e5130c2
commit
632c19bc48
3 changed files with 26 additions and 0 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue