From ee56a7da21ff68be8c9bb16705e03adf84ebcf79 Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Tue, 2 Apr 2024 15:11:09 +0200 Subject: [PATCH 1/2] refactor(champ): remove stable_id delegate to type_de_champ --- app/models/champ.rb | 1 - spec/models/champs/carte_champ_spec.rb | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/app/models/champ.rb b/app/models/champ.rb index fc81892ce..c8de9dd48 100644 --- a/app/models/champ.rb +++ b/app/models/champ.rb @@ -50,7 +50,6 @@ class Champ < ApplicationRecord :siret?, :carte?, :datetime?, - :stable_id, :mandatory?, :prefillable?, :refresh_after_update?, diff --git a/spec/models/champs/carte_champ_spec.rb b/spec/models/champs/carte_champ_spec.rb index c7e4e5c99..71c2c3ff8 100644 --- a/spec/models/champs/carte_champ_spec.rb +++ b/spec/models/champs/carte_champ_spec.rb @@ -21,7 +21,7 @@ describe Champs::CarteChamp do let(:feature_collection) { { type: 'FeatureCollection', - id: champ.type_de_champ.stable_id, + id: champ.stable_id, bbox: champ.bounding_box, features: features } From 08e127c12048d2b025a6c48f370782153293204b Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Mon, 15 Apr 2024 17:59:44 +0200 Subject: [PATCH 2/2] chore(spec): remove test for old unused behaviour --- spec/models/champ_spec.rb | 35 ----------------------------------- 1 file changed, 35 deletions(-) diff --git a/spec/models/champ_spec.rb b/spec/models/champ_spec.rb index 355d75761..a23d4be63 100644 --- a/spec/models/champ_spec.rb +++ b/spec/models/champ_spec.rb @@ -496,41 +496,6 @@ describe Champ do expect(champ_text_row_1.dossier_id).to eq(champ.dossier_id) end end - - context 'when updating using nested attributes' do - subject do - dossier.update!(champs_public_attributes: [ - { - id: champ.id, - champs_attributes: [champ_text_attrs] - } - ]) - champ.reload - dossier.reload - end - - it 'associates nested champs to the parent dossier' do - subject - - expect(dossier.champs_public.size).to eq(2) - expect(champ.rows.size).to eq(2) - second_row = champ.reload.rows.second - expect(second_row.size).to eq(1) - expect(second_row.first.dossier).to eq(dossier) - - champ.champs << champ_integer - first_row = champ.reload.rows.first - expect(first_row.size).to eq(2) - expect(first_row.second).to eq(champ_integer) - - champ.champs << champ_text - first_row = champ.reload.rows.first - expect(first_row.size).to eq(2) - expect(first_row.first).to eq(champ_text) - - expect(champ.rows.size).to eq(2) - end - end end describe '#log_fetch_external_data_exception' do