2016-06-14 11:59:50 +02:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe PrevisualisationService do
|
2017-08-29 12:20:28 +02:00
|
|
|
describe '.delete_all_champs' do
|
|
|
|
subject { described_class.delete_all_champs dossier }
|
2016-06-14 11:59:50 +02:00
|
|
|
|
|
|
|
let(:procedure_1) { create :procedure, :with_type_de_champ }
|
|
|
|
let(:procedure_2) { create :procedure, :with_type_de_champ }
|
|
|
|
|
|
|
|
let!(:dossier_1) { create :dossier, procedure: procedure_1 }
|
|
|
|
let!(:dossier_2) { create :dossier, procedure: procedure_2 }
|
|
|
|
|
|
|
|
it { expect(Dossier.all.size).to eq 2 }
|
|
|
|
it { expect(TypeDeChamp.all.size).to eq 2 }
|
|
|
|
it { expect(Champ.all.size).to eq 2 }
|
|
|
|
|
2017-08-29 12:20:28 +02:00
|
|
|
context 'when function delete_all_champs is call' do
|
2016-06-14 11:59:50 +02:00
|
|
|
let(:dossier) { dossier_1 }
|
|
|
|
|
|
|
|
before do
|
|
|
|
subject
|
|
|
|
end
|
|
|
|
|
|
|
|
it { expect(Dossier.all.size).to eq 2 }
|
|
|
|
it { expect(TypeDeChamp.all.size).to eq 2 }
|
|
|
|
it { expect(Champ.all.size).to eq 1 }
|
|
|
|
it { expect(Champ.first.type_de_champ).to eq procedure_2.types_de_champ.first }
|
|
|
|
end
|
|
|
|
end
|
2017-04-04 15:27:04 +02:00
|
|
|
end
|