Merge pull request #7720 from betagouv/improve_perf_on_brouillon_save

perf(dossier): limite la verification des lignes aux seuls champs enfants
This commit is contained in:
Paul Chavard 2022-09-07 15:11:02 +02:00 committed by GitHub
commit 5a18e0e03d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 0 additions and 12 deletions

View file

@ -78,8 +78,6 @@ class Champ < ApplicationRecord
before_save :normalize before_save :normalize
after_update_commit :fetch_external_data_later after_update_commit :fetch_external_data_later
validates :type_de_champ_id, uniqueness: { scope: [:dossier_id, :row] }
def public? def public?
!private? !private?
end end

View file

@ -16,16 +16,6 @@ describe Champ do
end end
end end
describe "validations" do
let(:row) { 1 }
let(:champ) { create(:champ, type_de_champ: create(:type_de_champ), row: row) }
let(:champ2) { build(:champ, type_de_champ: champ.type_de_champ, row: champ.row, dossier: champ.dossier) }
it "returns false when champ with same type_de_champ and row already exist" do
expect(champ2).not_to be_valid
end
end
describe "normalization" do describe "normalization" do
it "should remove null bytes before save" do it "should remove null bytes before save" do
champ = create(:champ, value: "foo\u0000bar") champ = create(:champ, value: "foo\u0000bar")