added automated tests for PDF rendering
- as a user, it should not display the administration info - as an instructeur, it should display the administration info - it should render the proper view with no crash
This commit is contained in:
parent
8da1185a5d
commit
0c2ccb4ae0
2 changed files with 56 additions and 8 deletions
|
@ -473,6 +473,34 @@ describe Instructeurs::DossiersController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
describe "#show" do
|
||||
context "when the dossier is exported as PDF" do
|
||||
let(:instructeur) { create(:instructeur) }
|
||||
let(:dossier) {
|
||||
create(:dossier,
|
||||
:accepte,
|
||||
:with_all_champs,
|
||||
:with_all_annotations,
|
||||
:with_motivation,
|
||||
:with_commentaires, procedure: procedure)
|
||||
}
|
||||
let!(:avis) { create(:avis, dossier: dossier, instructeur: instructeur) }
|
||||
subject do
|
||||
get :show, params: {
|
||||
procedure_id: procedure.id,
|
||||
dossier_id: dossier.id,
|
||||
format: :pdf
|
||||
}
|
||||
end
|
||||
|
||||
before do
|
||||
subject
|
||||
end
|
||||
it { expect(assigns(:include_infos_administration)).to eq(true) }
|
||||
it { expect(response).to render_template 'dossiers/show' }
|
||||
end
|
||||
end
|
||||
|
||||
describe "#update_annotations" do
|
||||
let(:champ_multiple_drop_down_list) do
|
||||
create(:type_de_champ_multiple_drop_down_list, :private, libelle: 'libelle').champ.create
|
||||
|
|
|
@ -731,17 +731,37 @@ describe Users::DossiersController, type: :controller do
|
|||
sign_in(user)
|
||||
end
|
||||
|
||||
subject! { get(:show, params: { id: dossier.id }) }
|
||||
context 'with default output' do
|
||||
subject! { get(:show, params: { id: dossier.id }) }
|
||||
|
||||
context 'when the dossier is a brouillon' do
|
||||
let(:dossier) { create(:dossier, user: user) }
|
||||
it { is_expected.to redirect_to(brouillon_dossier_path(dossier)) }
|
||||
context 'when the dossier is a brouillon' do
|
||||
let(:dossier) { create(:dossier, user: user) }
|
||||
it { is_expected.to redirect_to(brouillon_dossier_path(dossier)) }
|
||||
end
|
||||
|
||||
context 'when the dossier has been submitted' do
|
||||
let(:dossier) { create(:dossier, :en_construction, user: user) }
|
||||
it { expect(assigns(:dossier)).to eq(dossier) }
|
||||
it { is_expected.to render_template(:show) }
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the dossier has been submitted' do
|
||||
let(:dossier) { create(:dossier, :en_construction, user: user) }
|
||||
it { expect(assigns(:dossier)).to eq(dossier) }
|
||||
it { is_expected.to render_template(:show) }
|
||||
context "with PDF output" do
|
||||
let(:procedure) { create(:procedure) }
|
||||
let(:dossier) {
|
||||
create(:dossier,
|
||||
:accepte,
|
||||
:with_all_champs,
|
||||
:with_motivation,
|
||||
:with_commentaires,
|
||||
procedure: procedure,
|
||||
user: user)
|
||||
}
|
||||
|
||||
subject! { get(:show, params: { id: dossier.id, format: :pdf }) }
|
||||
|
||||
it { expect(assigns(:include_infos_administration)).to eq(false) }
|
||||
it { expect(response).to render_template 'dossiers/show' }
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue