diff --git a/spec/components/dossiers/en_construction_not_submitted_component_spec.rb b/spec/components/dossiers/en_construction_not_submitted_component_spec.rb
index c05377d6b..73122cf9d 100644
--- a/spec/components/dossiers/en_construction_not_submitted_component_spec.rb
+++ b/spec/components/dossiers/en_construction_not_submitted_component_spec.rb
@@ -21,7 +21,7 @@ RSpec.describe Dossiers::EnConstructionNotSubmittedComponent, type: :component d
end
context "with changes" do
- before { fork.champs_public.first.update(value: "new value") }
+ before { fork.project_champs_public.first.update(value: "new value") }
it "inform user" do
expect(subject).to include("Des modifications n’ont pas encore été déposées")
diff --git a/spec/components/editable_champ/section_component_spec.rb b/spec/components/editable_champ/section_component_spec.rb
index cd821c247..d3398c0be 100644
--- a/spec/components/editable_champ/section_component_spec.rb
+++ b/spec/components/editable_champ/section_component_spec.rb
@@ -113,7 +113,7 @@ describe EditableChamp::SectionComponent, type: :component do
end
it 'contains as many text champ as repetition.rows' do
- expect(page).to have_selector("fieldset fieldset input[type=text]", count: dossier.champs_public.find(&:repetition?).rows.size)
+ expect(page).to have_selector("fieldset fieldset input[type=text]", count: dossier.project_champs_public.find(&:repetition?).rows.size)
end
end
diff --git a/spec/controllers/api/v2/graphql_controller_spec.rb b/spec/controllers/api/v2/graphql_controller_spec.rb
index 35fbdbe18..6ceef733d 100644
--- a/spec/controllers/api/v2/graphql_controller_spec.rb
+++ b/spec/controllers/api/v2/graphql_controller_spec.rb
@@ -515,7 +515,7 @@ describe API::V2::GraphqlController do
avis: []
)
- expected_champs = dossier.champs_public.map do |champ|
+ expected_champs = dossier.project_champs_public.map do |champ|
{
id: champ.to_typed_id,
label: champ.libelle,
@@ -546,7 +546,7 @@ describe API::V2::GraphqlController do
end
expect(gql_data[:dossier][:messages]).to match_array(expected_messages)
- expect(gql_data[:dossier][:champs][0][:id]).to eq(dossier.champs_public[0].type_de_champ.to_typed_id)
+ expect(gql_data[:dossier][:champs][0][:id]).to eq(dossier.project_champs_public[0].type_de_champ.to_typed_id)
end
end
@@ -687,8 +687,8 @@ describe API::V2::GraphqlController do
context "champs" do
let(:procedure) { create(:procedure, :published, :for_individual, administrateurs: [admin], types_de_champ_public: [{ type: :date }, { type: :datetime }]) }
let(:dossier) { create(:dossier, :en_construction, procedure: procedure) }
- let(:champ_date) { dossier.champs_public.first }
- let(:champ_datetime) { dossier.champs_public.second }
+ let(:champ_date) { dossier.project_champs_public.first }
+ let(:champ_datetime) { dossier.project_champs_public.second }
before do
champ_date.update(value: '2019-07-10')
@@ -1243,7 +1243,7 @@ describe API::V2::GraphqlController do
"mutation {
dossierModifierAnnotationText(input: {
dossierId: \"#{dossier.to_typed_id}\",
- annotationId: \"#{dossier.champs_private.find { |c| c.type == 'Champs::TextChamp' }.to_typed_id}\",
+ annotationId: \"#{dossier.project_champs_private.find { |c| c.type == 'Champs::TextChamp' }.to_typed_id}\",
instructeurId: \"#{instructeur.to_typed_id}\",
value: \"hello\"
}) {
@@ -1280,7 +1280,7 @@ describe API::V2::GraphqlController do
"mutation {
dossierModifierAnnotationCheckbox(input: {
dossierId: \"#{dossier.to_typed_id}\",
- annotationId: \"#{dossier.champs_private.find { |c| c.type_champ == 'checkbox' }.to_typed_id}\",
+ annotationId: \"#{dossier.project_champs_private.find { |c| c.type_champ == 'checkbox' }.to_typed_id}\",
instructeurId: \"#{instructeur.to_typed_id}\",
value: #{value}
}) {
@@ -1331,7 +1331,7 @@ describe API::V2::GraphqlController do
"mutation {
dossierModifierAnnotationCheckbox(input: {
dossierId: \"#{dossier.to_typed_id}\",
- annotationId: \"#{dossier.champs_private.find { |c| c.type_champ == 'yes_no' }.to_typed_id}\",
+ annotationId: \"#{dossier.project_champs_private.find { |c| c.type_champ == 'yes_no' }.to_typed_id}\",
instructeurId: \"#{instructeur.to_typed_id}\",
value: #{value}
}) {
@@ -1381,7 +1381,7 @@ describe API::V2::GraphqlController do
"mutation {
dossierModifierAnnotationDate(input: {
dossierId: \"#{dossier.to_typed_id}\",
- annotationId: \"#{dossier.champs_private.find { |c| c.type_champ == 'date' }.to_typed_id}\",
+ annotationId: \"#{dossier.project_champs_private.find { |c| c.type_champ == 'date' }.to_typed_id}\",
instructeurId: \"#{instructeur.to_typed_id}\",
value: \"#{1.day.from_now.to_date.iso8601}\"
}) {
@@ -1401,7 +1401,7 @@ describe API::V2::GraphqlController do
expect(gql_data).to eq(dossierModifierAnnotationDate: {
annotation: {
- stringValue: dossier.reload.champs_private.find { |c| c.type_champ == 'date' }.to_s
+ stringValue: dossier.reload.project_champs_private.find { |c| c.type_champ == 'date' }.to_s
},
errors: nil
})
@@ -1416,7 +1416,7 @@ describe API::V2::GraphqlController do
"mutation {
dossierModifierAnnotationDatetime(input: {
dossierId: \"#{dossier.to_typed_id}\",
- annotationId: \"#{dossier.champs_private.find { |c| c.type_champ == 'datetime' }.to_typed_id}\",
+ annotationId: \"#{dossier.project_champs_private.find { |c| c.type_champ == 'datetime' }.to_typed_id}\",
instructeurId: \"#{instructeur.to_typed_id}\",
value: \"#{1.day.from_now.iso8601}\"
}) {
@@ -1436,7 +1436,7 @@ describe API::V2::GraphqlController do
expect(gql_data).to eq(dossierModifierAnnotationDatetime: {
annotation: {
- stringValue: dossier.reload.champs_private.find { |c| c.type_champ == 'datetime' }.to_s
+ stringValue: dossier.reload.project_champs_private.find { |c| c.type_champ == 'datetime' }.to_s
},
errors: nil
})
@@ -1451,7 +1451,7 @@ describe API::V2::GraphqlController do
"mutation {
dossierModifierAnnotationDropDownList(input: {
dossierId: \"#{dossier.to_typed_id}\",
- annotationId: \"#{dossier.champs_private.find { |c| c.type_champ == 'drop_down_list' }.to_typed_id}\",
+ annotationId: \"#{dossier.project_champs_private.find { |c| c.type_champ == 'drop_down_list' }.to_typed_id}\",
instructeurId: \"#{instructeur.to_typed_id}\",
value: \"#{value}\"
}) {
@@ -1472,7 +1472,7 @@ describe API::V2::GraphqlController do
expect(gql_data).to eq(dossierModifierAnnotationDropDownList: {
annotation: {
- stringValue: dossier.reload.champs_private.find { |c| c.type_champ == 'drop_down_list' }.to_s
+ stringValue: dossier.reload.project_champs_private.find { |c| c.type_champ == 'drop_down_list' }.to_s
},
errors: nil
})
@@ -1497,7 +1497,7 @@ describe API::V2::GraphqlController do
"mutation {
dossierModifierAnnotationIntegerNumber(input: {
dossierId: \"#{dossier.to_typed_id}\",
- annotationId: \"#{dossier.champs_private.find { |c| c.type_champ == 'integer_number' }.to_typed_id}\",
+ annotationId: \"#{dossier.project_champs_private.find { |c| c.type_champ == 'integer_number' }.to_typed_id}\",
instructeurId: \"#{instructeur.to_typed_id}\",
value: 42
}) {
diff --git a/spec/controllers/champs/piece_justificative_controller_spec.rb b/spec/controllers/champs/piece_justificative_controller_spec.rb
index fb3f4b905..90a43aba6 100644
--- a/spec/controllers/champs/piece_justificative_controller_spec.rb
+++ b/spec/controllers/champs/piece_justificative_controller_spec.rb
@@ -4,7 +4,7 @@ describe Champs::PieceJustificativeController, type: :controller do
let(:user) { create(:user) }
let(:procedure) { create(:procedure, :published, types_de_champ_public: [{ type: :piece_justificative }]) }
let(:dossier) { create(:dossier, user: user, procedure: procedure) }
- let(:champ) { dossier.champs_public.first }
+ let(:champ) { dossier.project_champs_public.first }
describe '#update' do
render_views
diff --git a/spec/controllers/champs/rna_controller_spec.rb b/spec/controllers/champs/rna_controller_spec.rb
index 67fead4fb..a4a09377b 100644
--- a/spec/controllers/champs/rna_controller_spec.rb
+++ b/spec/controllers/champs/rna_controller_spec.rb
@@ -6,7 +6,7 @@ describe Champs::RNAController, type: :controller do
describe '#show' do
let(:dossier) { create(:dossier, user: user, procedure: procedure) }
- let(:champ) { dossier.champs_public.first }
+ let(:champ) { dossier.project_champs_public.first }
let(:champs_public_attributes) do
champ_attributes = {}
diff --git a/spec/controllers/champs/siret_controller_spec.rb b/spec/controllers/champs/siret_controller_spec.rb
index c0b134955..fdd483ac1 100644
--- a/spec/controllers/champs/siret_controller_spec.rb
+++ b/spec/controllers/champs/siret_controller_spec.rb
@@ -6,7 +6,7 @@ describe Champs::SiretController, type: :controller do
describe '#show' do
let(:dossier) { create(:dossier, user: user, procedure: procedure) }
- let(:champ) { dossier.champs_public.first }
+ let(:champ) { dossier.project_champs_public.first }
let(:champs_public_attributes) do
champ_attributes = {}
diff --git a/spec/controllers/experts/avis_controller_spec.rb b/spec/controllers/experts/avis_controller_spec.rb
index f1435d431..ed84e994f 100644
--- a/spec/controllers/experts/avis_controller_spec.rb
+++ b/spec/controllers/experts/avis_controller_spec.rb
@@ -483,7 +483,7 @@ describe Experts::AvisController, type: :controller do
context 'when the expert also shares the linked dossiers' do
context 'and the expert can access the linked dossiers' do
let(:created_avis) { create(:avis, dossier: dossier, claimant: claimant, email: "toto3@gmail.com") }
- let(:linked_dossier) { Dossier.find_by(id: dossier.reload.champs_public.filter(&:dossier_link?).filter_map(&:value)) }
+ let(:linked_dossier) { Dossier.find_by(id: dossier.reload.project_champs_public.filter(&:dossier_link?).filter_map(&:value)) }
let(:linked_avis) { create(:avis, dossier: linked_dossier, claimant: claimant) }
let(:invite_linked_dossiers) { true }
diff --git a/spec/controllers/instructeurs/dossiers_controller_spec.rb b/spec/controllers/instructeurs/dossiers_controller_spec.rb
index c9227d2ed..ee8053be5 100644
--- a/spec/controllers/instructeurs/dossiers_controller_spec.rb
+++ b/spec/controllers/instructeurs/dossiers_controller_spec.rb
@@ -978,11 +978,11 @@ describe Instructeurs::DossiersController, type: :controller do
let(:another_instructeur) { create(:instructeur) }
let(:now) { Time.zone.parse('01/01/2100') }
- let(:champ_multiple_drop_down_list) { dossier.champs_private.first }
- let(:champ_linked_drop_down_list) { dossier.champs_private.second }
- let(:champ_datetime) { dossier.champs_private.third }
- let(:champ_repetition) { dossier.champs_private.fourth }
- let(:champ_drop_down_list) { dossier.champs_private.fifth }
+ let(:champ_multiple_drop_down_list) { dossier.project_champs_private.first }
+ let(:champ_linked_drop_down_list) { dossier.project_champs_private.second }
+ let(:champ_datetime) { dossier.project_champs_private.third }
+ let(:champ_repetition) { dossier.project_champs_private.fourth }
+ let(:champ_drop_down_list) { dossier.project_champs_private.fifth }
context 'when no invalid champs_public' do
context "with new values for champs_private" do
@@ -1106,7 +1106,7 @@ describe Instructeurs::DossiersController, type: :controller do
]
end
- let(:champ_decimal_number) { dossier.champs_public.first }
+ let(:champ_decimal_number) { dossier.project_champs_public.first }
let(:params) do
{
diff --git a/spec/controllers/recherche_controller_spec.rb b/spec/controllers/recherche_controller_spec.rb
index 0c155fa48..ec5c6910a 100644
--- a/spec/controllers/recherche_controller_spec.rb
+++ b/spec/controllers/recherche_controller_spec.rb
@@ -18,16 +18,16 @@ describe RechercheController, type: :controller do
before do
instructeur.assign_to_procedure(dossier.procedure)
- dossier.champs_public[0].value = "Name of district A"
- dossier.champs_public[1].value = "Name of city A"
- dossier.champs_private[0].value = "Dossier A is complete"
- dossier.champs_private[1].value = "Dossier A is valid"
+ dossier.project_champs_public[0].value = "Name of district A"
+ dossier.project_champs_public[1].value = "Name of city A"
+ dossier.project_champs_private[0].value = "Dossier A is complete"
+ dossier.project_champs_private[1].value = "Dossier A is valid"
dossier.save!
- dossier_with_expert.champs_public[0].value = "Name of district B"
- dossier_with_expert.champs_public[1].value = "name of city B"
- dossier_with_expert.champs_private[0].value = "Dossier B is incomplete"
- dossier_with_expert.champs_private[1].value = "Dossier B is invalid"
+ dossier_with_expert.project_champs_public[0].value = "Name of district B"
+ dossier_with_expert.project_champs_public[1].value = "name of city B"
+ dossier_with_expert.project_champs_private[0].value = "Dossier B is incomplete"
+ dossier_with_expert.project_champs_private[1].value = "Dossier B is invalid"
dossier_with_expert.save!
perform_enqueued_jobs(only: DossierIndexSearchTermsJob)
diff --git a/spec/controllers/users/dossiers_controller_spec.rb b/spec/controllers/users/dossiers_controller_spec.rb
index 2e9bfadb0..68fe7a830 100644
--- a/spec/controllers/users/dossiers_controller_spec.rb
+++ b/spec/controllers/users/dossiers_controller_spec.rb
@@ -412,7 +412,7 @@ describe Users::DossiersController, type: :controller do
let(:procedure) { create(:procedure, :published, types_de_champ_public:) }
let(:types_de_champ_public) { [{ type: :text, mandatory: false }] }
let!(:dossier) { create(:dossier, user:, procedure:) }
- let(:first_champ) { dossier.champs_public.first }
+ let(:first_champ) { dossier.project_champs_public.first }
let(:anchor_to_first_champ) { controller.helpers.link_to first_champ.libelle, brouillon_dossier_path(anchor: first_champ.labelledby_id), class: 'error-anchor' }
let(:value) { 'beautiful value' }
let(:now) { Time.zone.parse('01/01/2100') }
@@ -529,7 +529,7 @@ describe Users::DossiersController, type: :controller do
let(:procedure) { create(:procedure, :published, types_de_champ_public:) }
let(:types_de_champ_public) { [{ type: :text, mandatory: false }] }
let(:dossier) { create(:dossier, :en_construction, procedure:, user:) }
- let(:first_champ) { dossier.owner_editing_fork.champs_public.first }
+ let(:first_champ) { dossier.owner_editing_fork.project_champs_public.first }
let(:anchor_to_first_champ) { controller.helpers.link_to I18n.t('views.users.dossiers.fix_champ'), modifier_dossier_path(anchor: first_champ.labelledby_id), class: 'error-anchor' }
let(:value) { 'beautiful value' }
let(:now) { Time.zone.parse('01/01/2100') }
@@ -677,8 +677,8 @@ describe Users::DossiersController, type: :controller do
let(:procedure) { create(:procedure, :published, types_de_champ_public:) }
let(:types_de_champ_public) { [{}, { type: :piece_justificative, mandatory: false }] }
let(:dossier) { create(:dossier, user:, procedure:) }
- let(:first_champ) { dossier.champs_public.first }
- let(:piece_justificative_champ) { dossier.champs_public.last }
+ let(:first_champ) { dossier.project_champs_public.first }
+ let(:piece_justificative_champ) { dossier.project_champs_public.last }
let(:value) { 'beautiful value' }
let(:file) { fixture_file_upload('spec/fixtures/files/piece_justificative_0.pdf', 'application/pdf') }
let(:now) { Time.zone.parse('01/01/2100') }
@@ -773,8 +773,8 @@ describe Users::DossiersController, type: :controller do
render_views
let(:types_de_champ_public) { [{ type: :text }, { type: :integer_number }] }
- let(:text_champ) { dossier.champs_public.first }
- let(:number_champ) { dossier.champs_public.last }
+ let(:text_champ) { dossier.project_champs_public.first }
+ let(:number_champ) { dossier.project_champs_public.last }
let(:submit_payload) do
{
id: dossier.id,
@@ -837,9 +837,9 @@ describe Users::DossiersController, type: :controller do
let(:procedure) { create(:procedure, :published, types_de_champ_public: [{}, { type: :piece_justificative }]) }
let!(:dossier) { create(:dossier, :en_construction, user:, procedure:) }
- let(:first_champ) { dossier.champs_public.first }
+ let(:first_champ) { dossier.project_champs_public.first }
let(:anchor_to_first_champ) { controller.helpers.link_to I18n.t('views.users.dossiers.fix_champ'), brouillon_dossier_path(anchor: first_champ.labelledby_id), class: 'error-anchor' }
- let(:piece_justificative_champ) { dossier.champs_public.last }
+ let(:piece_justificative_champ) { dossier.project_champs_public.last }
let(:value) { 'beautiful value' }
let(:file) { fixture_file_upload('spec/fixtures/files/piece_justificative_0.pdf', 'application/pdf') }
let(:now) { Time.zone.parse('01/01/2100') }
@@ -962,7 +962,7 @@ describe Users::DossiersController, type: :controller do
before do
first_champ.type_de_champ.update!(type_champ: :iban, mandatory: true, libelle: 'l')
- dossier.champs_public.first.becomes!(Champs::IbanChamp).save!
+ dossier.project_champs_public.first.becomes!(Champs::IbanChamp).save!
subject
end
@@ -1000,7 +1000,7 @@ describe Users::DossiersController, type: :controller do
context 'when the champ is a phone number' do
let(:procedure) { create(:procedure, :published, types_de_champ_public: [{ type: :phone }]) }
let!(:dossier) { create(:dossier, :en_construction, user:, procedure:) }
- let(:first_champ) { dossier.champs_public.first }
+ let(:first_champ) { dossier.project_champs_public.first }
let(:now) { Time.zone.parse('01/01/2100') }
let(:submit_payload) do
diff --git a/spec/graphql/dossier_spec.rb b/spec/graphql/dossier_spec.rb
index 01599b791..2c9e2d71a 100644
--- a/spec/graphql/dossier_spec.rb
+++ b/spec/graphql/dossier_spec.rb
@@ -71,8 +71,8 @@ RSpec.describe Types::DossierType, type: :graphql do
end
before do
- dossier.champs_public.find { _1.type_champ == TypeDeChamp.type_champs.fetch(:address) }.update(data: address)
- dossier.champs_public.find { _1.type_champ == TypeDeChamp.type_champs.fetch(:rna) }.update(data: rna)
+ dossier.project_champs_public.find { _1.type_champ == TypeDeChamp.type_champs.fetch(:address) }.update(data: address)
+ dossier.project_champs_public.find { _1.type_champ == TypeDeChamp.type_champs.fetch(:rna) }.update(data: rna)
end
it do
@@ -82,7 +82,7 @@ RSpec.describe Types::DossierType, type: :graphql do
expect(data[:dossier][:champs][1][:commune][:code]).to eq('75119')
expect(data[:dossier][:champs][1][:commune][:postalCode]).to eq('75019')
expect(data[:dossier][:champs][1][:departement][:code]).to eq('75')
- expect(data[:dossier][:champs][2][:etablissement][:siret]).to eq dossier.champs_public[2].etablissement.siret
+ expect(data[:dossier][:champs][2][:etablissement][:siret]).to eq dossier.project_champs_public[2].etablissement.siret
expect(data[:dossier][:champs][0][:id]).to eq(data[:dossier][:revision][:champDescriptors][0][:id])
expect(data[:dossier][:champs][1][:address][:cityName]).to eq('Paris 19e Arrondissement')
@@ -99,7 +99,7 @@ RSpec.describe Types::DossierType, type: :graphql do
end
context 'when etablissement is in degraded mode' do
- let(:etablissement) { dossier.champs_public.third.etablissement }
+ let(:etablissement) { dossier.project_champs_public.third.etablissement }
before do
etablissement.update(adresse: nil)
end
@@ -128,7 +128,7 @@ RSpec.describe Types::DossierType, type: :graphql do
let(:dossier) { create(:dossier, :en_construction, :with_populated_champs, procedure:) }
let(:query) { DOSSIER_WITH_SELECTED_CHAMP_QUERY }
let(:variables) { { number: dossier.id, id: champ.to_typed_id } }
- let(:champ) { dossier.champs_public.last }
+ let(:champ) { dossier.project_champs_public.last }
context 'when champ exists' do
it {
@@ -155,7 +155,7 @@ RSpec.describe Types::DossierType, type: :graphql do
let(:checkbox_value) { 'true' }
before do
- dossier.champs_public.first.update(value: checkbox_value)
+ dossier.project_champs_public.first.update(value: checkbox_value)
end
context 'when checkbox is true' do
@@ -204,7 +204,7 @@ RSpec.describe Types::DossierType, type: :graphql do
let(:variables) { { number: dossier.id } }
before do
- dossier.champs_public.first.update(value: linked_dossier.id)
+ dossier.project_champs_public.first.update(value: linked_dossier.id)
end
context 'en_construction' do
@@ -233,7 +233,7 @@ RSpec.describe Types::DossierType, type: :graphql do
let(:variables) { { number: dossier.id } }
let(:rows) do
- dossier.champs_public.first.rows.map do |champs|
+ dossier.project_champs_public.first.rows.map do |champs|
{ champs: champs.map { { id: _1.to_typed_id } } }
end
end
diff --git a/spec/jobs/dossier_index_search_terms_job_spec.rb b/spec/jobs/dossier_index_search_terms_job_spec.rb
index 872cf1a8a..523ac8cb9 100644
--- a/spec/jobs/dossier_index_search_terms_job_spec.rb
+++ b/spec/jobs/dossier_index_search_terms_job_spec.rb
@@ -10,8 +10,8 @@ RSpec.describe DossierIndexSearchTermsJob, type: :job do
subject(:perform_job) { described_class.perform_now(dossier.reload) }
before do
- dossier.champs_public.first.update_column(:value, "un nouveau champ")
- dossier.champs_private.first.update_column(:value, "private champ")
+ dossier.project_champs_public.first.update_column(:value, "un nouveau champ")
+ dossier.project_champs_private.first.update_column(:value, "private champ")
end
it "update search terms columns" do
diff --git a/spec/lib/recovery/revision_life_cycle_spec.rb b/spec/lib/recovery/revision_life_cycle_spec.rb
index f4227bfb8..9300d2740 100644
--- a/spec/lib/recovery/revision_life_cycle_spec.rb
+++ b/spec/lib/recovery/revision_life_cycle_spec.rb
@@ -29,11 +29,11 @@ describe 'Recovery::Revision::LifeCycle' do
it do
expect { DossierPreloader.load_one(dossier) }.not_to raise_error(ArgumentError)
- expect(dossier.champs_public.size).to eq(1)
+ expect(dossier.project_champs_public.size).to eq(1)
expect(dossier.champs.size).to eq(2)
importer.load
expect { DossierPreloader.load_one(dossier) }.not_to raise_error(ArgumentError)
- expect(dossier.champs_public.size).to eq(2)
+ expect(dossier.project_champs_public.size).to eq(2)
end
end
diff --git a/spec/models/attestation_template_spec.rb b/spec/models/attestation_template_spec.rb
index 4343a9746..e998b54c1 100644
--- a/spec/models/attestation_template_spec.rb
+++ b/spec/models/attestation_template_spec.rb
@@ -75,11 +75,11 @@ describe AttestationTemplate, type: :model do
end
before do
- dossier.champs_public
+ dossier.project_champs_public
.find { |champ| champ.libelle == 'libelleA' }
.update(value: 'libelle1')
- dossier.champs_public
+ dossier.project_champs_public
.find { |champ| champ.libelle == 'libelleB' }
.update(value: 'libelle2')
end
diff --git a/spec/models/champ_spec.rb b/spec/models/champ_spec.rb
index 6375ee4dd..016c7f2e0 100644
--- a/spec/models/champ_spec.rb
+++ b/spec/models/champ_spec.rb
@@ -86,8 +86,8 @@ describe Champ do
let(:dossier) { create(:dossier) }
it 'partition public and private' do
- expect(dossier.champs_public.count).to eq(1)
- expect(dossier.champs_private.count).to eq(1)
+ expect(dossier.project_champs_public.count).to eq(1)
+ expect(dossier.project_champs_private.count).to eq(1)
end
end
@@ -97,7 +97,7 @@ describe Champ do
context 'when a procedure has 2 revisions' do
it 'does not duplicate the champs' do
- expect(dossier.champs_public.count).to eq(1)
+ expect(dossier.project_champs_public.count).to eq(1)
expect(procedure.revisions.count).to eq(2)
end
end
@@ -111,7 +111,7 @@ describe Champ do
before { procedure.publish }
it 'does not duplicate the champs private' do
- expect(dossier.champs_private.count).to eq(1)
+ expect(dossier.project_champs_private.count).to eq(1)
expect(procedure.revisions.count).to eq(2)
end
end
@@ -122,12 +122,12 @@ describe Champ do
create(:procedure, types_de_champ_public: [{}, { type: :header_section }, { type: :repetition, mandatory: true, children: [{ type: :header_section }] }], types_de_champ_private: [{}, { type: :header_section }])
end
let(:dossier) { create(:dossier, procedure: procedure) }
- let(:public_champ) { dossier.champs_public.first }
- let(:private_champ) { dossier.champs_private.first }
- let(:champ_in_repetition) { dossier.champs_public.find(&:repetition?).champs.first }
+ let(:public_champ) { dossier.project_champs_public.first }
+ let(:private_champ) { dossier.project_champs_private.first }
+ let(:champ_in_repetition) { dossier.project_champs_public.find(&:repetition?).champs.first }
let(:standalone_champ) { build(:champ, type_de_champ: build(:type_de_champ), dossier: build(:dossier)) }
- let(:public_sections) { dossier.champs_public.filter(&:header_section?) }
- let(:private_sections) { dossier.champs_private.filter(&:header_section?) }
+ let(:public_sections) { dossier.project_champs_public.filter(&:header_section?) }
+ let(:private_sections) { dossier.project_champs_private.filter(&:header_section?) }
let(:sections_in_repetition) { dossier.champs.filter(&:child?).filter(&:header_section?) }
it 'returns the sibling sections of a champ' do
diff --git a/spec/models/concerns/dossier_champs_concern_spec.rb b/spec/models/concerns/dossier_champs_concern_spec.rb
index a4168faab..e4177db5c 100644
--- a/spec/models/concerns/dossier_champs_concern_spec.rb
+++ b/spec/models/concerns/dossier_champs_concern_spec.rb
@@ -61,7 +61,7 @@ RSpec.describe DossierChampsConcern do
end
context "missing champ" do
- before { dossier; Champs::TextChamp.destroy_all }
+ before { dossier.champs.where(type: 'Champs::TextChamp').destroy_all; dossier.reload }
it {
expect(subject.new_record?).to be_truthy
@@ -94,7 +94,7 @@ RSpec.describe DossierChampsConcern do
it { expect(subject.persisted?).to be_truthy }
context "missing champ" do
- before { dossier; Champs::TextChamp.destroy_all }
+ before { dossier.champs.where(type: 'Champs::TextChamp').destroy_all; dossier.reload }
it {
expect(subject.new_record?).to be_truthy
diff --git a/spec/models/concerns/dossier_clone_concern_spec.rb b/spec/models/concerns/dossier_clone_concern_spec.rb
index 7856bc140..e7e5f4869 100644
--- a/spec/models/concerns/dossier_clone_concern_spec.rb
+++ b/spec/models/concerns/dossier_clone_concern_spec.rb
@@ -120,15 +120,15 @@ RSpec.describe DossierCloneConcern do
context 'public are duplicated' do
it do
- expect(new_dossier.champs_public.count).to eq(dossier.champs_public.count)
- expect(new_dossier.champs_public.ids).not_to eq(dossier.champs_public.ids)
+ expect(new_dossier.project_champs_public.count).to eq(dossier.project_champs_public.count)
+ expect(new_dossier.project_champs_public.map(&:id)).not_to eq(dossier.project_champs_public.map(&:id))
end
it 'keeps champs.values' do
- original_first_champ = dossier.champs_public.first
+ original_first_champ = dossier.project_champs_public.first
original_first_champ.update!(value: 'kthxbye')
- expect(new_dossier.champs_public.first.value).to eq(original_first_champ.value)
+ expect(new_dossier.project_champs_public.first.value).to eq(original_first_champ.value)
end
context 'for Champs::Repetition with rows, original_champ.repetition and rows are duped' do
@@ -192,26 +192,26 @@ RSpec.describe DossierCloneConcern do
let(:types_de_champ_private) { [{}] }
it 'reset champs private values' do
- expect(new_dossier.champs_private.count).to eq(dossier.champs_private.count)
- expect(new_dossier.champs_private.ids).not_to eq(dossier.champs_private.ids)
- original_first_champs_private = dossier.champs_private.first
+ expect(new_dossier.project_champs_private.count).to eq(dossier.project_champs_private.count)
+ expect(new_dossier.project_champs_private.map(&:id)).not_to eq(dossier.project_champs_private.map(&:id))
+ original_first_champs_private = dossier.project_champs_private.first
original_first_champs_private.update!(value: 'kthxbye')
- expect(new_dossier.champs_private.first.value).not_to eq(original_first_champs_private.value)
- expect(new_dossier.champs_private.first.value).to eq(nil)
+ expect(new_dossier.project_champs_private.first.value).not_to eq(original_first_champs_private.value)
+ expect(new_dossier.project_champs_private.first.value).to eq(nil)
end
end
end
context "as a fork" do
let(:new_dossier) { dossier.clone(fork: true) }
- before { dossier.champs_public.reload } # we compare timestamps so we have to get the precision limit from the db }
+ before { dossier.project_champs_public } # we compare timestamps so we have to get the precision limit from the db }
it do
expect(new_dossier.editing_fork_origin).to eq(dossier)
- expect(new_dossier.champs_public[0].id).not_to eq(dossier.champs_public[0].id)
- expect(new_dossier.champs_public[0].created_at).to eq(dossier.champs_public[0].created_at)
- expect(new_dossier.champs_public[0].updated_at).to eq(dossier.champs_public[0].updated_at)
+ expect(new_dossier.project_champs_public[0].id).not_to eq(dossier.project_champs_public[0].id)
+ expect(new_dossier.project_champs_public[0].created_at).to eq(dossier.project_champs_public[0].created_at)
+ expect(new_dossier.project_champs_public[0].updated_at).to eq(dossier.project_champs_public[0].updated_at)
end
context "piece justificative champ" do
@@ -343,11 +343,11 @@ RSpec.describe DossierCloneConcern do
dossier.debounce_index_search_terms_flag.remove
end
- it { expect { subject }.to change { dossier.reload.champs.size }.by(0) }
- it { expect { subject }.not_to change { dossier.reload.champs.order(:created_at).reject { _1.stable_id.in?([99, 994]) }.map(&:value) } }
+ it { expect { subject }.to change { dossier.champs.size }.by(0) }
+ it { expect { subject }.not_to change { dossier.champs.order(:created_at).reject { _1.stable_id.in?([99, 994]) }.map(&:value) } }
it { expect { subject }.to have_enqueued_job(DossierIndexSearchTermsJob).with(dossier) }
- it { expect { subject }.to change { dossier.reload.champs.find { _1.stable_id == 99 }.value }.from('old value').to('new value') }
- it { expect { subject }.to change { dossier.reload.champs.find { _1.stable_id == 994 }.value }.from('old value').to('new value in repetition') }
+ it { expect { subject }.to change { dossier.champs.find { _1.stable_id == 99 }.value }.from('old value').to('new value') }
+ it { expect { subject }.to change { dossier.champs.find { _1.stable_id == 994 }.value }.from('old value').to('new value in repetition') }
it 'fork is hidden after merge' do
subject
@@ -386,11 +386,10 @@ RSpec.describe DossierCloneConcern do
added_repetition_champ.update(value: "new value in repetition champ")
dossier.reload
super()
- dossier.reload
}
- it { expect { subject }.to change { dossier.reload.champs.size }.by(1) }
- it { expect { subject }.to change { dossier.reload.champs.order(:created_at).map(&:to_s) }.from(['old value', 'old value', 'Non', 'old value', 'old value']).to(['new value for updated champ', 'Non', 'old value', 'old value', 'new value for added champ', 'new value in repetition champ']) }
+ it { expect { subject }.to change { dossier.champs.size }.by(1) }
+ it { expect { subject }.to change { dossier.champs.order(:created_at).map(&:to_s) }.from(['old value', 'old value', 'Non', 'old value', 'old value']).to(['new value for updated champ', 'Non', 'old value', 'old value', 'new value for added champ', 'new value in repetition champ']) }
it "dossier after merge should be on last published revision" do
expect(dossier.revision_id).to eq(procedure.revisions.first.id)
diff --git a/spec/models/concerns/dossier_prefillable_concern_spec.rb b/spec/models/concerns/dossier_prefillable_concern_spec.rb
index f3b1fe2bb..2d0866fec 100644
--- a/spec/models/concerns/dossier_prefillable_concern_spec.rb
+++ b/spec/models/concerns/dossier_prefillable_concern_spec.rb
@@ -43,7 +43,7 @@ RSpec.describe DossierPrefillableConcern do
end
it "doesn't change champs_public" do
- expect { fill }.not_to change { dossier.champs_public.to_a }
+ expect { fill }.not_to change { dossier.project_champs_public.to_a }
end
end
@@ -71,12 +71,12 @@ RSpec.describe DossierPrefillableConcern do
it "updates the champs with the new values and mark them as prefilled" do
fill
- expect(dossier.champs_public.first.value).to eq(value_1)
- expect(dossier.champs_public.first.prefilled).to eq(true)
- expect(dossier.champs_public.last.value).to eq(value_2)
- expect(dossier.champs_public.last.prefilled).to eq(true)
- expect(dossier.champs_private.first.value).to eq(value_3)
- expect(dossier.champs_private.first.prefilled).to eq(true)
+ expect(dossier.project_champs_public.first.value).to eq(value_1)
+ expect(dossier.project_champs_public.first.prefilled).to eq(true)
+ expect(dossier.project_champs_public.last.value).to eq(value_2)
+ expect(dossier.project_champs_public.last.prefilled).to eq(true)
+ expect(dossier.project_champs_private.first.value).to eq(value_3)
+ expect(dossier.project_champs_private.first.prefilled).to eq(true)
end
end
@@ -91,11 +91,11 @@ RSpec.describe DossierPrefillableConcern do
it_behaves_like 'a dossier marked as prefilled'
it "still updates the champ" do
- expect { fill }.to change { dossier.champs_public.first.value }.from(nil).to(value)
+ expect { fill }.to change { dossier.project_champs_public.first.value }.from(nil).to(value)
end
it "still marks it as prefilled" do
- expect { fill }.to change { dossier.champs_public.first.prefilled }.from(nil).to(true)
+ expect { fill }.to change { dossier.project_champs_public.first.prefilled }.from(nil).to(true)
end
end
end
@@ -115,7 +115,7 @@ RSpec.describe DossierPrefillableConcern do
it "updates the champs with the new values and mark them as prefilled" do
fill
- expect(dossier.champs_public.first.value).to eq(value_1)
+ expect(dossier.project_champs_public.first.value).to eq(value_1)
expect(dossier.individual).to be_nil # Fix #9486
end
diff --git a/spec/models/concerns/dossier_rebase_concern_spec.rb b/spec/models/concerns/dossier_rebase_concern_spec.rb
index d201f8191..5b4c1704a 100644
--- a/spec/models/concerns/dossier_rebase_concern_spec.rb
+++ b/spec/models/concerns/dossier_rebase_concern_spec.rb
@@ -293,19 +293,19 @@ describe DossierRebaseConcern do
let(:datetime_type_de_champ) { types_de_champ.find { _1.stable_id == 103 } }
let(:yes_no_type_de_champ) { types_de_champ.find { _1.stable_id == 104 } }
- let(:text_champ) { dossier.champs_public.find { _1.stable_id == 1 } }
- let(:repetition_champ) { dossier.champs_public.find { _1.stable_id == 101 } }
- let(:datetime_champ) { dossier.champs_public.find { _1.stable_id == 103 } }
+ let(:text_champ) { dossier.project_champs_public.find { _1.stable_id == 1 } }
+ let(:repetition_champ) { dossier.project_champs_public.find { _1.stable_id == 101 } }
+ let(:datetime_champ) { dossier.project_champs_public.find { _1.stable_id == 103 } }
- let(:rebased_text_champ) { dossier.champs_public.find { _1.stable_id == 1 } }
- let(:rebased_repetition_champ) { dossier.champs_public.find { _1.stable_id == 101 } }
- let(:rebased_datetime_champ) { dossier.champs_public.find { _1.stable_id == 103 } }
- let(:rebased_number_champ) { dossier.champs_public.find { _1.stable_id == 105 } }
+ let(:rebased_text_champ) { dossier.project_champs_public.find { _1.stable_id == 1 } }
+ let(:rebased_repetition_champ) { dossier.project_champs_public.find { _1.stable_id == 101 } }
+ let(:rebased_datetime_champ) { dossier.project_champs_public.find { _1.stable_id == 103 } }
+ let(:rebased_number_champ) { dossier.project_champs_public.find { _1.stable_id == 105 } }
- let(:rebased_new_repetition_champ) { dossier.champs_public.find { _1.libelle == "une autre repetition" } }
+ let(:rebased_new_repetition_champ) { dossier.project_champs_public.find { _1.libelle == "une autre repetition" } }
let(:private_text_type_de_champ) { types_de_champ.find { _1.stable_id == 11 } }
- let(:rebased_private_text_champ) { dossier.champs_private.find { _1.stable_id == 11 } }
+ let(:rebased_private_text_champ) { dossier.project_champs_private.find { _1.stable_id == 11 } }
context "when revision is published" do
before do
@@ -345,16 +345,17 @@ describe DossierRebaseConcern do
datetime_champ.update(value: Time.zone.now.to_s)
text_champ.update(value: 'bonjour')
+ text_champ.type_de_champ
# Add two rows then remove previous to last row in order to create a "hole" in the sequence
repetition_champ.add_row(updated_by: 'test')
repetition_champ.add_row(updated_by: 'test')
- repetition_champ.champs.where(row_id: repetition_champ.rows[-2].first.row_id).destroy_all
- repetition_champ.reload
+ repetition_champ.champs.where(row_id: repetition_champ.row_ids[-2]).destroy_all
+ dossier.reload
end
it "updates the brouillon champs with the latest revision changes" do
expect(dossier.revision).to eq(procedure.published_revision)
- expect(dossier.champs_public.size).to eq(5)
+ expect(dossier.project_champs_public.size).to eq(5)
expect(dossier.champs.count(&:public?)).to eq(7)
expect(repetition_champ.rows.size).to eq(2)
expect(repetition_champ.rows[0].size).to eq(1)
@@ -367,7 +368,7 @@ describe DossierRebaseConcern do
expect(procedure.revisions.size).to eq(3)
expect(dossier.revision).to eq(procedure.published_revision)
- expect(dossier.champs_public.size).to eq(7)
+ expect(dossier.project_champs_public.size).to eq(7)
expect(dossier.champs.count(&:public?)).to eq(13)
expect(rebased_text_champ.value).to eq(text_champ.value)
expect(rebased_text_champ.type_de_champ).not_to eq(text_champ.type_de_champ)
@@ -404,7 +405,7 @@ describe DossierRebaseConcern do
let(:dossier) { create(:dossier, :en_construction, procedure:) }
it 'is noop' do
- expect { subject }.not_to change { dossier.reload.champs_public[0].rebased_at }
+ expect { subject }.not_to change { dossier.reload.project_champs_public[0].rebased_at }
expect { subject }.not_to change { dossier.updated_at }
end
end
@@ -430,38 +431,38 @@ describe DossierRebaseConcern do
context 'when a dropdown option is added' do
before do
- dossier.champs_public.first.update(value: 'v1')
+ dossier.project_champs_public.first.update(value: 'v1')
stable_id = procedure.draft_revision.types_de_champ.find_by(libelle: 'l1')
tdc_to_update = procedure.draft_revision.find_and_ensure_exclusive_use(stable_id)
tdc_to_update.update(drop_down_options: ["option", "updated", "v1"])
end
- it { expect { subject }.not_to change { dossier.champs_public.first.value } }
+ it { expect { subject }.not_to change { dossier.project_champs_public.first.value } }
end
context 'when a dropdown option is removed' do
before do
- dossier.champs_public.first.update(value: 'v1')
+ dossier.project_champs_public.first.update(value: 'v1')
stable_id = procedure.draft_revision.types_de_champ.find_by(libelle: 'l1')
tdc_to_update = procedure.draft_revision.find_and_ensure_exclusive_use(stable_id)
tdc_to_update.update(drop_down_options: ["option", "updated"])
end
- it { expect { subject }.to change { dossier.champs_public.first.value }.from('v1').to(nil) }
+ it { expect { subject }.to change { dossier.project_champs_public.first.value }.from('v1').to(nil) }
end
context 'when a dropdown unused option is removed' do
before do
- dossier.champs_public.first.update(value: 'v1')
+ dossier.project_champs_public.first.update(value: 'v1')
stable_id = procedure.draft_revision.types_de_champ.find_by(libelle: 'l1')
tdc_to_update = procedure.draft_revision.find_and_ensure_exclusive_use(stable_id)
tdc_to_update.update(drop_down_options: ["v1", "updated"])
end
- it { expect { subject }.not_to change { dossier.champs_public.first.value } }
+ it { expect { subject }.not_to change { dossier.project_champs_public.first.value } }
end
end
@@ -476,38 +477,38 @@ describe DossierRebaseConcern do
context 'when a dropdown option is added' do
before do
- dossier.champs_public.first.update(value: '["v1"]')
+ dossier.project_champs_public.first.update(value: '["v1"]')
stable_id = procedure.draft_revision.types_de_champ.find_by(libelle: 'l1')
tdc_to_update = procedure.draft_revision.find_and_ensure_exclusive_use(stable_id)
tdc_to_update.update(drop_down_options: ["option", "updated", "v1"])
end
- it { expect { subject }.not_to change { dossier.champs_public.first.value } }
+ it { expect { subject }.not_to change { dossier.project_champs_public.first.value } }
end
context 'when a dropdown option is removed' do
before do
- dossier.champs_public.first.update(value: '["v1", "option"]')
+ dossier.project_champs_public.first.update(value: '["v1", "option"]')
stable_id = procedure.draft_revision.types_de_champ.find_by(libelle: 'l1')
tdc_to_update = procedure.draft_revision.find_and_ensure_exclusive_use(stable_id)
tdc_to_update.update(drop_down_options: ["option", "updated"])
end
- it { expect { subject }.to change { dossier.champs_public.first.value }.from('["v1","option"]').to('["option"]') }
+ it { expect { subject }.to change { dossier.project_champs_public.first.value }.from('["v1","option"]').to('["option"]') }
end
context 'when a dropdown unused option is removed' do
before do
- dossier.champs_public.first.update(value: '["v1"]')
+ dossier.project_champs_public.first.update(value: '["v1"]')
stable_id = procedure.draft_revision.types_de_champ.find_by(libelle: 'l1')
tdc_to_update = procedure.draft_revision.find_and_ensure_exclusive_use(stable_id)
tdc_to_update.update(drop_down_options: ["v1", "updated"])
end
- it { expect { subject }.not_to change { dossier.champs_public.first.value } }
+ it { expect { subject }.not_to change { dossier.project_champs_public.first.value } }
end
end
@@ -522,38 +523,38 @@ describe DossierRebaseConcern do
context 'when a dropdown option is added' do
before do
- dossier.champs_public.first.update(value: '["v1",""]')
+ dossier.project_champs_public.first.update(value: '["v1",""]')
stable_id = procedure.draft_revision.types_de_champ.find_by(libelle: 'l1')
tdc_to_update = procedure.draft_revision.find_and_ensure_exclusive_use(stable_id)
tdc_to_update.update(drop_down_options: ["--titre1--", "option", "v1", "updated", "--titre2--", "option2", "v2"])
end
- it { expect { subject }.not_to change { dossier.champs_public.first.value } }
+ it { expect { subject }.not_to change { dossier.project_champs_public.first.value } }
end
context 'when a dropdown option is removed' do
before do
- dossier.champs_public.first.update(value: '["v1","option2"]')
+ dossier.project_champs_public.first.update(value: '["v1","option2"]')
stable_id = procedure.draft_revision.types_de_champ.find_by(libelle: 'l1')
tdc_to_update = procedure.draft_revision.find_and_ensure_exclusive_use(stable_id)
tdc_to_update.update(drop_down_options: ["--titre1--", "option", "updated", "--titre2--", "option2", "v2"])
end
- it { expect { subject }.to change { dossier.champs_public.first.value }.from('["v1","option2"]').to(nil) }
+ it { expect { subject }.to change { dossier.project_champs_public.first.value }.from('["v1","option2"]').to(nil) }
end
context 'when a dropdown unused option is removed' do
before do
- dossier.champs_public.first.update(value: '["v1",""]')
+ dossier.project_champs_public.first.update(value: '["v1",""]')
stable_id = procedure.draft_revision.types_de_champ.find_by(libelle: 'l1')
tdc_to_update = procedure.draft_revision.find_and_ensure_exclusive_use(stable_id)
tdc_to_update.update(drop_down_options: ["--titre1--", "v1", "updated", "--titre2--", "option2", "v2"])
end
- it { expect { subject }.not_to change { dossier.champs_public.first.value } }
+ it { expect { subject }.not_to change { dossier.project_champs_public.first.value } }
end
end
@@ -568,14 +569,14 @@ describe DossierRebaseConcern do
context 'and the cadastre are removed' do
before do
- dossier.champs_public.first.update(value: 'v1', geo_areas: [build(:geo_area, :cadastre)])
+ dossier.project_champs_public.first.update(value: 'v1', geo_areas: [build(:geo_area, :cadastre)])
stable_id = procedure.draft_revision.types_de_champ.find_by(libelle: 'l1')
tdc_to_update = procedure.draft_revision.find_and_ensure_exclusive_use(stable_id)
tdc_to_update.update(cadastres: false)
end
- it { expect { subject }.to change { dossier.champs_public.first.cadastres.count }.from(1).to(0) }
+ it { expect { subject }.to change { dossier.project_champs_public.first.cadastres.count }.from(1).to(0) }
end
end
@@ -626,7 +627,7 @@ describe DossierRebaseConcern do
end
context 'when the first tdc type is updated' do
- def first_champ = dossier.champs_public.first
+ def first_champ = dossier.project_champs_public.first
before do
first_champ.update(value: 'v1', external_id: '123', geo_areas: [build(:geo_area)])
@@ -727,7 +728,7 @@ describe DossierRebaseConcern do
parent.update(type_champ: :integer_number)
end
- it { expect { subject }.to change { dossier.champs_public.first.champs.count }.from(2).to(0) }
+ it { expect { subject }.to change { dossier.project_champs_public.first.champs.count }.from(2).to(0) }
it { expect { subject }.to change { Champ.count }.from(3).to(1) }
end
end
diff --git a/spec/models/concerns/dossier_searchable_concern_spec.rb b/spec/models/concerns/dossier_searchable_concern_spec.rb
index d1b0c1114..62f198a03 100644
--- a/spec/models/concerns/dossier_searchable_concern_spec.rb
+++ b/spec/models/concerns/dossier_searchable_concern_spec.rb
@@ -1,8 +1,8 @@
# frozen_string_literal: true
describe DossierSearchableConcern do
- let(:champ_public) { dossier.champs_public.first }
- let(:champ_private) { dossier.champs_private.first }
+ let(:champ_public) { dossier.project_champs_public.first }
+ let(:champ_private) { dossier.project_champs_private.first }
describe '#index_search_terms' do
let(:etablissement) { dossier.etablissement }
diff --git a/spec/models/concerns/tags_substitution_concern_spec.rb b/spec/models/concerns/tags_substitution_concern_spec.rb
index 42b0d30a0..10e0368a5 100644
--- a/spec/models/concerns/tags_substitution_concern_spec.rb
+++ b/spec/models/concerns/tags_substitution_concern_spec.rb
@@ -169,11 +169,11 @@ describe TagsSubstitutionConcern, type: :model do
context 'and their value in the dossier are not nil' do
before do
- dossier.champs_public
+ dossier.project_champs_public
.find { |champ| champ.libelle == 'libelleA' }
.update(value: 'libelle1')
- dossier.champs_public
+ dossier.project_champs_public
.find { |champ| champ.libelle == "libelle\xc2\xA0B".encode('utf-8') }
.update(value: 'libelle2')
end
@@ -195,7 +195,7 @@ describe TagsSubstitutionConcern, type: :model do
context 'and their value in the dossier are not nil' do
before do
- dossier.champs_public
+ dossier.project_champs_public
.find { |champ| champ.libelle == "Intitulé de l'‘«\"évènement\"»’" }
.update(value: 'ceci est mon évènement')
end
@@ -217,7 +217,7 @@ describe TagsSubstitutionConcern, type: :model do
context 'and their value in the dossier are not nil' do
before do
- dossier.champs_public
+ dossier.project_champs_public
.find { |champ| champ.libelle == "bon pote -- c'est top" }
.update(value: 'ceci est mon évènement')
end
@@ -316,7 +316,7 @@ describe TagsSubstitutionConcern, type: :model do
let(:template) { '--libelleA--' }
context 'and its value in the dossier is not nil' do
- before { dossier.champs_private.first.update(value: 'libelle1') }
+ before { dossier.project_champs_private.first.update(value: 'libelle1') }
it { is_expected.to eq('libelle1') }
end
@@ -339,7 +339,7 @@ describe TagsSubstitutionConcern, type: :model do
context 'champs publics are valid tags' do
let(:types_de_champ_public) { [{ libelle: 'libelleA' }] }
- before { dossier.champs_public.first.update(value: 'libelle1') }
+ before { dossier.project_champs_public.first.update(value: 'libelle1') }
it { is_expected.to eq('libelle1') }
end
@@ -358,11 +358,11 @@ describe TagsSubstitutionConcern, type: :model do
context 'and its value in the dossier are not nil' do
before do
- dossier.champs_public
+ dossier.project_champs_public
.find { |champ| champ.type_champ == TypeDeChamp.type_champs.fetch(:date) }
.update(value: '2017-04-15')
- dossier.champs_public
+ dossier.project_champs_public
.find { |champ| champ.type_champ == TypeDeChamp.type_champs.fetch(:datetime) }
.update(value: '2017-09-13 09:00')
end
@@ -433,7 +433,7 @@ describe TagsSubstitutionConcern, type: :model do
end
context "match breaking and non breaking spaces" do
- before { dossier.champs_public.first.update(value: 'valeur') }
+ before { dossier.project_champs_public.first.update(value: 'valeur') }
shared_examples "treat all kinds of space as equivalent" do
context 'and the champ has a non breaking space' do
@@ -480,7 +480,7 @@ describe TagsSubstitutionConcern, type: :model do
before do
draft_type_de_champ.update(libelle: 'mon nouveau libellé')
- dossier.champs_public.first.update(value: 'valeur')
+ dossier.project_champs_public.first.update(value: 'valeur')
procedure.update!(draft_revision: procedure.create_new_revision, published_revision: procedure.draft_revision)
end
@@ -513,7 +513,7 @@ describe TagsSubstitutionConcern, type: :model do
context 'in a champ' do
let(:types_de_champ_public) { [{ libelle: 'libelleA' }] }
- before { dossier.champs_public.first.update(value: 'hey anchor') }
+ before { dossier.project_champs_public.first.update(value: 'hey anchor') }
it { is_expected.to eq('hey <a href="https://oops.com">anchor</a> --nom--') }
end
diff --git a/spec/models/dossier_preloader_spec.rb b/spec/models/dossier_preloader_spec.rb
index 3fd7be78b..fb2fadda7 100644
--- a/spec/models/dossier_preloader_spec.rb
+++ b/spec/models/dossier_preloader_spec.rb
@@ -10,9 +10,9 @@ describe DossierPreloader do
end
let(:procedure) { create(:procedure, types_de_champ_public: types_de_champ) }
let(:dossier) { create(:dossier, procedure: procedure) }
- let(:repetition) { subject.champs_public.second }
- let(:repetition_optional) { subject.champs_public.third }
- let(:first_child) { subject.champs_public.second.champs.first }
+ let(:repetition) { subject.project_champs_public.second }
+ let(:repetition_optional) { subject.project_champs_public.third }
+ let(:first_child) { subject.project_champs_public.second.champs.first }
describe 'all' do
subject { DossierPreloader.load_one(dossier, pj_template: true) }
@@ -25,20 +25,20 @@ describe DossierPreloader do
callback = lambda { |*_args| count += 1 }
ActiveSupport::Notifications.subscribed(callback, "sql.active_record") do
expect(subject.id).to eq(dossier.id)
- expect(subject.champs_public.size).to eq(types_de_champ.size)
+ expect(subject.project_champs_public.size).to eq(types_de_champ.size)
expect(subject.changed?).to be false
expect(first_child.type).to eq('Champs::TextChamp')
expect(repetition.id).not_to eq(first_child.id)
expect(subject.champs.first.dossier).to eq(subject)
expect(subject.champs.find(&:public?).dossier).to eq(subject)
- expect(subject.champs_public.first.dossier).to eq(subject)
+ expect(subject.project_champs_public.first.dossier).to eq(subject)
- expect(subject.champs_public.first.type_de_champ.piece_justificative_template.attached?).to eq(false)
+ expect(subject.project_champs_public.first.type_de_champ.piece_justificative_template.attached?).to eq(false)
expect(subject.champs.first.conditional?).to eq(false)
expect(subject.champs.find(&:public?).conditional?).to eq(false)
- expect(subject.champs_public.first.conditional?).to eq(false)
+ expect(subject.project_champs_public.first.conditional?).to eq(false)
expect(first_child.parent).to eq(repetition)
expect(repetition.champs.first).to eq(first_child)
diff --git a/spec/models/dossier_spec.rb b/spec/models/dossier_spec.rb
index 26b623346..8deed619b 100644
--- a/spec/models/dossier_spec.rb
+++ b/spec/models/dossier_spec.rb
@@ -304,22 +304,12 @@ describe Dossier, type: :model do
subject { dossier }
- describe '#create' do
- let(:procedure) { create(:procedure, :with_type_de_champ, :with_type_de_champ_private) }
- let(:dossier) { create(:dossier, procedure: procedure, user: user) }
-
- it 'builds public and private champs' do
- expect(dossier.champs_public.count).to eq(1)
- expect(dossier.champs_private.count).to eq(1)
- end
- end
-
- describe '#build_default_individual' do
+ describe '#build_default_values' do
let(:dossier) { build(:dossier, procedure: procedure, user: user) }
subject do
dossier.individual = nil
- dossier.build_default_individual
+ dossier.build_default_values
end
context 'when the dossier belongs to a procedure for individuals' do
@@ -867,7 +857,7 @@ describe Dossier, type: :model do
it { is_expected.not_to eq(modif_date) }
context 'when a champ is modified' do
- before { dossier.champs_public.first.update_attribute('value', 'yop') }
+ before { dossier.project_champs_public.first.update_attribute('value', 'yop') }
it { is_expected.to eq(modif_date) }
end
@@ -1709,14 +1699,14 @@ describe Dossier, type: :model do
let(:expression_reguliere_error_message) { "Le champ doit être composé de lettres majuscules" }
before do
- champ = dossier.champs_public.first
+ champ = dossier.project_champs_public.first
champ.value = expression_reguliere_exemple_text
dossier.save(context: :champs_public_value)
end
it 'should have errors' do
expect(dossier.errors).not_to be_empty
- expect(dossier.errors.full_messages.join(',')).to include(dossier.champs_public.first.expression_reguliere_error_message)
+ expect(dossier.errors.full_messages.join(',')).to include(dossier.project_champs_public.first.expression_reguliere_error_message)
end
end
@@ -1726,7 +1716,7 @@ describe Dossier, type: :model do
let(:expression_reguliere_error_message) { "Le champ doit être composé de lettres majuscules" }
before do
- champ = dossier.champs_public.first
+ champ = dossier.project_champs_public.first
champ.value = expression_reguliere_exemple_text
dossier.save
end
@@ -2026,8 +2016,8 @@ describe Dossier, type: :model do
let(:explication_type_de_champ) { procedure.active_revision.types_de_champ_public.find { |type_de_champ| type_de_champ.type_champ == TypeDeChamp.type_champs.fetch(:explication) } }
let(:commune_type_de_champ) { procedure.active_revision.types_de_champ_public.find { |type_de_champ| type_de_champ.type_champ == TypeDeChamp.type_champs.fetch(:communes) } }
let(:repetition_type_de_champ) { procedure.active_revision.types_de_champ_public.find { |type_de_champ| type_de_champ.type_champ == TypeDeChamp.type_champs.fetch(:repetition) } }
- let(:repetition_champ) { dossier.champs_public.find(&:repetition?) }
- let(:repetition_second_revision_champ) { dossier_second_revision.champs_public.find(&:repetition?) }
+ let(:repetition_champ) { dossier.project_champs_public.find(&:repetition?) }
+ let(:repetition_second_revision_champ) { dossier_second_revision.project_champs_public.find(&:repetition?) }
let(:dossier) { create(:dossier, procedure: procedure) }
let(:dossier_second_revision) { create(:dossier, procedure: procedure) }
let(:dossier_champs_for_export) { dossier.champs_for_export(procedure.types_de_champ_for_procedure_export) }
@@ -2087,14 +2077,14 @@ describe Dossier, type: :model do
let(:dossier) { create(:dossier, procedure:) }
let(:yes_no_tdc) { procedure.active_revision.types_de_champ_public.first }
let(:text_tdc) { procedure.active_revision.types_de_champ_public.second }
- let(:tdcs) { dossier.champs_public.map(&:type_de_champ) }
+ let(:tdcs) { dossier.project_champs_public.map(&:type_de_champ) }
subject { dossier.champs_for_export(tdcs) }
before do
text_tdc.update(condition: ds_eq(champ_value(yes_no_tdc.stable_id), constant(true)))
- yes_no, text = dossier.champs_public
+ yes_no, text = dossier.project_champs_public
yes_no.update(value: yes_no_value)
text.update(value: 'text')
end
@@ -2113,7 +2103,7 @@ describe Dossier, type: :model do
context 'with another revision' do
let(:tdc_from_another_revision) { create(:type_de_champ_communes, libelle: 'commune', condition: ds_eq(constant(true), constant(true))) }
- let(:tdcs) { dossier.champs_public.map(&:type_de_champ) << tdc_from_another_revision }
+ let(:tdcs) { dossier.project_champs_public.map(&:type_de_champ) << tdc_from_another_revision }
let(:yes_no_value) { 'true' }
let(:expected) do
diff --git a/spec/models/export_template_spec.rb b/spec/models/export_template_spec.rb
index 8ef3e3c04..3cb3bfd26 100644
--- a/spec/models/export_template_spec.rb
+++ b/spec/models/export_template_spec.rb
@@ -50,7 +50,7 @@ describe ExportTemplate do
end
context 'for pj' do
- let(:champ_pj) { dossier.champs_public.first }
+ let(:champ_pj) { dossier.project_champs_public.first }
let(:export_template) { create(:export_template, groupe_instructeur:, pjs: [ExportItem.default(stable_id: 3, prefix: "justif", enabled: true)]) }
let(:attachment) { ActiveStorage::Attachment.new(name: 'pj', record: champ_pj, blob: ActiveStorage::Blob.new(filename: "superpj.png")) }
diff --git a/spec/models/instructeur_spec.rb b/spec/models/instructeur_spec.rb
index b0b26f8bc..54f2a21b0 100644
--- a/spec/models/instructeur_spec.rb
+++ b/spec/models/instructeur_spec.rb
@@ -201,7 +201,7 @@ describe Instructeur, type: :model do
context 'when there is a modification on public champs' do
before {
- dossier.champs_public.first.update(value: 'toto')
+ dossier.project_champs_public.first.update(value: 'toto')
dossier.update(last_champ_updated_at: Time.zone.now)
}
@@ -223,7 +223,7 @@ describe Instructeur, type: :model do
context 'when there is a modification on private champs' do
before {
- dossier.champs_private.first.update(value: 'toto')
+ dossier.project_champs_private.first.update(value: 'toto')
dossier.update(last_champ_private_updated_at: Time.zone.now)
}
@@ -302,7 +302,7 @@ describe Instructeur, type: :model do
it { expect(instructeur_on_procedure_2.notifications_for_groupe_instructeurs(gi_p2)[:en_cours]).to match([]) }
context 'and there is a modification on private champs' do
- before { dossier.champs_private.first.update_attribute('value', 'toto') }
+ before { dossier.project_champs_private.first.update_attribute('value', 'toto') }
it { is_expected.to match([dossier.id]) }
end
@@ -317,7 +317,7 @@ describe Instructeur, type: :model do
end
context 'when there is a modification on public champs on a followed dossier from another procedure' do
- before { dossier_on_procedure_2.champs_public.first.update_attribute('value', 'toto') }
+ before { dossier_on_procedure_2.project_champs_public.first.update_attribute('value', 'toto') }
it { is_expected.to match([]) }
end
diff --git a/spec/models/procedure_presentation_spec.rb b/spec/models/procedure_presentation_spec.rb
index 1759d8525..0ae5de859 100644
--- a/spec/models/procedure_presentation_spec.rb
+++ b/spec/models/procedure_presentation_spec.rb
@@ -146,8 +146,8 @@ describe ProcedurePresentation do
let(:tartine_dossier) { create(:dossier, procedure: procedure) }
before do
- beurre_dossier.champs_public.first.update(value: 'beurre')
- tartine_dossier.champs_public.first.update(value: 'tartine')
+ beurre_dossier.project_champs_public.first.update(value: 'beurre')
+ tartine_dossier.project_champs_public.first.update(value: 'tartine')
end
context 'asc' do
@@ -176,8 +176,8 @@ describe ProcedurePresentation do
nothing_dossier
procedure.draft_revision.add_type_de_champ(tdc)
procedure.publish_revision!
- beurre_dossier.champs_public.last.update(value: 'beurre')
- tartine_dossier.champs_public.last.update(value: 'tartine')
+ beurre_dossier.project_champs_public.last.update(value: 'beurre')
+ tartine_dossier.project_champs_public.last.update(value: 'tartine')
end
context 'asc' do
@@ -201,8 +201,8 @@ describe ProcedurePresentation do
let(:vin_dossier) { create(:dossier, procedure: procedure) }
before do
- biere_dossier.champs_private.first.update(value: 'biere')
- vin_dossier.champs_private.first.update(value: 'vin')
+ biere_dossier.project_champs_private.first.update(value: 'biere')
+ vin_dossier.project_champs_private.first.update(value: 'vin')
end
context 'asc' do
@@ -231,8 +231,8 @@ describe ProcedurePresentation do
nothing_dossier
procedure.draft_revision.add_type_de_champ(tdc)
procedure.publish_revision!
- biere_dossier.champs_private.last.update(value: 'biere')
- vin_dossier.champs_private.last.update(value: 'vin')
+ biere_dossier.project_champs_private.last.update(value: 'biere')
+ vin_dossier.project_champs_private.last.update(value: 'vin')
end
context 'asc' do
@@ -592,8 +592,8 @@ describe ProcedurePresentation do
let(:value_column_searched) { ['postal_code'] }
before do
- kept_dossier.champs_public.find_by(stable_id: 1).update(value_json: { "postal_code" => value })
- create(:dossier, procedure: procedure).champs_public.find_by(stable_id: 1).update(value_json: { "postal_code" => "unknown" })
+ kept_dossier.project_champs_public.find { _1.stable_id == 1 }.update(value_json: { "postal_code" => value })
+ create(:dossier, procedure: procedure).project_champs_public.find { _1.stable_id == 1 }.update(value_json: { "postal_code" => "unknown" })
end
it { is_expected.to contain_exactly(kept_dossier.id) }
it 'describes column' do
@@ -607,8 +607,8 @@ describe ProcedurePresentation do
let(:value_column_searched) { ['departement_code'] }
before do
- kept_dossier.champs_public.find_by(stable_id: 1).update(value_json: { "departement_code" => value })
- create(:dossier, procedure: procedure).champs_public.find_by(stable_id: 1).update(value_json: { "departement_code" => "unknown" })
+ kept_dossier.project_champs_public.find { _1.stable_id == 1 }.update(value_json: { "departement_code" => value })
+ create(:dossier, procedure: procedure).project_champs_public.find { _1.stable_id == 1 }.update(value_json: { "departement_code" => "unknown" })
end
it { is_expected.to contain_exactly(kept_dossier.id) }
it 'describes column' do
@@ -622,8 +622,8 @@ describe ProcedurePresentation do
let(:value_column_searched) { ['region_name'] }
before do
- kept_dossier.champs_public.find_by(stable_id: 1).update(value_json: { "region_name" => value })
- create(:dossier, procedure: procedure).champs_public.find_by(stable_id: 1).update(value_json: { "region_name" => "unknown" })
+ kept_dossier.project_champs_public.find { _1.stable_id == 1 }.update(value_json: { "region_name" => value })
+ create(:dossier, procedure: procedure).project_champs_public.find { _1.stable_id == 1 }.update(value_json: { "region_name" => "unknown" })
end
it { is_expected.to contain_exactly(kept_dossier.id) }
it 'describes column' do
diff --git a/spec/policies/champ_policy_spec.rb b/spec/policies/champ_policy_spec.rb
index 4b86a4351..786956a2c 100644
--- a/spec/policies/champ_policy_spec.rb
+++ b/spec/policies/champ_policy_spec.rb
@@ -10,8 +10,8 @@ describe ChampPolicy do
subject { Pundit.policy_scope(account, Champ) }
- let(:champ) { dossier.champs_public.first }
- let(:champ_private) { dossier.champs_private.first }
+ let(:champ) { dossier.project_champs_public.first }
+ let(:champ_private) { dossier.project_champs_private.first }
shared_examples_for 'they can access a public champ' do
it { expect(subject.find_by(id: champ.id)).to eq(champ) }
diff --git a/spec/services/dossier_projection_service_spec.rb b/spec/services/dossier_projection_service_spec.rb
index fe402d066..1b577cf40 100644
--- a/spec/services/dossier_projection_service_spec.rb
+++ b/spec/services/dossier_projection_service_spec.rb
@@ -21,10 +21,10 @@ describe DossierProjectionService do
end
before do
- dossier_1.champs_public.first.update(value: 'champ_1')
- dossier_1.champs_public.second.update(value: '["test"]')
- dossier_2.champs_public.first.update(value: 'champ_2')
- dossier_3.champs_public.first.destroy
+ dossier_1.project_champs_public.first.update(value: 'champ_1')
+ dossier_1.project_champs_public.second.update(value: '["test"]')
+ dossier_2.project_champs_public.first.update(value: 'champ_2')
+ dossier_3.project_champs_public.first.destroy
end
let(:result) { subject }
@@ -65,7 +65,7 @@ describe DossierProjectionService do
end
before do
- dossier.champs_public.first.update(code_postal: '63290', external_id: '63102')
+ dossier.project_champs_public.first.update(code_postal: '63290', external_id: '63102')
end
let(:result) { subject }
@@ -185,7 +185,7 @@ describe DossierProjectionService do
let(:dossier) { create(:dossier) }
let(:column) { dossier.procedure.active_revision.types_de_champ_public.first.stable_id.to_s }
- before { dossier.champs_public.first.update(value: 'kale') }
+ before { dossier.project_champs_public.first.update(value: 'kale') }
it { is_expected.to eq('kale') }
end
@@ -195,7 +195,7 @@ describe DossierProjectionService do
let(:dossier) { create(:dossier) }
let(:column) { dossier.procedure.active_revision.types_de_champ_private.first.stable_id.to_s }
- before { dossier.champs_private.first.update(value: 'quinoa') }
+ before { dossier.project_champs_private.first.update(value: 'quinoa') }
it { is_expected.to eq('quinoa') }
end
@@ -206,7 +206,7 @@ describe DossierProjectionService do
let(:dossier) { create(:dossier, procedure: procedure) }
let(:column) { dossier.procedure.active_revision.types_de_champ_public.first.stable_id.to_s }
- before { dossier.champs_public.first.update(value: 'true') }
+ before { dossier.project_champs_public.first.update(value: 'true') }
it { is_expected.to eq('Oui') }
end
@@ -217,7 +217,7 @@ describe DossierProjectionService do
let(:dossier) { create(:dossier, procedure: procedure) }
let(:column) { dossier.procedure.active_revision.types_de_champ_public.first.stable_id.to_s }
- before { dossier.champs_public.first.update(value: '18 a la bonne rue', data: { 'label' => '18 a la bonne rue', 'departement' => 'd' }) }
+ before { dossier.project_champs_public.first.update(value: '18 a la bonne rue', data: { 'label' => '18 a la bonne rue', 'departement' => 'd' }) }
it { is_expected.to eq('18 a la bonne rue') }
end
@@ -236,7 +236,7 @@ describe DossierProjectionService do
context 'when external id is set' do
before do
- dossier.champs_public.first.update(external_id: 'GB')
+ dossier.project_champs_public.first.update(external_id: 'GB')
end
it { is_expected.to eq('Royaume-Uni') }
@@ -244,7 +244,7 @@ describe DossierProjectionService do
context 'when no external id is set' do
before do
- dossier.champs_public.first.update(value: "qu'il est beau mon pays")
+ dossier.project_champs_public.first.update(value: "qu'il est beau mon pays")
end
it { is_expected.to eq("") }
diff --git a/spec/services/pieces_justificatives_service_spec.rb b/spec/services/pieces_justificatives_service_spec.rb
index 61661ece2..1c0979043 100644
--- a/spec/services/pieces_justificatives_service_spec.rb
+++ b/spec/services/pieces_justificatives_service_spec.rb
@@ -10,7 +10,7 @@ describe PiecesJustificativesService do
let(:pj_service) { PiecesJustificativesService.new(user_profile:, export_template:) }
let(:user_profile) { build(:administrateur) }
- def pj_champ(d) = d.champs_public.find_by(type: 'Champs::PieceJustificativeChamp')
+ def pj_champ(d) = d.project_champs_public.find { _1.type == 'Champs::PieceJustificativeChamp' }
def repetition(d) = d.champs.find_by(type: "Champs::RepetitionChamp")
def attachments(champ) = champ.piece_justificative_file.attachments
@@ -102,7 +102,7 @@ describe PiecesJustificativesService do
let(:user_profile) { build(:administrateur) }
let(:procedure) { create(:procedure, types_de_champ_public: [{ type: :piece_justificative }]) }
let(:witness) { create(:dossier, procedure: procedure) }
- def pj_champ(d) = d.champs_public.find { |c| c.type == 'Champs::PieceJustificativeChamp' }
+ def pj_champ(d) = d.project_champs_public.find { |c| c.type == 'Champs::PieceJustificativeChamp' }
context 'with a single attachment' do
before do
@@ -143,7 +143,7 @@ describe PiecesJustificativesService do
let(:procedure) { create(:procedure, types_de_champ_public: [{ type: :titre_identite }]) }
let(:dossier) { create(:dossier, procedure: procedure) }
- let(:champ_identite) { dossier.champs_public.find { |c| c.type == 'Champs::TitreIdentiteChamp' } }
+ let(:champ_identite) { dossier.project_champs_public.find { |c| c.type == 'Champs::TitreIdentiteChamp' } }
before { attach_file_to_champ(champ_identite) }
@@ -260,7 +260,7 @@ describe PiecesJustificativesService do
let(:witness) { create(:dossier, procedure: procedure) }
let!(:private_pj) { create(:type_de_champ_piece_justificative, procedure: procedure, private: true) }
- def private_pj_champ(d) = d.champs_private.find { |c| c.type == 'Champs::PieceJustificativeChamp' }
+ def private_pj_champ(d) = d.project_champs_private.find { |c| c.type == 'Champs::PieceJustificativeChamp' }
before do
attach_file_to_champ(private_pj_champ(dossier))
@@ -503,8 +503,8 @@ describe PiecesJustificativesService do
let(:dossier_1) { create(:dossier, procedure:) }
let(:champs) { dossier_1.champs }
- def pj_champ(d) = d.champs_public.find_by(type: 'Champs::PieceJustificativeChamp')
- def repetition(d, index:) = d.champs_public.filter(&:repetition?)[index]
+ def pj_champ(d) = d.project_champs_public.find { _1.type == 'Champs::PieceJustificativeChamp' }
+ def repetition(d, index:) = d.project_champs_public.filter(&:repetition?)[index]
subject { PiecesJustificativesService.new(user_profile:, export_template: nil).send(:compute_champ_id_row_index, champs) }
@@ -535,7 +535,7 @@ describe PiecesJustificativesService do
end
it do
- champs = dossier_1.champs_public
+ champs = dossier_1.project_champs_public
repet_0 = champs[0]
pj_0 = repet_0.rows.first.first
pj_1 = repet_0.rows.second.first
diff --git a/spec/services/procedure_export_service_spec.rb b/spec/services/procedure_export_service_spec.rb
index 34cecb9f1..f44545c38 100644
--- a/spec/services/procedure_export_service_spec.rb
+++ b/spec/services/procedure_export_service_spec.rb
@@ -155,7 +155,7 @@ describe ProcedureExportService do
let!(:dossier) { create(:dossier, :en_instruction, :with_populated_champs, :with_individual, procedure:) }
let!(:dossier_2) { create(:dossier, :en_instruction, :with_populated_champs, :with_individual, procedure:) }
before do
- dossier_2.champs_public
+ dossier_2.project_champs_public
.find { _1.is_a? Champs::PieceJustificativeChamp }
.piece_justificative_file
.attach(io: StringIO.new("toto"), filename: "toto.txt", content_type: "text/plain")
@@ -351,7 +351,7 @@ describe ProcedureExportService do
create(:dossier, :en_instruction, :with_populated_champs, :with_individual, procedure: procedure)
]
end
- let(:champ_repetition) { dossiers.first.champs_public.find { |champ| champ.type_champ == 'repetition' } }
+ let(:champ_repetition) { dossiers.first.project_champs_public.find { |champ| champ.type_champ == 'repetition' } }
it 'should have sheets' do
expect(subject.sheets.map(&:name)).to eq(['Dossiers', 'Etablissements', 'Avis', champ_repetition.type_de_champ.libelle_for_export])
@@ -416,7 +416,7 @@ describe ProcedureExportService do
context 'with empty repetition' do
before do
- dossiers.flat_map { |dossier| dossier.champs_public.filter(&:repetition?) }.each do |champ|
+ dossiers.flat_map { |dossier| dossier.project_champs_public.filter(&:repetition?) }.each do |champ|
Champ.where(row_id: champ.row_ids).destroy_all
end
end
@@ -520,7 +520,7 @@ describe ProcedureExportService do
end
let(:dossier) { create(:dossier, :en_instruction, :with_populated_champs, :with_individual, procedure: procedure) }
- let(:champ_carte) { dossier.champs_public.find(&:carte?) }
+ let(:champ_carte) { dossier.project_champs_public.find(&:carte?) }
let(:properties) { subject['features'].first['properties'] }
before do
diff --git a/spec/services/procedure_export_service_zip_spec.rb b/spec/services/procedure_export_service_zip_spec.rb
index 696a62067..44602784e 100644
--- a/spec/services/procedure_export_service_zip_spec.rb
+++ b/spec/services/procedure_export_service_zip_spec.rb
@@ -7,7 +7,7 @@ describe ProcedureExportService do
let(:export_template) { create(:export_template, :enabled_pjs, groupe_instructeur: procedure.defaut_groupe_instructeur) }
let(:service) { ProcedureExportService.new(procedure, procedure.dossiers, instructeur, export_template) }
- def pj_champ(d) = d.champs_public.find_by(type: 'Champs::PieceJustificativeChamp')
+ def pj_champ(d) = d.project_champs_public.find { _1.type == 'Champs::PieceJustificativeChamp' }
def repetition(d) = d.champs.find_by(type: "Champs::RepetitionChamp")
def attachments(champ) = champ.piece_justificative_file.attachments
diff --git a/spec/system/api_particulier/api_particulier_spec.rb b/spec/system/api_particulier/api_particulier_spec.rb
index 40b06aabb..a2ad90dcf 100644
--- a/spec/system/api_particulier/api_particulier_spec.rb
+++ b/spec/system/api_particulier/api_particulier_spec.rb
@@ -282,7 +282,7 @@ describe 'fetch API Particulier Data', js: true do
fill_in 'Le code postal', with: 'wrong_code'
dossier = Dossier.last
- cnaf_champ = dossier.champs_public.find(&:cnaf?)
+ cnaf_champ = dossier.project_champs_public.find(&:cnaf?)
wait_until { cnaf_champ.reload.code_postal == 'wrong_code' }
@@ -342,7 +342,7 @@ describe 'fetch API Particulier Data', js: true do
fill_in "Identifiant", with: 'wrong code'
dossier = Dossier.last
- pole_emploi_champ = dossier.champs_public.find(&:pole_emploi?)
+ pole_emploi_champ = dossier.project_champs_public.find(&:pole_emploi?)
wait_until { pole_emploi_champ.reload.identifiant == 'wrong code' }
@@ -418,7 +418,7 @@ describe 'fetch API Particulier Data', js: true do
fill_in "INE", with: 'wrong code'
dossier = Dossier.last
- mesri_champ = dossier.champs_public.find(&:mesri?)
+ mesri_champ = dossier.project_champs_public.find(&:mesri?)
wait_until { mesri_champ.reload.ine == 'wrong code' }
clear_enqueued_jobs
@@ -485,7 +485,7 @@ describe 'fetch API Particulier Data', js: true do
fill_in "La référence d’avis d’imposition", with: 'wrong_code'
dossier = Dossier.last
- dgfip_champ = dossier.champs_public.find(&:dgfip?)
+ dgfip_champ = dossier.project_champs_public.find(&:dgfip?)
wait_until { dgfip_champ.reload.reference_avis == 'wrong_code' }
diff --git a/spec/system/instructeurs/instruction_spec.rb b/spec/system/instructeurs/instruction_spec.rb
index d56c107b6..62390e084 100644
--- a/spec/system/instructeurs/instruction_spec.rb
+++ b/spec/system/instructeurs/instruction_spec.rb
@@ -214,7 +214,7 @@ describe 'Instructing a dossier:', js: true do
context 'with dossiers having attached files' do
let(:procedure) { create(:procedure, :published, types_de_champ_public: [{ type: :piece_justificative }], instructeurs: [instructeur]) }
let(:dossier) { create(:dossier, :en_construction, procedure: procedure) }
- let(:champ) { dossier.champs_public.first }
+ let(:champ) { dossier.project_champs_public.first }
let(:path) { 'spec/fixtures/files/piece_justificative_0.pdf' }
let(:commentaire) { create(:commentaire, instructeur: instructeur, dossier: dossier) }
diff --git a/spec/system/instructeurs/procedure_sort_spec.rb b/spec/system/instructeurs/procedure_sort_spec.rb
index 3f3c4342d..166b42105 100644
--- a/spec/system/instructeurs/procedure_sort_spec.rb
+++ b/spec/system/instructeurs/procedure_sort_spec.rb
@@ -10,7 +10,7 @@ describe "procedure sort", js: true do
before do
instructeur.follow(followed_dossier)
instructeur.follow(followed_dossier_2)
- followed_dossier.champs_public.first.update(value: '123') # touch the dossier
+ followed_dossier.project_champs_public.first.update(value: '123') # touch the dossier
login_as(instructeur.user, scope: :user)
visit instructeur_procedure_path(procedure, statut: "suivis")
diff --git a/spec/system/routing/rules_full_scenario_spec.rb b/spec/system/routing/rules_full_scenario_spec.rb
index 3a418560c..d688f2457 100644
--- a/spec/system/routing/rules_full_scenario_spec.rb
+++ b/spec/system/routing/rules_full_scenario_spec.rb
@@ -186,7 +186,7 @@ describe 'The routing with rules', js: true do
click_on litteraire_user.dossiers.first.procedure.libelle
click_on 'Modifier mon dossier'
- fill_in litteraire_user.dossiers.first.champs_public.first.libelle, with: 'some value'
+ fill_in litteraire_user.dossiers.first.project_champs_public.first.libelle, with: 'some value'
wait_for_autosave
click_on 'Déposer les modifications'
diff --git a/spec/system/users/brouillon_spec.rb b/spec/system/users/brouillon_spec.rb
index c03ff3a07..ade916005 100644
--- a/spec/system/users/brouillon_spec.rb
+++ b/spec/system/users/brouillon_spec.rb
@@ -674,7 +674,7 @@ describe 'The user', js: true do
end
def champ_for(libelle)
- champs = user_dossier.reload.champs_public
+ champs = user_dossier.reload.project_champs_public
champ = champs.find { |c| c.libelle == libelle }
champ.reload
end
diff --git a/spec/system/users/dropdown_spec.rb b/spec/system/users/dropdown_spec.rb
index aaed8c34a..2a442f706 100644
--- a/spec/system/users/dropdown_spec.rb
+++ b/spec/system/users/dropdown_spec.rb
@@ -35,13 +35,13 @@ describe 'dropdown list with other option activated', js: true do
choose I18n.t('shared.champs.drop_down_list.other')
fill_in(I18n.t('shared.champs.drop_down_list.other_label'), with: "My choice")
- wait_until { user_dossier.champs_public.first.value == "My choice" }
- expect(user_dossier.champs_public.first.value).to eq("My choice")
+ wait_until { user_dossier.reload.project_champs_public.first.value == "My choice" }
+ expect(user_dossier.project_champs_public.first.value).to eq("My choice")
choose "Secondary 1.1"
- wait_until { user_dossier.champs_public.first.value == "Secondary 1.1" }
- expect(user_dossier.champs_public.first.value).to eq("Secondary 1.1")
+ wait_until { user_dossier.reload.project_champs_public.first.value == "Secondary 1.1" }
+ expect(user_dossier.project_champs_public.first.value).to eq("Secondary 1.1")
end
end
@@ -68,8 +68,8 @@ describe 'dropdown list with other option activated', js: true do
select("Secondary 1.2")
expect(page).to have_selector(".autosave-status.succeeded", visible: true)
- wait_until { user_dossier.champs_public.first.value == "Secondary 1.2" }
- expect(user_dossier.champs_public.first.value).to eq("Secondary 1.2")
+ wait_until { user_dossier.reload.project_champs_public.first.value == "Secondary 1.2" }
+ expect(user_dossier.project_champs_public.first.value).to eq("Secondary 1.2")
end
end
diff --git a/spec/system/users/en_construction_spec.rb b/spec/system/users/en_construction_spec.rb
index f34e8c993..ba9d06788 100644
--- a/spec/system/users/en_construction_spec.rb
+++ b/spec/system/users/en_construction_spec.rb
@@ -10,7 +10,7 @@ describe "Dossier en_construction", js: true do
}
let(:champ) {
- dossier.find_editing_fork(dossier.user).champs_public.find { _1.stable_id == tdc.stable_id }
+ dossier.find_editing_fork(dossier.user).project_champs_public.find { _1.stable_id == tdc.stable_id }
}
scenario 'delete a non mandatory piece justificative' do
diff --git a/spec/system/users/invite_spec.rb b/spec/system/users/invite_spec.rb
index 95e1a08b6..4caa306ca 100644
--- a/spec/system/users/invite_spec.rb
+++ b/spec/system/users/invite_spec.rb
@@ -175,7 +175,7 @@ describe 'Invitations' do
end
it "can search something inside the dossier and it displays the dossier" do
- page.find_by_id('q').set(dossier_2.champs_public.first.value)
+ page.find_by_id('q').set(dossier_2.project_champs_public.first.value)
find('.fr-search-bar .fr-btn').click
expect(current_path).to eq(dossiers_path)
expect(page).to have_link(dossier.procedure.libelle)
diff --git a/spec/system/users/list_dossiers_spec.rb b/spec/system/users/list_dossiers_spec.rb
index 5d4cc3eac..dc3f5de5d 100644
--- a/spec/system/users/list_dossiers_spec.rb
+++ b/spec/system/users/list_dossiers_spec.rb
@@ -306,7 +306,7 @@ describe 'user access to the list of their dossiers', js: true do
context "when user search for something inside the dossier" do
before do
- page.find_by_id('q').set(dossier_en_construction.champs_public.first.value)
+ page.find_by_id('q').set(dossier_en_construction.project_champs_public.first.value)
end
context 'when it matches multiple dossiers' do
@@ -336,7 +336,7 @@ describe 'user access to the list of their dossiers', js: true do
click_on 'Afficher'
expect(page).not_to have_link(String(dossier_en_construction.id))
expect(page).not_to have_link(String(dossier_with_champs.id))
- expect(page).to have_content("Résultat de la recherche pour « #{dossier_en_construction.champs_public.first.value} » et pour la procédure « #{dossier_brouillon.procedure.libelle} » ")
+ expect(page).to have_content("Résultat de la recherche pour « #{dossier_en_construction.project_champs_public.first.value} » et pour la procédure « #{dossier_brouillon.procedure.libelle} » ")
expect(page).to have_text("Aucun dossier")
end
end
diff --git a/spec/tasks/maintenance/backfill_cloned_champs_private_piece_justificatives_task_spec.rb b/spec/tasks/maintenance/backfill_cloned_champs_private_piece_justificatives_task_spec.rb
index 2029c1991..e34dcf848 100644
--- a/spec/tasks/maintenance/backfill_cloned_champs_private_piece_justificatives_task_spec.rb
+++ b/spec/tasks/maintenance/backfill_cloned_champs_private_piece_justificatives_task_spec.rb
@@ -11,8 +11,8 @@ module Maintenance
let(:parent_dossier) { create(:dossier, procedure:) }
let(:cloned_dossier) { create(:dossier, procedure:) }
- let(:parent_champ_pj) { parent_dossier.champs_private.find(&:piece_justificative?) }
- let(:cloned_champ_pj) { cloned_dossier.champs_private.find(&:piece_justificative?) }
+ let(:parent_champ_pj) { parent_dossier.project_champs_private.find(&:piece_justificative?) }
+ let(:cloned_champ_pj) { cloned_dossier.project_champs_private.find(&:piece_justificative?) }
before do
cloned_dossier.update(parent_dossier:) # used on factorie, does not seed private_champs..
diff --git a/spec/views/shared/dossiers/_champs.html.haml_spec.rb b/spec/views/shared/dossiers/_champs.html.haml_spec.rb
index 93bfbebb5..6d250ceaa 100644
--- a/spec/views/shared/dossiers/_champs.html.haml_spec.rb
+++ b/spec/views/shared/dossiers/_champs.html.haml_spec.rb
@@ -21,12 +21,12 @@ describe 'shared/dossiers/champs', type: :view do
context "there are some champs" do
let(:types_de_champ_public) { [{ type: :checkbox }, { type: :header_section }, { type: :explication }, { type: :dossier_link }, { type: :textarea }, { type: :rna }] }
- let(:champ1) { dossier.champs[0] }
- let(:champ2) { dossier.champs[1] }
- let(:champ3) { dossier.champs[2] }
- let(:champ4) { dossier.champs[3] }
- let(:champ5) { dossier.champs[4] }
- let(:champ6) { dossier.champs[5] }
+ let(:champ1) { dossier.project_champs_public[0] }
+ let(:champ2) { dossier.project_champs_public[1] }
+ let(:champ3) { dossier.project_champs_public[2] }
+ let(:champ4) { dossier.project_champs_public[3] }
+ let(:champ5) { dossier.project_champs_public[4] }
+ let(:champ6) { dossier.project_champs_public[5] }
before do
champ1.update(value: 'true')
@@ -57,8 +57,8 @@ describe 'shared/dossiers/champs', type: :view do
context "with auto-link" do
let(:types_de_champ_public) { [{ type: :text }, { type: :textarea }] }
- let(:champ1) { dossier.champs[0] }
- let(:champ2) { dossier.champs[1] }
+ let(:champ1) { dossier.project_champs_public.first }
+ let(:champ2) { dossier.project_champs_public.second }
before do
champ1.update(value: 'https://github.com/tchak')
@@ -118,8 +118,8 @@ describe 'shared/dossiers/champs', type: :view do
context "with seen_at" do
let(:types_de_champ_public) { [{ type: :checkbox }] }
- let(:dossier) { create(:dossier, :en_construction, :with_populated_champs, procedure:, depose_at: 1.day.ago) }
- let(:champ1) { dossier.champs[0] }
+ let(:dossier) { create(:dossier, :en_construction, :with_populated_champs, procedure:, depose_at: 1.day.ago.change(usec: 0)) }
+ let(:champ1) { dossier.champs.first }
context "with a demande_seen_at after champ updated_at" do
let(:demande_seen_at) { champ1.updated_at + 1.hour }
@@ -127,21 +127,20 @@ describe 'shared/dossiers/champs', type: :view do
it { is_expected.not_to have_css(".fr-badge--new") }
end
- context "with champ updated_at at depose_at" do
- let(:champ1) { dossier.champs[0] }
- let(:demande_seen_at) { champ1.updated_at - 1.hour }
-
- before do
- champ1.update(value: 'false', updated_at: dossier.depose_at)
- end
-
- it { is_expected.not_to have_css(".fr-badge--new") }
- end
-
- context "with a demande_seen_at after champ updated_at" do
+ context "with a demande_seen_at before champ updated_at" do
let(:demande_seen_at) { champ1.updated_at - 1.hour }
it { is_expected.to have_css(".fr-badge--new") }
end
+
+ context "with champ updated_at at depose_at" do
+ let(:demande_seen_at) { champ1.updated_at - 1.hour }
+
+ before do
+ champ1.update_columns(value: 'false', updated_at: dossier.depose_at)
+ end
+
+ it { is_expected.not_to have_css(".fr-badge--new") }
+ end
end
end
diff --git a/spec/views/shared/dossiers/_demande.html.haml_spec.rb b/spec/views/shared/dossiers/_demande.html.haml_spec.rb
index 8475cc469..5760764e2 100644
--- a/spec/views/shared/dossiers/_demande.html.haml_spec.rb
+++ b/spec/views/shared/dossiers/_demande.html.haml_spec.rb
@@ -48,7 +48,7 @@ describe 'shared/dossiers/demande', type: :view do
let(:procedure) { create(:procedure, :published, :with_type_de_champ) }
it 'renders the champs' do
- dossier.champs_public.each do |champ|
+ dossier.project_champs_public.each do |champ|
expect(subject).to include(champ.libelle)
end
end
@@ -57,7 +57,7 @@ describe 'shared/dossiers/demande', type: :view do
context 'when a champ is freshly build' do
let(:procedure) { create(:procedure, :published, :with_type_de_champ) }
before do
- dossier.champs_public.first.destroy
+ dossier.project_champs_public.first.destroy
end
it 'renders without error' do
diff --git a/spec/views/shared/dossiers/_edit.html.haml_spec.rb b/spec/views/shared/dossiers/_edit.html.haml_spec.rb
index c974ecc0d..efccf5c7d 100644
--- a/spec/views/shared/dossiers/_edit.html.haml_spec.rb
+++ b/spec/views/shared/dossiers/_edit.html.haml_spec.rb
@@ -44,7 +44,7 @@ describe 'shared/dossiers/edit', type: :view do
context 'with a single-value list' do
let(:types_de_champ_public) { [{ type: :drop_down_list, options:, mandatory: }] }
- let(:champ) { dossier.champs_public.first }
+ let(:champ) { dossier.project_champs_public.first }
let(:type_de_champ) { champ.type_de_champ }
let(:enabled_options) { type_de_champ.drop_down_options }
let(:mandatory) { true }