Add dossier_legacy_state helper
This commit is contained in:
parent
a524c72add
commit
0fe59a7c65
2 changed files with 51 additions and 0 deletions
|
@ -31,4 +31,21 @@ module DossierHelper
|
||||||
state = I18n.t(dossier.state, scope: [:activerecord, :attributes, :dossier, :state])
|
state = I18n.t(dossier.state, scope: [:activerecord, :attributes, :dossier, :state])
|
||||||
lower ? state.downcase : state
|
lower ? state.downcase : state
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def dossier_legacy_state(dossier)
|
||||||
|
case dossier.state
|
||||||
|
when Dossier.states.fetch(:en_construction)
|
||||||
|
'initiated'
|
||||||
|
when Dossier.states.fetch(:en_instruction)
|
||||||
|
'received'
|
||||||
|
when Dossier.states.fetch(:accepte)
|
||||||
|
'closed'
|
||||||
|
when Dossier.states.fetch(:refuse)
|
||||||
|
'refused'
|
||||||
|
when Dossier.states.fetch(:sans_suite)
|
||||||
|
'without_continuation'
|
||||||
|
else
|
||||||
|
dossier.state
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -166,4 +166,38 @@ RSpec.describe DossierHelper, type: :helper do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe '.dossier_legacy_state' do
|
||||||
|
subject { dossier_legacy_state(dossier) }
|
||||||
|
|
||||||
|
context 'when the dossier is en instruction' do
|
||||||
|
let(:dossier) { create(:dossier) }
|
||||||
|
|
||||||
|
it { is_expected.to eq('brouillon') }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when the dossier is en instruction' do
|
||||||
|
let(:dossier) { create(:dossier, :en_instruction) }
|
||||||
|
|
||||||
|
it { is_expected.to eq('received') }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when the dossier is accepte' do
|
||||||
|
let(:dossier) { create(:dossier, state: Dossier.states.fetch(:accepte)) }
|
||||||
|
|
||||||
|
it { is_expected.to eq('closed') }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when the dossier is refuse' do
|
||||||
|
let(:dossier) { create(:dossier, state: Dossier.states.fetch(:refuse)) }
|
||||||
|
|
||||||
|
it { is_expected.to eq('refused') }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when the dossier is sans_suite' do
|
||||||
|
let(:dossier) { create(:dossier, state: Dossier.states.fetch(:sans_suite)) }
|
||||||
|
|
||||||
|
it { is_expected.to eq('without_continuation') }
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue