Can get dossier vide if procedure is closed
This commit is contained in:
parent
29e3b3f831
commit
e087582f57
2 changed files with 15 additions and 5 deletions
|
@ -19,14 +19,14 @@ module Users
|
||||||
end
|
end
|
||||||
|
|
||||||
def dossier_vide_pdf
|
def dossier_vide_pdf
|
||||||
@procedure = retrieve_procedure
|
@procedure = retrieve_procedure_with_closed
|
||||||
return procedure_not_found if @procedure.blank? || @procedure.brouillon?
|
return procedure_not_found if @procedure.blank? || @procedure.brouillon?
|
||||||
|
|
||||||
generate_empty_pdf(@procedure.published_revision)
|
generate_empty_pdf(@procedure.published_revision)
|
||||||
end
|
end
|
||||||
|
|
||||||
def dossier_vide_pdf_test
|
def dossier_vide_pdf_test
|
||||||
@procedure = retrieve_procedure
|
@procedure = retrieve_procedure_with_closed
|
||||||
return procedure_not_found if @procedure.blank? || (@procedure.publiee? && !@procedure.draft_changed?)
|
return procedure_not_found if @procedure.blank? || (@procedure.publiee? && !@procedure.draft_changed?)
|
||||||
|
|
||||||
generate_empty_pdf(@procedure.draft_revision)
|
generate_empty_pdf(@procedure.draft_revision)
|
||||||
|
@ -66,6 +66,10 @@ module Users
|
||||||
Procedure.publiees.or(Procedure.brouillons).find_by(path: params[:path])
|
Procedure.publiees.or(Procedure.brouillons).find_by(path: params[:path])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def retrieve_procedure_with_closed
|
||||||
|
Procedure.publiees.or(Procedure.brouillons).or(Procedure.closes).find_by(path: params[:path])
|
||||||
|
end
|
||||||
|
|
||||||
def procedure_not_found
|
def procedure_not_found
|
||||||
procedure = Procedure.find_by(path: params[:path])
|
procedure = Procedure.find_by(path: params[:path])
|
||||||
|
|
||||||
|
|
|
@ -192,22 +192,28 @@ describe Users::CommencerController, type: :controller do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#dossier_vide_pdf' do
|
describe '#dossier_vide_pdf' do
|
||||||
|
let(:procedure) { create(:procedure, :published, :with_service, :with_path) }
|
||||||
before { get :dossier_vide_pdf, params: { path: procedure.path } }
|
before { get :dossier_vide_pdf, params: { path: procedure.path } }
|
||||||
|
|
||||||
context 'published procedure' do
|
context 'published procedure' do
|
||||||
let(:procedure) { create(:procedure, :published, :with_service, :with_path) }
|
|
||||||
|
|
||||||
it 'works' do
|
it 'works' do
|
||||||
expect(response).to have_http_status(:success)
|
expect(response).to have_http_status(:success)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
context 'not published procedure' do
|
context 'not yet published procedure' do
|
||||||
let(:procedure) { create(:procedure, :with_service, :with_path) }
|
let(:procedure) { create(:procedure, :with_service, :with_path) }
|
||||||
|
|
||||||
it 'redirects to procedure not found' do
|
it 'redirects to procedure not found' do
|
||||||
expect(response).to have_http_status(302)
|
expect(response).to have_http_status(302)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
context 'closed procedure' do
|
||||||
|
it 'works' do
|
||||||
|
procedure.service = create(:service)
|
||||||
|
procedure.close!
|
||||||
|
expect(response).to have_http_status(:success)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#dossier_vide_test_pdf' do
|
describe '#dossier_vide_test_pdf' do
|
||||||
|
|
Loading…
Reference in a new issue