Do not raise exception when Avis is not valid, just fix the data
This commit is contained in:
parent
7932085976
commit
5a0eca5ccc
2 changed files with 20 additions and 1 deletions
|
@ -20,7 +20,7 @@ module Maintenance
|
||||||
expert: expert
|
expert: expert
|
||||||
)
|
)
|
||||||
|
|
||||||
avis.update!(experts_procedure: correct_experts_procedure)
|
avis.update_column(:experts_procedure_id, correct_experts_procedure.id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -78,6 +78,25 @@ module Maintenance
|
||||||
expect(avis.experts_procedure).to eq(correct_experts_procedure)
|
expect(avis.experts_procedure).to eq(correct_experts_procedure)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "when the avis has an invalid question_answer" do
|
||||||
|
let(:avis) do
|
||||||
|
create(:avis,
|
||||||
|
dossier: dossier,
|
||||||
|
expert: expert,
|
||||||
|
experts_procedure: wrong_experts_procedure,
|
||||||
|
question_label: "Some question",
|
||||||
|
question_answer: nil)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "fixes the experts_procedure association without validation errors" do
|
||||||
|
expect(avis).not_to be_valid
|
||||||
|
expect { process }.not_to raise_error
|
||||||
|
|
||||||
|
avis.reload
|
||||||
|
expect(avis.experts_procedure.procedure_id).to eq(procedure2.id)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue