[fix #504] Dossier: refused -> refuse

This commit is contained in:
Simon Lehericey 2017-12-04 18:15:40 +01:00 committed by LeSim
parent a13256f73d
commit 2be9b8d2ba
21 changed files with 55 additions and 35 deletions

View file

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

View file

@ -4,8 +4,8 @@ module DossierHelper
'accepted'
elsif dossier.without_continuation?
'without-continuation'
elsif dossier.refused?
'refused'
elsif dossier.refuse?
'refuse'
end
end

View file

@ -4,7 +4,7 @@ class Dossier < ActiveRecord::Base
en_construction: 'en_construction',
en_instruction: 'en_instruction',
accepte: 'accepte',
refused: 'refused',
refuse: 'refuse',
without_continuation: 'without_continuation'
}
@ -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 refused without_continuation)
TERMINE = %w(accepte refuse without_continuation)
has_one :etablissement, dependent: :destroy
has_one :entreprise, dependent: :destroy
@ -177,7 +177,7 @@ class Dossier < ActiveRecord::Base
end
when 'refuse'
if en_instruction?
refused!
refuse!
if motivation
self.motivation = motivation
@ -283,7 +283,7 @@ class Dossier < ActiveRecord::Base
end
def read_only?
en_instruction? || accepte? || refused? || without_continuation?
en_instruction? || accepte? || refuse? || without_continuation?
end
def owner? email
@ -368,7 +368,7 @@ class Dossier < ActiveRecord::Base
'accepté'
elsif without_continuation?
'classé sans suite'
elsif refused?
elsif refuse?
'refusé'
end
end

View file

@ -43,6 +43,8 @@ class DossierSerializer < ActiveModel::Serializer
'received'
when 'accepte'
'closed'
when 'refuse'
'refused'
else
object.state
end

View file

@ -30,6 +30,8 @@ class DossierTableExportSerializer < ActiveModel::Serializer
'received'
when 'accepte'
'closed'
when 'refuse'
'refused'
else
object.state
end

View file

@ -4,7 +4,7 @@
%span.label.construction en construction
- elsif dossier.accepte?
%span.label.accepted accepté
- elsif dossier.refused?
- elsif dossier.refuse?
%span.label.refused refusé
- elsif dossier.without_continuation?
%span.label.without-continuation sans suite

View file

@ -12,7 +12,7 @@ fr:
en_construction: "En construction"
en_instruction: "En instruction"
accepte: "Accepté"
refused: "Refusé"
refuse: "Refusé"
without_continuation: "Sans suite"
errors:

View file

@ -14,4 +14,8 @@ namespace :'2017_12_04_translate_dossier_state_to_french' do
task accepte: :environment do
Dossier.unscoped.where(state: 'closed').update_all(state: 'accepte')
end
task refuse: :environment do
Dossier.unscoped.where(state: 'refused').update_all(state: 'refuse')
end
end

View file

@ -242,11 +242,11 @@ describe Backoffice::DossiersController, type: :controller do
subject { post :process_dossier, params: { process_action: "refuse", dossier_id: dossier_id} }
it 'change state to refused' do
it 'change state to refuse' do
subject
dossier.reload
expect(dossier.state).to eq('refused')
expect(dossier.state).to eq('refuse')
end
it 'Notification email is sent' do

View file

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

View file

@ -47,8 +47,8 @@ describe DossierDecorator do
expect(subject).to eq('Sans suite')
end
it 'refused is traité' do
dossier.refused!
it 'refuse is traité' do
dossier.refuse!
expect(subject).to eq('Refusé')
end
end

View file

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

View file

@ -24,7 +24,7 @@ RSpec.describe AutoArchiveProcedureJob, type: :job do
let!(:dossier4) { create(:dossier, procedure: procedure_hier, state: 'en_construction', archived: false)}
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: 'refused', 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!(:dossier9) { create(:dossier, procedure: procedure_aujourdhui, state: 'en_construction', archived: false)}
@ -45,7 +45,7 @@ RSpec.describe AutoArchiveProcedureJob, type: :job do
it { expect(dossier4.state).to eq 'en_instruction' }
it { expect(dossier5.state).to eq 'en_instruction' }
it { expect(dossier6.state).to eq 'accepte' }
it { expect(dossier7.state).to eq 'refused' }
it { expect(dossier7.state).to eq 'refuse' }
it { expect(dossier8.state).to eq 'without_continuation' }
it { expect(dossier9.state).to eq 'en_instruction' }

