Merge branch 'dev' into new_design_edit_attestation

This commit is contained in:
jpoulvel 2020-07-30 09:53:09 +02:00 committed by GitHub
commit 62e04a6ca9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
33 changed files with 304 additions and 1145 deletions

View file

@ -41,23 +41,6 @@ describe Admin::ProceduresController, type: :controller do
it { expect(response.status).to eq(200) }
end
describe 'GET #index with sorting and pagination' do
before do
create(:procedure, administrateur: admin)
admin.reload
end
subject {
get :index, params: {
'procedures_smart_listing[page]': 1,
'procedures_smart_listing[per_page]': 10,
'procedures_smart_listing[sort][id]': 'asc'
}
}
it { expect(subject.status).to eq(200) }
end
describe 'GET #archived' do
subject { get :archived }

View file

@ -12,7 +12,7 @@ describe API::V2::GraphqlController do
dossier
end
let(:dossier1) { create(:dossier, :en_construction, :with_individual, procedure: procedure, en_construction_at: 1.day.ago) }
let(:dossier2) { create(:dossier, :en_construction, :with_individual, procedure: procedure, en_construction_at: 3.days.ago) }
let(:dossier2) { create(:dossier, :en_construction, :with_individual, :archived, procedure: procedure, en_construction_at: 3.days.ago) }
let(:dossier_brouillon) { create(:dossier, :with_individual, procedure: procedure) }
let(:dossiers) { [dossier2, dossier1, dossier] }
let(:instructeur) { create(:instructeur, followed_dossiers: dossiers) }
@ -171,6 +171,50 @@ describe API::V2::GraphqlController do
})
end
end
context "filter archived dossiers" do
let(:query) do
"{
demarche(number: #{procedure.id}) {
id
number
dossiers(archived: #{archived_filter}) {
nodes {
id
}
}
}
}"
end
context 'with archived=true' do
let(:archived_filter) { 'true' }
it "only archived dossiers should be returned" do
expect(gql_errors).to eq(nil)
expect(gql_data).to eq(demarche: {
id: procedure.to_typed_id,
number: procedure.id,
dossiers: {
nodes: [{ id: dossier2.to_typed_id }]
}
})
end
end
context 'with archived=false' do
let(:archived_filter) { 'false' }
it "only not archived dossiers should be returned" do
expect(gql_errors).to eq(nil)
expect(gql_data).to eq(demarche: {
id: procedure.to_typed_id,
number: procedure.id,
dossiers: {
nodes: [{ id: dossier1.to_typed_id }, { id: dossier.to_typed_id }]
}
})
end
end
end
end
context "dossier" do

View file

@ -43,6 +43,27 @@ describe NewAdministrateur::ProceduresController, type: :controller do
sign_in(admin.user)
end
describe 'GET #index' do
subject { get :index }
it { expect(response.status).to eq(200) }
end
describe 'GET #index with sorting and pagination' do
before do
create(:procedure, administrateur: admin)
admin.reload
end
subject {
get :index, params: {
'statut': 'publiees'
}
}
it { expect(subject.status).to eq(200) }
end
describe 'GET #edit' do
let(:published_at) { nil }
let(:procedure) { create(:procedure, administrateur: admin, published_at: published_at) }

View file

@ -18,6 +18,7 @@ feature 'As an administrateur I wanna clone a procedure', js: true do
scenario do
visit admin_procedures_path
expect(page.find_by_id('procedures')['data-item-count']).to eq('1')
page.all('.procedures-actions-btn').first.click
page.all('.clone-btn').first.click
visit admin_procedures_draft_path
expect(page.find_by_id('procedures')['data-item-count']).to eq('1')

View file

