refactor spec

This commit is contained in:
simon lehericey 2022-05-02 10:48:05 +02:00
parent 37e01ea399
commit 96eec7e566

View file

@ -5,7 +5,7 @@ describe ProcedurePresentation do
context 'for a draft procedure' do
let(:procedure) { create(:procedure) }
context 'when there are one tdc on a published revision' do
context 'when there are one tdc on a draft revision' do
let!(:tdc) { { type_champ: :number, libelle: 'libelle 1' } }
before { procedure.draft_revision.add_type_de_champ(tdc) }
@ -37,26 +37,26 @@ describe ProcedurePresentation do
end
context 'add one tdc above the first one' do
let(:tdc2) { { type_champ: :number, libelle: 'libelle 2' } }
let(:tdc0) { { type_champ: :number, libelle: 'libelle 0' } }
before do
created_tdc2 = procedure.draft_revision.add_type_de_champ(tdc2)
procedure.draft_revision.move_type_de_champ(created_tdc2.stable_id, 0)
created_tdc0 = procedure.draft_revision.add_type_de_champ(tdc0)
procedure.draft_revision.move_type_de_champ(created_tdc0.stable_id, 0)
procedure.publish_revision!
end
it { is_expected.to match(['libelle 2', 'libelle 1']) }
it { is_expected.to match(['libelle 0', 'libelle 1']) }
context 'and finally, when this tdc is removed' do
let!(:previous_tdc2) { procedure.published_revision.types_de_champ_public.find_by(libelle: 'libelle 2') }
let!(:previous_tdc0) { procedure.published_revision.types_de_champ_public.find_by(libelle: 'libelle 0') }
before do
procedure.draft_revision.remove_type_de_champ(previous_tdc2.stable_id)
procedure.draft_revision.remove_type_de_champ(previous_tdc0.stable_id)
procedure.publish_revision!
end
it { is_expected.to match(['libelle 1', 'libelle 2']) }
it { is_expected.to match(['libelle 1', 'libelle 0']) }
end
end