task(dossier): remove orphan champs
This commit is contained in:
parent
adfc4f8cdd
commit
e9d0ccbdf9
2 changed files with 56 additions and 0 deletions
|
@ -0,0 +1,22 @@
|
|||
describe '20220705164551_remove_unused_champs' do
|
||||
let(:rake_task) { Rake::Task['after_party:remove_unused_champs'] }
|
||||
let(:procedure) { create(:procedure, :with_all_champs) }
|
||||
let(:dossier) { create(:dossier, :with_populated_champs, procedure: procedure) }
|
||||
let(:champ_repetition) { dossier.champs.find(&:repetition?) }
|
||||
|
||||
subject(:run_task) do
|
||||
dossier
|
||||
rake_task.invoke
|
||||
end
|
||||
|
||||
before { champ_repetition.champs.first.update(type_de_champ: create(:type_de_champ)) }
|
||||
after { rake_task.reenable }
|
||||
|
||||
describe 'remove_unused_champs' do
|
||||
it "with bad champs" do
|
||||
expect(Champ.where(dossier: dossier).count).to eq(39)
|
||||
run_task
|
||||
expect(Champ.where(dossier: dossier).count).to eq(38)
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue