Merge pull request #1242 from betagouv/fix_1209-date_de_depot_in_received_mail
Fix 1209 date de depot in received mail
This commit is contained in:
commit
8c73851cec
1 changed files with 61 additions and 50 deletions
|
@ -9,7 +9,7 @@ shared_examples 'description_controller_spec' do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'redirects to users/sign_in' do
|
it 'redirects to users/sign_in' do
|
||||||
get :show, params: {dossier_id: dossier_id}
|
get :show, params: { dossier_id: dossier_id }
|
||||||
expect(response).to redirect_to('/users/sign_in')
|
expect(response).to redirect_to('/users/sign_in')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -17,7 +17,7 @@ shared_examples 'description_controller_spec' do
|
||||||
context 'when all is ok' do
|
context 'when all is ok' do
|
||||||
before do
|
before do
|
||||||
dossier.entreprise = create :entreprise
|
dossier.entreprise = create :entreprise
|
||||||
get :show, params: {dossier_id: dossier_id}
|
get :show, params: { dossier_id: dossier_id }
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns http success' do
|
it 'returns http success' do
|
||||||
|
@ -41,7 +41,7 @@ shared_examples 'description_controller_spec' do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'redirection vers start si mauvais dossier ID' do
|
it 'redirection vers start si mauvais dossier ID' do
|
||||||
get :show, params: {dossier_id: bad_dossier_id}
|
get :show, params: { dossier_id: bad_dossier_id }
|
||||||
|
|
||||||
expect(flash[:alert]).to be_present
|
expect(flash[:alert]).to be_present
|
||||||
expect(response).to redirect_to(root_path)
|
expect(response).to redirect_to(root_path)
|
||||||
|
@ -55,7 +55,7 @@ shared_examples 'description_controller_spec' do
|
||||||
dossier.state = 'en_instruction'
|
dossier.state = 'en_instruction'
|
||||||
dossier.save
|
dossier.save
|
||||||
|
|
||||||
get :show, params: {dossier_id: dossier.id}
|
get :show, params: { dossier_id: dossier.id }
|
||||||
end
|
end
|
||||||
|
|
||||||
it { is_expected.to redirect_to root_path }
|
it { is_expected.to redirect_to root_path }
|
||||||
|
@ -63,7 +63,7 @@ shared_examples 'description_controller_spec' do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'before action check_autorisation_donnees' do
|
describe 'before action check_autorisation_donnees' do
|
||||||
subject { get :show, params: {dossier_id: dossier_id} }
|
subject { get :show, params: { dossier_id: dossier_id } }
|
||||||
|
|
||||||
context 'when dossier does not have a valid autorisations_donness (nil)' do
|
context 'when dossier does not have a valid autorisations_donness (nil)' do
|
||||||
before do
|
before do
|
||||||
|
@ -83,12 +83,9 @@ shared_examples 'description_controller_spec' do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'before action check_starter_dossier_informations' do
|
describe 'before action check_starter_dossier_informations' do
|
||||||
subject { get :show, params: {dossier_id: dossier_id} }
|
subject { get :show, params: { dossier_id: dossier_id } }
|
||||||
|
|
||||||
context 'when dossier does not have an enterprise datas' do
|
context 'when dossier does not have an enterprise datas' do
|
||||||
before do
|
|
||||||
end
|
|
||||||
|
|
||||||
it { expect(dossier.entreprise).to be_nil }
|
it { expect(dossier.entreprise).to be_nil }
|
||||||
it { expect(subject).to redirect_to "/users/dossiers/#{dossier.id}" }
|
it { expect(subject).to redirect_to "/users/dossiers/#{dossier.id}" }
|
||||||
end
|
end
|
||||||
|
@ -105,51 +102,69 @@ shared_examples 'description_controller_spec' do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'POST #update' do
|
describe 'POST #update' do
|
||||||
let(:timestamp) { Time.now }
|
|
||||||
let(:description) { 'Description de test Coucou, je suis un saut à la ligne Je suis un double saut la ligne.' }
|
|
||||||
|
|
||||||
context 'Tous les attributs sont bons' do
|
context 'Tous les attributs sont bons' do
|
||||||
describe 'Premier enregistrement des données' do
|
describe 'Premier enregistrement des données' do
|
||||||
subject { post :update, params: {dossier_id: dossier_id, submit: submit} }
|
let(:state) { 'brouillon' }
|
||||||
|
|
||||||
before do
|
def submit_dossier
|
||||||
dossier.brouillon!
|
post :update, params: { dossier_id: dossier_id, submit: submit }
|
||||||
subject
|
|
||||||
dossier.reload
|
dossier.reload
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when the user submits the dossier" do
|
context "when the user submits the dossier" do
|
||||||
let(:submit) { {nouveaux: 'nouveaux'} }
|
let(:submit) { { nouveaux: 'nouveaux' } }
|
||||||
|
|
||||||
it "redirection vers la page recapitulative" do
|
it "redirection vers la page recapitulative" do
|
||||||
|
submit_dossier
|
||||||
|
|
||||||
expect(response).to redirect_to("/users/dossiers/#{dossier_id}/recapitulatif")
|
expect(response).to redirect_to("/users/dossiers/#{dossier_id}/recapitulatif")
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'etat du dossier est en construction' do
|
it 'etat du dossier est en construction' do
|
||||||
|
submit_dossier
|
||||||
|
|
||||||
expect(dossier.state).to eq('en_construction')
|
expect(dossier.state).to eq('en_construction')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'sending the accusé de réception mail' do
|
||||||
|
before { Timecop.freeze(DateTime.now) }
|
||||||
|
|
||||||
|
after { Timecop.return }
|
||||||
|
|
||||||
|
it 'sets the state of the dossier before sending the mail' do
|
||||||
|
expect_any_instance_of(Mails::InitiatedMail)
|
||||||
|
.to receive(:subject_for_dossier)
|
||||||
|
.with(have_attributes(en_construction_at: DateTime.now))
|
||||||
|
|
||||||
|
submit_dossier
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when user saves a brouillon' do
|
context 'when user saves a brouillon' do
|
||||||
let(:submit) { {brouillon: 'brouillon'} }
|
let(:submit) { { brouillon: 'brouillon' } }
|
||||||
|
|
||||||
it "reste sur la page du dossier" do
|
it "reste sur la page du dossier" do
|
||||||
|
submit_dossier
|
||||||
expect(response).to redirect_to("/users/dossiers/#{dossier_id}/description")
|
expect(response).to redirect_to("/users/dossiers/#{dossier_id}/description")
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'etat du dossier est brouillon' do
|
it 'etat du dossier est brouillon' do
|
||||||
|
submit_dossier
|
||||||
expect(dossier.state).to eq('brouillon')
|
expect(dossier.state).to eq('brouillon')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when user saves a brouillon and goes to dashboard' do
|
context 'when user saves a brouillon and goes to dashboard' do
|
||||||
let(:submit) { {brouillon_then_dashboard: 'brouillon_then_dashboard'} }
|
let(:submit) { { brouillon_then_dashboard: 'brouillon_then_dashboard' } }
|
||||||
|
|
||||||
it "goes to dashboard" do
|
it "goes to dashboard" do
|
||||||
|
submit_dossier
|
||||||
expect(response).to redirect_to("/users/dossiers?liste=brouillon")
|
expect(response).to redirect_to("/users/dossiers?liste=brouillon")
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'etat du dossier est brouillon' do
|
it 'etat du dossier est brouillon' do
|
||||||
|
submit_dossier
|
||||||
expect(dossier.state).to eq('brouillon')
|
expect(dossier.state).to eq('brouillon')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -158,7 +173,7 @@ shared_examples 'description_controller_spec' do
|
||||||
context 'En train de manipuler un dossier non brouillon' do
|
context 'En train de manipuler un dossier non brouillon' do
|
||||||
before do
|
before do
|
||||||
dossier.en_construction!
|
dossier.en_construction!
|
||||||
post :update, params: {dossier_id: dossier_id}
|
post :update, params: { dossier_id: dossier_id }
|
||||||
dossier.reload
|
dossier.reload
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -173,22 +188,19 @@ shared_examples 'description_controller_spec' do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'Quand la procédure accepte les CERFA' do
|
context 'Quand la procédure accepte les CERFA' do
|
||||||
subject { post :update, params: {dossier_id: dossier_id,
|
subject { post :update, params: { dossier_id: dossier_id, cerfa_pdf: cerfa_pdf } }
|
||||||
cerfa_pdf: cerfa_pdf}
|
|
||||||
}
|
|
||||||
|
|
||||||
it 'Notification interne is create' do
|
it 'Notification interne is create' do
|
||||||
expect { subject }.to change(Notification, :count).by (1)
|
expect { subject }.to change(Notification, :count).by (1)
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'Sauvegarde du CERFA PDF', vcr: {cassette_name: 'controllers_users_description_controller_save_cerfa'} do
|
context 'Sauvegarde du CERFA PDF', vcr: { cassette_name: 'controllers_users_description_controller_save_cerfa' } do
|
||||||
before do
|
before do
|
||||||
post :update, params: {dossier_id: dossier_id,
|
post :update, params: { dossier_id: dossier_id, cerfa_pdf: cerfa_pdf }
|
||||||
cerfa_pdf: cerfa_pdf}
|
|
||||||
dossier.reload
|
dossier.reload
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when a CERFA PDF is sent', vcr: {cassette_name: 'controllers_users_description_controller_cerfa_is_sent'} do
|
context 'when a CERFA PDF is sent', vcr: { cassette_name: 'controllers_users_description_controller_cerfa_is_sent' } do
|
||||||
subject { dossier.cerfa.first }
|
subject { dossier.cerfa.first }
|
||||||
|
|
||||||
it 'content' do
|
it 'content' do
|
||||||
|
@ -210,7 +222,7 @@ shared_examples 'description_controller_spec' do
|
||||||
let(:cerfas) { Cerfa.where(dossier_id: dossier_id) }
|
let(:cerfas) { Cerfa.where(dossier_id: dossier_id) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
post :update, params: {dossier_id: dossier_id, cerfa_pdf: cerfa_pdf}
|
post :update, params: { dossier_id: dossier_id, cerfa_pdf: cerfa_pdf }
|
||||||
end
|
end
|
||||||
|
|
||||||
it "il y a deux CERFA PDF pour ce dossier" do
|
it "il y a deux CERFA PDF pour ce dossier" do
|
||||||
|
@ -224,8 +236,7 @@ shared_examples 'description_controller_spec' do
|
||||||
context 'Sauvegarde du CERFA PDF' do
|
context 'Sauvegarde du CERFA PDF' do
|
||||||
let!(:procedure) { create(:procedure) }
|
let!(:procedure) { create(:procedure) }
|
||||||
before do
|
before do
|
||||||
post :update, params: {dossier_id: dossier_id,
|
post :update, params: { dossier_id: dossier_id, cerfa_pdf: cerfa_pdf }
|
||||||
cerfa_pdf: cerfa_pdf}
|
|
||||||
dossier.reload
|
dossier.reload
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -247,7 +258,7 @@ shared_examples 'description_controller_spec' do
|
||||||
{
|
{
|
||||||
dossier_id: dossier_id,
|
dossier_id: dossier_id,
|
||||||
champs: {
|
champs: {
|
||||||
"'#{dossier_text_champ_id}'" => dossier_text_value, # PARFOIS ce putain de champ est associé à un type datetime, et en plus parfois l'ordre n'est pas le bon
|
"'#{dossier_text_champ_id}'" => dossier_text_value,
|
||||||
"'#{dossier_datetime_champ_id}'" => dossier_date_value
|
"'#{dossier_datetime_champ_id}'" => dossier_date_value
|
||||||
},
|
},
|
||||||
time_hour: {
|
time_hour: {
|
||||||
|
@ -286,22 +297,22 @@ shared_examples 'description_controller_spec' do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'Sauvegarde des pièces justificatives', vcr: {cassette_name: 'controllers_users_description_controller_sauvegarde_pj'} do
|
context 'Sauvegarde des pièces justificatives', vcr: { cassette_name: 'controllers_users_description_controller_sauvegarde_pj' } do
|
||||||
let(:all_pj_type) { dossier.procedure.type_de_piece_justificative_ids }
|
let(:all_pj_type) { dossier.procedure.type_de_piece_justificative_ids }
|
||||||
before do
|
before do
|
||||||
post :update, params: {dossier_id: dossier_id,
|
post :update, params: { dossier_id: dossier_id,
|
||||||
'piece_justificative_' + all_pj_type[0].to_s => piece_justificative_0,
|
'piece_justificative_' + all_pj_type[0].to_s => piece_justificative_0,
|
||||||
'piece_justificative_' + all_pj_type[1].to_s => piece_justificative_1}
|
'piece_justificative_' + all_pj_type[1].to_s => piece_justificative_1 }
|
||||||
dossier.reload
|
dossier.reload
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'clamav anti-virus presence', vcr: {cassette_name: 'controllers_users_description_controller_clamav_presence'} do
|
describe 'clamav anti-virus presence', vcr: { cassette_name: 'controllers_users_description_controller_clamav_presence' } do
|
||||||
it 'ClamavService safe_file? is call' do
|
it 'ClamavService safe_file? is call' do
|
||||||
expect(ClamavService).to receive(:safe_file?).twice
|
expect(ClamavService).to receive(:safe_file?).twice
|
||||||
|
|
||||||
post :update, params: {dossier_id: dossier_id,
|
post :update, params: { dossier_id: dossier_id,
|
||||||
'piece_justificative_' + all_pj_type[0].to_s => piece_justificative_0,
|
'piece_justificative_' + all_pj_type[0].to_s => piece_justificative_0,
|
||||||
'piece_justificative_' + all_pj_type[1].to_s => piece_justificative_1}
|
'piece_justificative_' + all_pj_type[1].to_s => piece_justificative_1 }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -334,12 +345,12 @@ shared_examples 'description_controller_spec' do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'POST #pieces_justificatives', vcr: {cassette_name: 'controllers_users_description_controller_pieces_justificatives'} do
|
describe 'POST #pieces_justificatives', vcr: { cassette_name: 'controllers_users_description_controller_pieces_justificatives' } do
|
||||||
let(:all_pj_type) { dossier.procedure.type_de_piece_justificative_ids }
|
let(:all_pj_type) { dossier.procedure.type_de_piece_justificative_ids }
|
||||||
|
|
||||||
subject { patch :pieces_justificatives, params: {dossier_id: dossier.id,
|
subject { patch :pieces_justificatives, params: { dossier_id: dossier.id,
|
||||||
'piece_justificative_' + all_pj_type[0].to_s => piece_justificative_0,
|
'piece_justificative_' + all_pj_type[0].to_s => piece_justificative_0,
|
||||||
'piece_justificative_' + all_pj_type[1].to_s => piece_justificative_1}
|
'piece_justificative_' + all_pj_type[1].to_s => piece_justificative_1 }
|
||||||
}
|
}
|
||||||
|
|
||||||
context 'when user is a guest' do
|
context 'when user is a guest' do
|
||||||
|
@ -378,7 +389,7 @@ shared_examples 'description_controller_spec' do
|
||||||
|
|
||||||
it { expect(dossier.pieces_justificatives.size).to eq 2 }
|
it { expect(dossier.pieces_justificatives.size).to eq 2 }
|
||||||
|
|
||||||
context 'when upload two PJ', vcr: {cassette_name: 'controllers_users_description_controller_upload_2pj'} do
|
context 'when upload two PJ', vcr: { cassette_name: 'controllers_users_description_controller_upload_2pj' } do
|
||||||
before do
|
before do
|
||||||
subject
|
subject
|
||||||
dossier.reload
|
dossier.reload
|
||||||
|
@ -413,12 +424,12 @@ end
|
||||||
shared_examples 'description_controller_spec_POST_piece_justificatives_for_owner' do
|
shared_examples 'description_controller_spec_POST_piece_justificatives_for_owner' do
|
||||||
let(:all_pj_type) { dossier.procedure.type_de_piece_justificative_ids }
|
let(:all_pj_type) { dossier.procedure.type_de_piece_justificative_ids }
|
||||||
|
|
||||||
subject { patch :pieces_justificatives, params: {dossier_id: dossier.id,
|
subject { patch :pieces_justificatives, params: { dossier_id: dossier.id,
|
||||||
'piece_justificative_' + all_pj_type[0].to_s => piece_justificative_0,
|
'piece_justificative_' + all_pj_type[0].to_s => piece_justificative_0,
|
||||||
'piece_justificative_' + all_pj_type[1].to_s => piece_justificative_1}
|
'piece_justificative_' + all_pj_type[1].to_s => piece_justificative_1 }
|
||||||
}
|
}
|
||||||
|
|
||||||
context 'when user is the owner', vcr: {cassette_name: 'controllers_users_description_controller_pieces_justificatives'} do
|
context 'when user is the owner', vcr: { cassette_name: 'controllers_users_description_controller_pieces_justificatives' } do
|
||||||
before do
|
before do
|
||||||
sign_in user
|
sign_in user
|
||||||
end
|
end
|
||||||
|
@ -438,7 +449,7 @@ shared_examples 'description_controller_spec_POST_piece_justificatives_for_owner
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when PJ have already a document', vcr: {cassette_name: 'controllers_users_description_controller_pj_already_exist'} do
|
context 'when PJ have already a document', vcr: { cassette_name: 'controllers_users_description_controller_pj_already_exist' } do
|
||||||
before do
|
before do
|
||||||
create :piece_justificative, :rib, dossier: dossier, type_de_piece_justificative_id: all_pj_type[0]
|
create :piece_justificative, :rib, dossier: dossier, type_de_piece_justificative_id: all_pj_type[0]
|
||||||
create :piece_justificative, :contrat, dossier: dossier, type_de_piece_justificative_id: all_pj_type[1]
|
create :piece_justificative, :contrat, dossier: dossier, type_de_piece_justificative_id: all_pj_type[1]
|
||||||
|
@ -446,7 +457,7 @@ shared_examples 'description_controller_spec_POST_piece_justificatives_for_owner
|
||||||
|
|
||||||
it { expect(dossier.pieces_justificatives.size).to eq 2 }
|
it { expect(dossier.pieces_justificatives.size).to eq 2 }
|
||||||
|
|
||||||
context 'when upload two PJ', vcr: {cassette_name: 'controllers_users_description_controller_pj_already_exist_upload_2pj'} do
|
context 'when upload two PJ', vcr: { cassette_name: 'controllers_users_description_controller_pj_already_exist_upload_2pj' } do
|
||||||
before do
|
before do
|
||||||
subject
|
subject
|
||||||
dossier.reload
|
dossier.reload
|
||||||
|
|
Loading…
Reference in a new issue