From 418d4ede17e24a2765bf1e4a248d8ac71f1e8c8c Mon Sep 17 00:00:00 2001 From: Martin Date: Mon, 25 Apr 2022 14:57:15 +0200 Subject: [PATCH] test(commencer): test dossier_vide_pdf and dossier_vide_pdf_test --- config/routes.rb | 2 +- .../users/commencer_controller_spec.rb | 37 +++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/config/routes.rb b/config/routes.rb index 4dcfbe044..4dc41112c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -246,7 +246,7 @@ Rails.application.routes.draw do end namespace :commencer do - get '/test/:path/dossier_vide', action: 'dossier_vide_pdf_test', as: :dossier_vide_test + get '/test/:path/dossier_vide', action: :dossier_vide_pdf_test, as: :dossier_vide_test get '/test/:path', action: 'commencer_test', as: :test get '/:path', action: 'commencer' get '/:path/dossier_vide', action: 'dossier_vide_pdf', as: :dossier_vide diff --git a/spec/controllers/users/commencer_controller_spec.rb b/spec/controllers/users/commencer_controller_spec.rb index 39730b912..1f42717cc 100644 --- a/spec/controllers/users/commencer_controller_spec.rb +++ b/spec/controllers/users/commencer_controller_spec.rb @@ -160,4 +160,41 @@ describe Users::CommencerController, type: :controller do end end end + + describe '#dossier_vide_pdf' do + before { get :dossier_vide_pdf, params: { path: procedure.path } } + + context 'published procedure' do + let(:procedure) { create(:procedure, :published, :with_service, :with_path) } + + it 'works' do + expect(response).to have_http_status(:success) + end + end + context 'not published procedure' do + let(:procedure) { create(:procedure, :with_service, :with_path) } + + it 'redirects to procedure not found' do + expect(response).to have_http_status(302) + end + end + end + + describe '#dossier_vide_test_pdf' do + before { get :dossier_vide_pdf_test, params: { path: procedure.path } } + + context 'not published procedure' do + let(:procedure) { create(:procedure, :with_service, :with_path) } + + it 'works' do + expect(response).to have_http_status(:success) + end + end + context 'published procedure' do + let(:procedure) { create(:procedure, :published, :with_service, :with_path) } + it 'redirect to procedure not found' do + expect(response).to have_http_status(302) + end + end + end end