validation des pièces justificative
This commit is contained in:
parent
94cfa8a139
commit
542cdbaefd
5 changed files with 34 additions and 6 deletions
|
@ -1,4 +1,7 @@
|
|||
class TypeDePieceJustificative < ActiveRecord::Base
|
||||
has_many :pieces_justificatives
|
||||
belongs_to :procedure
|
||||
|
||||
validates :libelle, presence: true, allow_blank: false, allow_nil: false
|
||||
validates :description, presence: true, allow_blank: false, allow_nil: false
|
||||
end
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class DefaultAPIEntrepriseAtFalseToTypeDePieceJustificative < ActiveRecord::Migration
|
||||
def change
|
||||
change_column :types_de_piece_justificative, :api_entreprise, :boolean, :default => false
|
||||
end
|
||||
end
|
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20150922085811) do
|
||||
ActiveRecord::Schema.define(version: 20150922110719) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
@ -126,7 +126,7 @@ ActiveRecord::Schema.define(version: 20150922085811) do
|
|||
create_table "types_de_piece_justificative", force: :cascade do |t|
|
||||
t.string "libelle"
|
||||
t.string "description"
|
||||
t.boolean "api_entreprise"
|
||||
t.boolean "api_entreprise", default: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.integer "procedure_id"
|
||||
|
|
|
@ -2,10 +2,14 @@ FactoryGirl.define do
|
|||
factory :type_de_piece_justificative do
|
||||
trait :rib do
|
||||
libelle 'RIB'
|
||||
description 'Releve identité bancaire'
|
||||
api_entreprise false
|
||||
end
|
||||
|
||||
trait :contrat do
|
||||
libelle 'Contrat'
|
||||
trait :msa do
|
||||
libelle 'Attestation MSA'
|
||||
description 'recuperation automatique'
|
||||
api_entreprise true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe TypeDePieceJustificative do
|
||||
let!(:procedure) { create(:procedure) }
|
||||
|
||||
describe 'database columns' do
|
||||
it { is_expected.to have_db_column(:libelle) }
|
||||
it { is_expected.to have_db_column(:description) }
|
||||
|
@ -13,4 +15,18 @@ describe TypeDePieceJustificative do
|
|||
it { is_expected.to have_many(:pieces_justificatives) }
|
||||
it { is_expected.to belong_to(:procedure) }
|
||||
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('RIB').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('Releve identité bancaire').for(:description) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue