move check email params in validator
This commit is contained in:
parent
d557cee249
commit
88b663a514
7 changed files with 81 additions and 50 deletions
|
@ -104,7 +104,8 @@ describe DescriptionController, type: :controller do
|
|||
context 'Mauvais format(s)' do
|
||||
it 'mail_contact n\'est un format d\'email' do
|
||||
post :create, dossier_id: dossier_id, nom_projet: nom_projet, description: description, montant_projet: montant_projet, montant_aide_demande: montant_aide_demande, date_previsionnelle: date_previsionnelle, mail_contact: 'test.com'
|
||||
expect(response).to redirect_to("/dossiers/#{dossier_id}/description/error")
|
||||
expect(response).to render_template('show')
|
||||
expect(flash[:alert]).to be_present
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -10,5 +10,11 @@ FactoryGirl.define do
|
|||
dossier.etablissement = etablissement
|
||||
end
|
||||
end
|
||||
|
||||
trait :with_pieces_jointes do
|
||||
after(:build) do |dossier, _evaluator|
|
||||
dossier.build_default_pieces_jointes
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -31,52 +31,59 @@ describe Dossier do
|
|||
it { is_expected.to delegate_method(:types_piece_jointe).to(:formulaire) }
|
||||
end
|
||||
|
||||
let(:dossier) { create(:dossier, :with_entreprise) }
|
||||
|
||||
let(:entreprise) { dossier.entreprise }
|
||||
let(:etablissement) { dossier.etablissement }
|
||||
|
||||
subject { dossier }
|
||||
|
||||
describe '#types_piece_jointe' do
|
||||
subject { dossier.types_piece_jointe }
|
||||
it 'returns list of required piece justificative' do
|
||||
expect(subject.size).to eq(7)
|
||||
expect(subject).to include(TypePieceJointe.find(103))
|
||||
end
|
||||
describe 'validation' do
|
||||
it { is_expected.to allow_value('tanguy@plop.com').for(:mail_contact) }
|
||||
it { is_expected.not_to allow_value('tanguyplop.com').for(:mail_contact) }
|
||||
end
|
||||
|
||||
describe 'creation' do
|
||||
it 'create default cerfa' do
|
||||
expect { described_class.create }.to change { Cerfa.count }.by(1)
|
||||
describe 'methods' do
|
||||
let(:dossier) { create(:dossier, :with_entreprise) }
|
||||
|
||||
let(:entreprise) { dossier.entreprise }
|
||||
let(:etablissement) { dossier.etablissement }
|
||||
|
||||
subject { dossier }
|
||||
|
||||
describe '#types_piece_jointe' do
|
||||
subject { dossier.types_piece_jointe }
|
||||
it 'returns list of required piece justificative' do
|
||||
expect(subject.size).to eq(7)
|
||||
expect(subject).to include(TypePieceJointe.find(103))
|
||||
end
|
||||
end
|
||||
|
||||
it 'link cerfa to dossier' do
|
||||
dossier = described_class.create
|
||||
expect(dossier.cerfa).to eq(Cerfa.last)
|
||||
end
|
||||
end
|
||||
describe 'creation' do
|
||||
it 'create default cerfa' do
|
||||
expect { described_class.create }.to change { Cerfa.count }.by(1)
|
||||
end
|
||||
|
||||
describe '#retrieve_piece_jointe_by_type' do
|
||||
let(:type) { 93 }
|
||||
subject { dossier.retrieve_piece_jointe_by_type type }
|
||||
before do
|
||||
dossier.build_default_pieces_jointes
|
||||
it 'link cerfa to dossier' do
|
||||
dossier = described_class.create
|
||||
expect(dossier.cerfa).to eq(Cerfa.last)
|
||||
end
|
||||
end
|
||||
|
||||
it 'returns piece jointe with given type' do
|
||||
expect(subject.type).to eq(93)
|
||||
end
|
||||
end
|
||||
|
||||
describe '#build_default_pieces_jointes' do
|
||||
context 'when dossier is linked to a formualire' do
|
||||
let(:dossier) { create(:dossier) }
|
||||
describe '#retrieve_piece_jointe_by_type' do
|
||||
let(:type) { 93 }
|
||||
subject { dossier.retrieve_piece_jointe_by_type type }
|
||||
before do
|
||||
dossier.build_default_pieces_jointes
|
||||
end
|
||||
it 'build all pieces jointes needed' do
|
||||
expect(dossier.pieces_jointes.count).to eq(7)
|
||||
|
||||
it 'returns piece jointe with given type' do
|
||||
expect(subject.type).to eq(93)
|
||||
end
|
||||
end
|
||||
|
||||
describe '#build_default_pieces_jointes' do
|
||||
context 'when dossier is linked to a formualire' do
|
||||
let(:dossier) { create(:dossier) }
|
||||
before do
|
||||
dossier.build_default_pieces_jointes
|
||||
end
|
||||
it 'build all pieces jointes needed' do
|
||||
expect(dossier.pieces_jointes.count).to eq(7)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue