[fix #504] Dossier: without_continuation -> sans_suite

This commit is contained in:
Simon Lehericey 2017-12-04 20:23:57 +01:00 committed by LeSim
parent 2be9b8d2ba
commit c83552f423
22 changed files with 64 additions and 41 deletions

View file

@ -18,7 +18,7 @@ class Users::RecapitulatifController < UsersController
def self.route_authorization
{
states: [:en_construction, :en_instruction, :without_continuation, :accepte, :refuse]
states: [:en_construction, :en_instruction, :sans_suite, :accepte, :refuse]
}
end

View file

@ -2,7 +2,7 @@ module DossierHelper
def button_or_label_class(dossier)
if dossier.accepte?
'accepted'
elsif dossier.without_continuation?
elsif dossier.sans_suite?
'without-continuation'
elsif dossier.refuse?
'refuse'

View file

@ -1,11 +1,11 @@
class Dossier < ActiveRecord::Base
enum state: {
brouillon: 'brouillon',
en_construction: 'en_construction',
en_instruction: 'en_instruction',
accepte: 'accepte',
refuse: 'refuse',
without_continuation: 'without_continuation'
brouillon: 'brouillon',
en_construction: 'en_construction',
en_instruction: 'en_instruction',
accepte: 'accepte',
refuse: 'refuse',
sans_suite: 'sans_suite'
}
BROUILLON = %w(brouillon)
@ -13,7 +13,7 @@ class Dossier < ActiveRecord::Base
EN_CONSTRUCTION = %w(en_construction)
EN_INSTRUCTION = %w(en_instruction)
EN_CONSTRUCTION_OU_INSTRUCTION = EN_CONSTRUCTION + EN_INSTRUCTION
TERMINE = %w(accepte refuse without_continuation)
TERMINE = %w(accepte refuse sans_suite)
has_one :etablissement, dependent: :destroy
has_one :entreprise, dependent: :destroy
@ -186,7 +186,7 @@ class Dossier < ActiveRecord::Base
end
when 'without_continuation'
if en_instruction?
without_continuation!
sans_suite!
if motivation
self.motivation = motivation
@ -283,7 +283,7 @@ class Dossier < ActiveRecord::Base
end
def read_only?
en_instruction? || accepte? || refuse? || without_continuation?
en_instruction? || accepte? || refuse? || sans_suite?
end
def owner? email
@ -366,7 +366,7 @@ class Dossier < ActiveRecord::Base
def statut
if accepte?
'accepté'
elsif without_continuation?
elsif sans_suite?
'classé sans suite'
elsif refuse?
'refusé'

View file

@ -45,6 +45,8 @@ class DossierSerializer < ActiveModel::Serializer
'closed'
when 'refuse'
'refused'
when 'sans_suite'
'without_continuation'
else
object.state
end

View file

@ -32,6 +32,8 @@ class DossierTableExportSerializer < ActiveModel::Serializer
'closed'
when 'refuse'
'refused'
when 'sans_suite'
'without_continuation'
else
object.state
end

View file

@ -6,5 +6,5 @@
%span.label.accepted accepté
- elsif dossier.refuse?
%span.label.refused refusé
- elsif dossier.without_continuation?
- elsif dossier.sans_suite?
%span.label.without-continuation sans suite

View file

@ -13,7 +13,7 @@ fr:
en_instruction: "En instruction"
accepte: "Accepté"
refuse: "Refusé"
without_continuation: "Sans suite"
sans_suite: "Sans suite"
errors:
models:

View file

@ -18,4 +18,11 @@ namespace :'2017_12_04_translate_dossier_state_to_french' do
task refuse: :environment do
Dossier.unscoped.where(state: 'refused').update_all(state: 'refuse')
end
task sans_suite: :environment do
Dossier.unscoped.where(state: 'without_continuation').update_all(state: 'sans_suite')
end
task all: %i(brouillon en_construction en_instruction accepte refuse sans_suite) do
end
end

View file

@ -260,7 +260,7 @@ describe Backoffice::DossiersController, type: :controller do
it { is_expected.to redirect_to backoffice_dossier_path(id: dossier.id) }
end
context "with without_continuation" do
context "with sans_suite" do
before do
dossier.en_instruction!
sign_in gestionnaire
@ -268,11 +268,11 @@ describe Backoffice::DossiersController, type: :controller do
subject { post :process_dossier, params: { process_action: "without_continuation", dossier_id: dossier_id} }
it 'change state to without_continuation' do
it 'change state to sans_suite' do
subject
dossier.reload
expect(dossier.state).to eq('without_continuation')
expect(dossier.state).to eq('sans_suite')
end
it 'Notification email is sent' do

View file

@ -143,11 +143,11 @@ describe NewGestionnaire::DossiersController, type: :controller do
subject { post :terminer, params: { process_action: "classer_sans_suite", procedure_id: procedure.id, dossier_id: dossier.id} }
it 'change state to without_continuation' do
it 'change state to sans_suite' do
subject
dossier.reload
expect(dossier.state).to eq('without_continuation')
expect(dossier.state).to eq('sans_suite')
end
it 'Notification email is sent' do

View file

@ -139,7 +139,7 @@ describe NewGestionnaire::ProceduresController, type: :controller do
before do
create(:dossier, procedure: procedure, state: "en_construction")
create(:dossier, procedure: procedure, state: "en_instruction")
create(:dossier, procedure: procedure, state: "without_continuation", archived: true)
create(:dossier, procedure: procedure, state: "sans_suite", archived: true)
gestionnaire.procedures << procedure2
create(:dossier, :followed, procedure: procedure2, state: "en_construction")

View file

@ -42,8 +42,8 @@ describe DossierDecorator do
expect(subject).to eq('En instruction')
end
it 'without_continuation is traité' do
dossier.without_continuation!
it 'sans_suite is traité' do
dossier.sans_suite!
expect(subject).to eq('Sans suite')
end

View file

@ -10,7 +10,7 @@ feature 'on click on tabs button' do
create(:dossier, :with_entreprise, user: user, state: 'en_instruction')
create(:dossier, :with_entreprise, user: user, state: 'accepte')
create(:dossier, :with_entreprise, user: user, state: 'refuse')
create(:dossier, :with_entreprise, user: user, state: 'without_continuation')
create(:dossier, :with_entreprise, user: user, state: 'sans_suite')
create :invite, dossier: dossier_invite, user: user

View file

@ -25,7 +25,7 @@ RSpec.describe AutoArchiveProcedureJob, type: :job do
let!(:dossier5) { create(:dossier, procedure: procedure_hier, state: 'en_instruction', archived: false)}
let!(:dossier6) { create(:dossier, procedure: procedure_hier, state: 'accepte', archived: false)}
let!(:dossier7) { create(:dossier, procedure: procedure_hier, state: 'refuse', archived: false)}
let!(:dossier8) { create(:dossier, procedure: procedure_hier, state: 'without_continuation', archived: false)}
let!(:dossier8) { create(:dossier, procedure: procedure_hier, state: 'sans_suite', archived: false)}
let!(:dossier9) { create(:dossier, procedure: procedure_aujourdhui, state: 'en_construction', archived: false)}
before do
@ -46,7 +46,7 @@ RSpec.describe AutoArchiveProcedureJob, type: :job do
it { expect(dossier5.state).to eq 'en_instruction' }
it { expect(dossier6.state).to eq 'accepte' }
it { expect(dossier7.state).to eq 'refuse' }
it { expect(dossier8.state).to eq 'without_continuation' }
it { expect(dossier8.state).to eq 'sans_suite' }
it { expect(dossier9.state).to eq 'en_instruction' }
it { expect(procedure_hier.archivee?).to eq true }

View file

@ -258,9 +258,9 @@ describe Dossier do
end
end
context 'when dossier is at state without_continuation' do
context 'when dossier is at state sans_suite' do
before do
dossier.without_continuation!
dossier.sans_suite!
end
context 'when user is connected' do
@ -269,7 +269,7 @@ describe Dossier do
context 'when he posts a comment' do
let(:action) { 'comment' }
it { is_expected.to eq('without_continuation') }
it { is_expected.to eq('sans_suite') }
end
end
@ -279,7 +279,7 @@ describe Dossier do
context 'when he posts a comment' do
let(:action) { 'comment' }
it { is_expected.to eq('without_continuation') }
it { is_expected.to eq('sans_suite') }
end
end
end
@ -751,10 +751,10 @@ describe Dossier do
it_behaves_like 'dossier is processed', 'refuse'
end
context 'when dossier is without_continuation' do
context 'when dossier is sans_suite' do
let(:state) { 'en_instruction' }
it_behaves_like 'dossier is processed', 'without_continuation'
it_behaves_like 'dossier is processed', 'sans_suite'
end
end
@ -809,7 +809,7 @@ describe Dossier do
expect { Dossier.create(procedure: procedure, state: "en_instruction", user: user) }.not_to change(ActionMailer::Base.deliveries, :size)
expect { Dossier.create(procedure: procedure, state: "accepte", user: user) }.not_to change(ActionMailer::Base.deliveries, :size)
expect { Dossier.create(procedure: procedure, state: "refuse", user: user) }.not_to change(ActionMailer::Base.deliveries, :size)
expect { Dossier.create(procedure: procedure, state: "without_continuation", user: user) }.not_to change(ActionMailer::Base.deliveries, :size)
expect { Dossier.create(procedure: procedure, state: "sans_suite", user: user) }.not_to change(ActionMailer::Base.deliveries, :size)
end
end

View file

@ -27,5 +27,11 @@ describe DossierSerializer do
it { is_expected.to include(state: 'refused') }
end
context 'when the dossier is sans_suite' do
let(:dossier) { create(:dossier, state: :sans_suite) }
it { is_expected.to include(state: 'without_continuation') }
end
end
end

View file

@ -29,6 +29,12 @@ describe DossierTableExportSerializer do
it { is_expected.to include(state: 'refused') }
end
context 'when the dossier is sans_suite' do
let(:dossier) { create(:dossier, state: :sans_suite) }
it { is_expected.to include(state: 'without_continuation') }
end
end
describe '#emails_accompagnateurs' do

View file

@ -352,7 +352,7 @@ describe DossiersListGestionnaireService do
let!(:dossier7) { create(:dossier, procedure: procedure, state: 'en_instruction') } #a_instruire
let!(:dossier8) { create(:dossier, procedure: procedure, state: 'accepte') } #termine
let!(:dossier9) { create(:dossier, procedure: procedure, state: 'refuse') } #termine
let!(:dossier10) { create(:dossier, procedure: procedure, state: 'without_continuation') } #termine
let!(:dossier10) { create(:dossier, procedure: procedure, state: 'sans_suite') } #termine
let!(:dossier11) { create(:dossier, procedure: procedure, state: 'accepte') } #termine
let!(:dossier12) { create(:dossier, procedure: procedure, state: 'en_construction', archived: true) } #a_traiter #archived
let!(:dossier14) { create(:dossier, procedure: procedure, state: 'accepte', archived: true) } #termine #archived

View file

@ -10,7 +10,7 @@ describe 'backoffice/dossiers/index.html.haml', type: :view do
let!(:decorate_dossier_en_instruction) { create(:dossier, :with_entreprise, procedure: procedure, state: 'en_instruction').decorate }
let!(:decorate_dossier_accepte) { create(:dossier, :with_entreprise, procedure: procedure, state: 'accepte').decorate }
let!(:decorate_dossier_refuse) { create(:dossier, :with_entreprise, procedure: procedure, state: 'refuse').decorate }
let!(:decorate_dossier_without_continuation) { create(:dossier, :with_entreprise, procedure: procedure, state: 'without_continuation').decorate }
let!(:decorate_dossier_sans_suite) { create(:dossier, :with_entreprise, procedure: procedure, state: 'sans_suite').decorate }
let(:dossiers_list_facade) { DossiersListFacades.new gestionnaire, nil }
@ -22,7 +22,7 @@ describe 'backoffice/dossiers/index.html.haml', type: :view do
decorate_dossier_en_instruction.entreprise.update_column(:raison_sociale, 'plup')
decorate_dossier_accepte.entreprise.update_column(:raison_sociale, 'plyp')
decorate_dossier_refuse.entreprise.update_column(:raison_sociale, 'plzp')
decorate_dossier_without_continuation.entreprise.update_column(:raison_sociale, 'plnp')
decorate_dossier_sans_suite.entreprise.update_column(:raison_sociale, 'plnp')
create :preference_list_dossier,
gestionnaire: gestionnaire,

View file

@ -72,8 +72,8 @@ describe 'layouts/left_panels/_left_panel_backoffice_dossierscontroller_show.htm
end
end
context 'when dossier have state without_continuation' do
let(:state) { 'without_continuation' }
context 'when dossier have state sans_suite' do
let(:state) { 'sans_suite' }
before do
render

View file

@ -48,8 +48,8 @@ describe 'layouts/left_panels/_left_panel_users_recapitulatifcontroller_show.htm
end
end
context 'when dossier state is without_continuation' do
let(:state) { 'without_continuation' }
context 'when dossier state is sans_suite' do
let(:state) { 'sans_suite' }
before do
render

View file

@ -7,7 +7,7 @@ describe 'users/dossiers/index.html.haml', type: :view do
let!(:decorate_dossier_en_instruction) { create(:dossier, :with_entreprise, user: user, state: 'en_instruction').decorate }
let!(:decorate_dossier_accepte) { create(:dossier, :with_entreprise, user: user, state: 'accepte').decorate }
let!(:decorate_dossier_refuse) { create(:dossier, :with_entreprise, user: user, state: 'refuse').decorate }
let!(:decorate_dossier_without_continuation) { create(:dossier, :with_entreprise, user: user, state: 'without_continuation').decorate }
let!(:decorate_dossier_sans_suite) { create(:dossier, :with_entreprise, user: user, state: 'sans_suite').decorate }
let!(:decorate_dossier_invite) { create(:dossier, :with_entreprise, user: create(:user), state: 'en_construction').decorate }
before do
@ -75,7 +75,7 @@ describe 'users/dossiers/index.html.haml', type: :view do
end
it_behaves_like 'check_tab_content' do
let(:decorate_dossier_at_check) { decorate_dossier_without_continuation }
let(:decorate_dossier_at_check) { decorate_dossier_sans_suite }
end
end