test(commencer): test dossier_vide_pdf and dossier_vide_pdf_test

This commit is contained in:
Martin 2022-04-25 14:57:15 +02:00 committed by mfo
parent 89d192bcfe
commit 418d4ede17
2 changed files with 38 additions and 1 deletions

View file

@ -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

View file

@ -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