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:
Frederic Merizen 2018-01-11 16:51:44 +01:00 committed by GitHub
commit 8c73851cec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -86,9 +86,6 @@ shared_examples 'description_controller_spec' do
subject { get :show, params: { dossier_id: dossier_id } }
context 'when dossier does not have an enterprise datas' do
before do
end
it { expect(dossier.entreprise).to be_nil }
it { expect(subject).to redirect_to "/users/dossiers/#{dossier.id}" }
end
@ -105,16 +102,12 @@ shared_examples 'description_controller_spec' do
end
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
describe 'Premier enregistrement des données' do
subject { post :update, params: {dossier_id: dossier_id, submit: submit} }
let(:state) { 'brouillon' }
before do
dossier.brouillon!
subject
def submit_dossier
post :update, params: { dossier_id: dossier_id, submit: submit }
dossier.reload
end
@ -122,22 +115,42 @@ shared_examples 'description_controller_spec' do
let(:submit) { { nouveaux: 'nouveaux' } }
it "redirection vers la page recapitulative" do
submit_dossier
expect(response).to redirect_to("/users/dossiers/#{dossier_id}/recapitulatif")
end
it 'etat du dossier est en construction' do
submit_dossier
expect(dossier.state).to eq('en_construction')
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
context 'when user saves a brouillon' do
let(:submit) { { brouillon: 'brouillon' } }
it "reste sur la page du dossier" do
submit_dossier
expect(response).to redirect_to("/users/dossiers/#{dossier_id}/description")
end
it 'etat du dossier est brouillon' do
submit_dossier
expect(dossier.state).to eq('brouillon')
end
end
@ -146,10 +159,12 @@ shared_examples 'description_controller_spec' do
let(:submit) { { brouillon_then_dashboard: 'brouillon_then_dashboard' } }
it "goes to dashboard" do
submit_dossier
expect(response).to redirect_to("/users/dossiers?liste=brouillon")
end
it 'etat du dossier est brouillon' do
submit_dossier
expect(dossier.state).to eq('brouillon')
end
end
@ -173,9 +188,7 @@ shared_examples 'description_controller_spec' do
end
context 'Quand la procédure accepte les CERFA' do
subject { post :update, params: {dossier_id: dossier_id,
cerfa_pdf: cerfa_pdf}
}
subject { post :update, params: { dossier_id: dossier_id, cerfa_pdf: cerfa_pdf } }
it 'Notification interne is create' do
expect { subject }.to change(Notification, :count).by (1)
@ -183,8 +196,7 @@ shared_examples 'description_controller_spec' do
context 'Sauvegarde du CERFA PDF', vcr: { cassette_name: 'controllers_users_description_controller_save_cerfa' } 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 }
dossier.reload
end
@ -224,8 +236,7 @@ shared_examples 'description_controller_spec' do
context 'Sauvegarde du CERFA PDF' do
let!(:procedure) { create(:procedure) }
before do
post :update, params: {dossier_id: dossier_id,
cerfa_pdf: cerfa_pdf}
post :update, params: { dossier_id: dossier_id, cerfa_pdf: cerfa_pdf }
dossier.reload
end
@ -247,7 +258,7 @@ shared_examples 'description_controller_spec' do
{
dossier_id: dossier_id,
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
},
time_hour: {