Add tests and lien_demarche in serialize

This commit is contained in:
Mathieu Magnin 2017-01-19 17:48:03 +01:00
parent f15e9ec7da
commit 1bd66b6a9e
3 changed files with 13 additions and 2 deletions

View file

@ -4,4 +4,6 @@ class TypeDePieceJustificative < ActiveRecord::Base
belongs_to :procedure
validates :libelle, presence: true, allow_blank: false, allow_nil: false
validates_format_of :lien_demarche, with: URI::regexp
end

View file

@ -2,5 +2,6 @@ class TypeDePieceJustificativeSerializer < ActiveModel::Serializer
attributes :id,
:libelle,
:description,
:order_place
:order_place,
:lien_demarche
end

View file

@ -10,6 +10,7 @@ describe TypeDePieceJustificative do
it { is_expected.to have_db_column(:created_at) }
it { is_expected.to have_db_column(:updated_at) }
it { is_expected.to have_db_column(:order_place) }
it { is_expected.to have_db_column(:lien_demarche) }
end
describe 'associations' do
@ -29,5 +30,12 @@ describe TypeDePieceJustificative do
# it { is_expected.not_to allow_value('').for(:order_place) }
it { is_expected.to allow_value(1).for(:order_place) }
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.not_to allow_value('not-a-link').for(:lien_demarche) }
it { is_expected.to allow_value('http://link').for(:lien_demarche) }
end
end
end