@ -12,18 +12,18 @@ feature 'As an administrateur I wanna create a new procedure', js: true do
context 'Right after sign_in I shall see all procedure states links' do
scenario 'Finding draft procedures' do
click_on 'draft-procedures'
expect(page).to have_current_path(admin_procedures_draft_path)
page.all('.tabs li a')[1].click
expect(page).to have_current_path(admin_procedures_path(statut: 'brouillons'))
end
scenario 'Finding active procedures' do
click_on 'active-procedures'
expect(page).to have_current_path(admin_procedures_path)
page.all('.tabs li a').first.click
expect(page).to have_current_path(admin_procedures_path(statut: 'publiees'))
end
scenario 'Finding archived procedures' do
click_on 'archived-procedures'
expect(page).to have_current_path(admin_procedures_archived_path)
page.all('.tabs li a').last.click
expect(page).to have_current_path(admin_procedures_path(statut: 'archivees'))
end
end
@ -32,7 +32,6 @@ feature 'As an administrateur I wanna create a new procedure', js: true do
scenario 'Finding save button for new procedure, libelle, description and cadre_juridique required' do
expect(page).to have_selector('#new-procedure')
find('#new-procedure').click
click_on 'from-scratch'
expect(page).to have_current_path(new_admin_procedure_path)
expect(find('#procedure_for_individual_true')).to be_checked
@ -54,7 +53,6 @@ feature 'As an administrateur I wanna create a new procedure', js: true do
before 'Create procedure' do
expect(page).to have_selector('#new-procedure')
find('#new-procedure').click
click_on 'from-scratch'
expect(page).to have_current_path(new_admin_procedure_path)
fill_in_dummy_procedure_details

View file

@ -229,6 +229,7 @@ feature 'The routing', js: true do
def log_out(old_layout: false)
if old_layout
page.all('.dropdown-button').first.click
click_on 'Se déconnecter'
else
click_button(title: 'Mon compte')

View file

@ -215,33 +215,4 @@ RSpec.describe DossierHelper, type: :helper do
it { is_expected.to eq('without_continuation') }
end
end
describe '.has_lost_attachments' do
let(:procedure) { create(:procedure, :published) }
let(:dossier_with_lost_attachments) { create(:dossier, procedure: procedure) }
let(:dossier_without_lost_attachments) { create(:dossier, procedure: procedure) }
before do
expect(ENV).to receive(:[]).with('APP_HOST').at_least(:once).and_return(app_host)
allow(helper).to receive(:dossiers_with_lost_attachments_ids).and_return([dossier_with_lost_attachments.id])
end
context 'on the DINUM instance' do
let(:app_host) { 'demarches-simplifiees.fr' }
it 'returns true for dossiers that lost attachments' do
expect(helper.has_lost_attachments(dossier_with_lost_attachments)).to be(true)
expect(helper.has_lost_attachments(dossier_without_lost_attachments)).to be(false)
end
end
context 'on another instance' do
let(:app_host) { 'polynesie-francaise.pref.gouv.fr' }
it 'returns false for all dossiers' do
expect(helper.has_lost_attachments(dossier_with_lost_attachments)).to be(false)
expect(helper.has_lost_attachments(dossier_without_lost_attachments)).to be(false)
end
end
end
end

View file

@ -50,15 +50,5 @@ describe 'shared/dossiers/demande.html.haml', type: :view do
expect(subject).to include(champ.libelle)
end
end
context 'when the dossier lost some attachments' do
before do
expect(view).to receive(:has_lost_attachments).and_return(true)
end
it 'displays a warning message' do
expect(subject).to include('Des pièces jointes de votre dossier peuvent être manquantes.')
end
end
end
end

View file

@ -1,40 +0,0 @@
describe 'shared/dossiers/lost_attachments.html.haml', type: :view do
let(:procedure) { create(:procedure, :published) }
let(:dossier) { create(:dossier, :en_construction, procedure: procedure) }
subject { render 'shared/dossiers/lost_attachments.html.haml', dossier: dossier, profile: profile }
context 'when viewed by an Usager' do
let(:profile) { 'usager' }
it 'displays a warning message' do
expect(subject).to include('Des pièces jointes de votre dossier peuvent être manquantes')
expect(subject).to have_link('renvoyer les pièces jointes manquantes', href: modifier_dossier_path(dossier))
end
context 'when the user cant edit the dossier' do
let(:dossier) { create(:dossier, :en_instruction, procedure: procedure) }
it 'suggest to wait' do
expect(subject).to include('ladministration vous contactera')
end
end
end
context 'when viewed by an Instructeur' do
let(:profile) { 'instructeur' }
it 'displays a warning message' do
expect(subject).to include('Des pièces jointes de ce dossier peuvent être manquantes')
expect(subject).to have_link('contacter le demandeur')
end
context 'when the user cant edit the dossier' do
let(:dossier) { create(:dossier, :en_instruction, procedure: procedure) }
it 'suggest to make the dossier editable again' do
expect(subject).to include('repasser ce dossier en construction')
end
end
end
end