View file

@ -232,9 +232,9 @@ describe Dossier do
end
end
context 'when dossier is at state refused' do
context 'when dossier is at state refuse' do
before do
dossier.refused!
dossier.refuse!
end
context 'when user is connected' do
@ -243,7 +243,7 @@ describe Dossier do
context 'when he posts a comment' do
let(:action) { 'comment' }
it { is_expected.to eq('refused') }
it { is_expected.to eq('refuse') }
end
end
@ -253,7 +253,7 @@ describe Dossier do
context 'when he posts a comment' do
let(:action) { 'comment' }
it { is_expected.to eq('refused') }
it { is_expected.to eq('refuse') }
end
end
end
@ -745,10 +745,10 @@ describe Dossier do
it_behaves_like 'dossier is processed', 'accepte'
end
context 'when dossier is refused' do
context 'when dossier is refuse' do
let(:state) { 'en_instruction' }
it_behaves_like 'dossier is processed', 'refused'
it_behaves_like 'dossier is processed', 'refuse'
end
context 'when dossier is without_continuation' do
@ -808,7 +808,7 @@ describe Dossier do
expect { Dossier.create(procedure: procedure, state: "en_construction", user: user) }.not_to change(ActionMailer::Base.deliveries, :size)
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: "refused", 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)
end
end

View file

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

View file

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

View file

@ -351,7 +351,7 @@ describe DossiersListGestionnaireService do
let!(:dossier6) { create(:dossier, procedure: procedure, state: 'en_instruction') } #a_instruire
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: 'refused') } #termine
let!(:dossier9) { create(:dossier, procedure: procedure, state: 'refuse') } #termine
let!(:dossier10) { create(:dossier, procedure: procedure, state: 'without_continuation') } #termine
let!(:dossier11) { create(:dossier, procedure: procedure, state: 'accepte') } #termine
let!(:dossier12) { create(:dossier, procedure: procedure, state: 'en_construction', archived: true) } #a_traiter #archived

View file

@ -9,7 +9,7 @@ describe 'backoffice/dossiers/index.html.haml', type: :view do
let!(:decorate_dossier_en_construction) { create(:dossier, :with_entreprise, procedure: procedure, state: 'en_construction').decorate }
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_refused) { create(:dossier, :with_entreprise, procedure: procedure, state: 'refused').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(:dossiers_list_facade) { DossiersListFacades.new gestionnaire, nil }
@ -21,7 +21,7 @@ describe 'backoffice/dossiers/index.html.haml', type: :view do
before do
decorate_dossier_en_instruction.entreprise.update_column(:raison_sociale, 'plup')
decorate_dossier_accepte.entreprise.update_column(:raison_sociale, 'plyp')
decorate_dossier_refused.entreprise.update_column(:raison_sociale, 'plzp')
decorate_dossier_refuse.entreprise.update_column(:raison_sociale, 'plzp')
decorate_dossier_without_continuation.entreprise.update_column(:raison_sociale, 'plnp')
create :preference_list_dossier,

View file

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

View file

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

View file

@ -6,7 +6,7 @@ describe 'users/dossiers/index.html.haml', type: :view do
let!(:decorate_dossier_en_construction) { create(:dossier, :with_entreprise, user: user, state: 'en_construction').decorate }
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_refused) { create(:dossier, :with_entreprise, user: user, state: 'refused').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_invite) { create(:dossier, :with_entreprise, user: create(:user), state: 'en_construction').decorate }
@ -71,7 +71,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_refused }
let(:decorate_dossier_at_check) { decorate_dossier_refuse }
end
it_behaves_like 'check_tab_content' do