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
|
class TypeDePieceJustificative < ActiveRecord::Base
|
||||||
has_many :pieces_justificatives
|
has_many :pieces_justificatives
|
||||||
belongs_to :procedure
|
belongs_to :procedure
|
||||||
|
|
||||||
|
validates :libelle, presence: true, allow_blank: false, allow_nil: false
|
||||||
|
validates :description, presence: true, allow_blank: false, allow_nil: false
|
||||||
end
|
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.
|
# 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
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
|
@ -126,9 +126,9 @@ ActiveRecord::Schema.define(version: 20150922085811) do
|
||||||
create_table "types_de_piece_justificative", force: :cascade do |t|
|
create_table "types_de_piece_justificative", force: :cascade do |t|
|
||||||
t.string "libelle"
|
t.string "libelle"
|
||||||
t.string "description"
|
t.string "description"
|
||||||
t.boolean "api_entreprise"
|
t.boolean "api_entreprise", default: false
|
||||||
t.datetime "created_at", null: false
|
t.datetime "created_at", null: false
|
||||||
t.datetime "updated_at", null: false
|
t.datetime "updated_at", null: false
|
||||||
t.integer "procedure_id"
|
t.integer "procedure_id"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -2,10 +2,14 @@ FactoryGirl.define do
|
||||||
factory :type_de_piece_justificative do
|
factory :type_de_piece_justificative do
|
||||||
trait :rib do
|
trait :rib do
|
||||||
libelle 'RIB'
|
libelle 'RIB'
|
||||||
|
description 'Releve identité bancaire'
|
||||||
|
api_entreprise false
|
||||||
end
|
end
|
||||||
|
|
||||||
trait :contrat do
|
trait :msa do
|
||||||
libelle 'Contrat'
|
libelle 'Attestation MSA'
|
||||||
|
description 'recuperation automatique'
|
||||||
|
api_entreprise true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe TypeDePieceJustificative do
|
describe TypeDePieceJustificative do
|
||||||
|
let!(:procedure) { create(:procedure) }
|
||||||
|
|
||||||
describe 'database columns' do
|
describe 'database columns' do
|
||||||
it { is_expected.to have_db_column(:libelle) }
|
it { is_expected.to have_db_column(:libelle) }
|
||||||
it { is_expected.to have_db_column(:description) }
|
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 have_many(:pieces_justificatives) }
|
||||||
it { is_expected.to belong_to(:procedure) }
|
it { is_expected.to belong_to(:procedure) }
|
||||||
end
|
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
|
end
|
||||||
|
|
Loading…
Reference in a new issue