From e8f3fda1f0a6fdca3c63781975684478161c1eea Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Tue, 13 Feb 2018 18:18:20 +0100 Subject: [PATCH 1/3] Add STI champ models --- app/models/champ.rb | 2 -- app/models/champs/address_champ.rb | 2 ++ app/models/champs/checkbox_champ.rb | 2 ++ app/models/champs/civilite_champ.rb | 2 ++ app/models/champs/date_champ.rb | 2 ++ app/models/champs/datetime_champ.rb | 2 ++ app/models/champs/departement_champ.rb | 2 ++ app/models/champs/dossier_link_champ.rb | 2 ++ app/models/champs/drop_down_list_champ.rb | 2 ++ app/models/champs/email_champ.rb | 2 ++ app/models/champs/engagement_champ.rb | 2 ++ app/models/champs/explication_champ.rb | 2 ++ app/models/champs/header_section_champ.rb | 2 ++ app/models/champs/multiple_drop_down_list_champ.rb | 2 ++ app/models/champs/number_champ.rb | 2 ++ app/models/champs/pays_champ.rb | 2 ++ app/models/champs/phone_champ.rb | 2 ++ app/models/champs/piece_justificative_champ.rb | 2 ++ app/models/champs/region_champ.rb | 2 ++ app/models/champs/text_champ.rb | 2 ++ app/models/champs/textarea_champ.rb | 2 ++ app/models/champs/yes_no_champ.rb | 2 ++ 22 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 app/models/champs/address_champ.rb create mode 100644 app/models/champs/checkbox_champ.rb create mode 100644 app/models/champs/civilite_champ.rb create mode 100644 app/models/champs/date_champ.rb create mode 100644 app/models/champs/datetime_champ.rb create mode 100644 app/models/champs/departement_champ.rb create mode 100644 app/models/champs/dossier_link_champ.rb create mode 100644 app/models/champs/drop_down_list_champ.rb create mode 100644 app/models/champs/email_champ.rb create mode 100644 app/models/champs/engagement_champ.rb create mode 100644 app/models/champs/explication_champ.rb create mode 100644 app/models/champs/header_section_champ.rb create mode 100644 app/models/champs/multiple_drop_down_list_champ.rb create mode 100644 app/models/champs/number_champ.rb create mode 100644 app/models/champs/pays_champ.rb create mode 100644 app/models/champs/phone_champ.rb create mode 100644 app/models/champs/piece_justificative_champ.rb create mode 100644 app/models/champs/region_champ.rb create mode 100644 app/models/champs/text_champ.rb create mode 100644 app/models/champs/textarea_champ.rb create mode 100644 app/models/champs/yes_no_champ.rb diff --git a/app/models/champ.rb b/app/models/champ.rb index c1ff823f5..d9c32362a 100644 --- a/app/models/champ.rb +++ b/app/models/champ.rb @@ -1,6 +1,4 @@ class Champ < ApplicationRecord - self.inheritance_column = :_type_disabled - belongs_to :dossier, touch: true belongs_to :type_de_champ, inverse_of: :champ has_many :commentaires diff --git a/app/models/champs/address_champ.rb b/app/models/champs/address_champ.rb new file mode 100644 index 000000000..1c27b3a71 --- /dev/null +++ b/app/models/champs/address_champ.rb @@ -0,0 +1,2 @@ +class Champs::AddressChamp < Champs::TextChamp +end diff --git a/app/models/champs/checkbox_champ.rb b/app/models/champs/checkbox_champ.rb new file mode 100644 index 000000000..dcf99beca --- /dev/null +++ b/app/models/champs/checkbox_champ.rb @@ -0,0 +1,2 @@ +class Champs::CheckboxChamp < Champ +end diff --git a/app/models/champs/civilite_champ.rb b/app/models/champs/civilite_champ.rb new file mode 100644 index 000000000..9404e46a1 --- /dev/null +++ b/app/models/champs/civilite_champ.rb @@ -0,0 +1,2 @@ +class Champs::CiviliteChamp < Champ +end diff --git a/app/models/champs/date_champ.rb b/app/models/champs/date_champ.rb new file mode 100644 index 000000000..7b391c5e9 --- /dev/null +++ b/app/models/champs/date_champ.rb @@ -0,0 +1,2 @@ +class Champs::DateChamp < Champ +end diff --git a/app/models/champs/datetime_champ.rb b/app/models/champs/datetime_champ.rb new file mode 100644 index 000000000..8b5c9c73f --- /dev/null +++ b/app/models/champs/datetime_champ.rb @@ -0,0 +1,2 @@ +class Champs::DatetimeChamp < Champ +end diff --git a/app/models/champs/departement_champ.rb b/app/models/champs/departement_champ.rb new file mode 100644 index 000000000..ee9803389 --- /dev/null +++ b/app/models/champs/departement_champ.rb @@ -0,0 +1,2 @@ +class Champs::DepartementChamp < Champs::TextChamp +end diff --git a/app/models/champs/dossier_link_champ.rb b/app/models/champs/dossier_link_champ.rb new file mode 100644 index 000000000..d8bc25e73 --- /dev/null +++ b/app/models/champs/dossier_link_champ.rb @@ -0,0 +1,2 @@ +class Champs::DossierLinkChamp < Champ +end diff --git a/app/models/champs/drop_down_list_champ.rb b/app/models/champs/drop_down_list_champ.rb new file mode 100644 index 000000000..df3d14dfc --- /dev/null +++ b/app/models/champs/drop_down_list_champ.rb @@ -0,0 +1,2 @@ +class Champs::DropDownListChamp < Champ +end diff --git a/app/models/champs/email_champ.rb b/app/models/champs/email_champ.rb new file mode 100644 index 000000000..5f5f36104 --- /dev/null +++ b/app/models/champs/email_champ.rb @@ -0,0 +1,2 @@ +class Champs::EmailChamp < Champs::TextChamp +end diff --git a/app/models/champs/engagement_champ.rb b/app/models/champs/engagement_champ.rb new file mode 100644 index 000000000..5f33b9084 --- /dev/null +++ b/app/models/champs/engagement_champ.rb @@ -0,0 +1,2 @@ +class Champs::EngagementChamp < Champs::CheckboxChamp +end diff --git a/app/models/champs/explication_champ.rb b/app/models/champs/explication_champ.rb new file mode 100644 index 000000000..21e3969cf --- /dev/null +++ b/app/models/champs/explication_champ.rb @@ -0,0 +1,2 @@ +class Champs::ExplicationChamp < Champs::TextChamp +end diff --git a/app/models/champs/header_section_champ.rb b/app/models/champs/header_section_champ.rb new file mode 100644 index 000000000..9d070e1ae --- /dev/null +++ b/app/models/champs/header_section_champ.rb @@ -0,0 +1,2 @@ +class Champs::HeaderSectionChamp < Champ +end diff --git a/app/models/champs/multiple_drop_down_list_champ.rb b/app/models/champs/multiple_drop_down_list_champ.rb new file mode 100644 index 000000000..5182673b5 --- /dev/null +++ b/app/models/champs/multiple_drop_down_list_champ.rb @@ -0,0 +1,2 @@ +class Champs::MultipleDropDownListChamp < Champ +end diff --git a/app/models/champs/number_champ.rb b/app/models/champs/number_champ.rb new file mode 100644 index 000000000..8903284e2 --- /dev/null +++ b/app/models/champs/number_champ.rb @@ -0,0 +1,2 @@ +class Champs::NumberChamp < Champ +end diff --git a/app/models/champs/pays_champ.rb b/app/models/champs/pays_champ.rb new file mode 100644 index 000000000..95b89893f --- /dev/null +++ b/app/models/champs/pays_champ.rb @@ -0,0 +1,2 @@ +class Champs::PaysChamp < Champs::TextChamp +end diff --git a/app/models/champs/phone_champ.rb b/app/models/champs/phone_champ.rb new file mode 100644 index 000000000..42c02151f --- /dev/null +++ b/app/models/champs/phone_champ.rb @@ -0,0 +1,2 @@ +class Champs::PhoneChamp < Champs::TextChamp +end diff --git a/app/models/champs/piece_justificative_champ.rb b/app/models/champs/piece_justificative_champ.rb new file mode 100644 index 000000000..83718ab29 --- /dev/null +++ b/app/models/champs/piece_justificative_champ.rb @@ -0,0 +1,2 @@ +class Champs::PieceJustificativeChamp < Champ +end diff --git a/app/models/champs/region_champ.rb b/app/models/champs/region_champ.rb new file mode 100644 index 000000000..ba9045087 --- /dev/null +++ b/app/models/champs/region_champ.rb @@ -0,0 +1,2 @@ +class Champs::RegionChamp < Champs::TextChamp +end diff --git a/app/models/champs/text_champ.rb b/app/models/champs/text_champ.rb new file mode 100644 index 000000000..8e24252ce --- /dev/null +++ b/app/models/champs/text_champ.rb @@ -0,0 +1,2 @@ +class Champs::TextChamp < Champ +end diff --git a/app/models/champs/textarea_champ.rb b/app/models/champs/textarea_champ.rb new file mode 100644 index 000000000..eedaac8b1 --- /dev/null +++ b/app/models/champs/textarea_champ.rb @@ -0,0 +1,2 @@ +class Champs::TextareaChamp < Champs::TextChamp +end diff --git a/app/models/champs/yes_no_champ.rb b/app/models/champs/yes_no_champ.rb new file mode 100644 index 000000000..6653a50d4 --- /dev/null +++ b/app/models/champs/yes_no_champ.rb @@ -0,0 +1,2 @@ +class Champs::YesNoChamp < Champs::CheckboxChamp +end From a9f078265ab58cfb90824dd71203f2a503c86c98 Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Wed, 14 Feb 2018 15:12:25 +0100 Subject: [PATCH 2/3] Add STI types de champ models --- app/models/type_de_champ.rb | 2 -- app/models/types_de_champ/address_type_de_champ.rb | 2 ++ app/models/types_de_champ/checkbox_type_de_champ.rb | 2 ++ app/models/types_de_champ/civilite_type_de_champ.rb | 2 ++ app/models/types_de_champ/date_type_de_champ.rb | 2 ++ app/models/types_de_champ/datetime_type_de_champ.rb | 2 ++ app/models/types_de_champ/departement_type_de_champ.rb | 2 ++ app/models/types_de_champ/dossier_link_type_de_champ.rb | 2 ++ app/models/types_de_champ/drop_down_list_type_de_champ.rb | 2 ++ app/models/types_de_champ/email_type_de_champ.rb | 2 ++ app/models/types_de_champ/engagement_type_de_champ.rb | 2 ++ app/models/types_de_champ/explication_type_de_champ.rb | 2 ++ app/models/types_de_champ/header_section_type_de_champ.rb | 2 ++ .../types_de_champ/multiple_drop_down_list_type_de_champ.rb | 2 ++ app/models/types_de_champ/number_type_de_champ.rb | 2 ++ app/models/types_de_champ/pays_type_de_champ.rb | 2 ++ app/models/types_de_champ/phone_type_de_champ.rb | 2 ++ app/models/types_de_champ/piece_justificative_type_de_champ.rb | 2 ++ app/models/types_de_champ/region_type_de_champ.rb | 2 ++ app/models/types_de_champ/text_type_de_champ.rb | 2 ++ app/models/types_de_champ/textarea_type_de_champ.rb | 2 ++ app/models/types_de_champ/yes_no_type_de_champ.rb | 2 ++ 22 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 app/models/types_de_champ/address_type_de_champ.rb create mode 100644 app/models/types_de_champ/checkbox_type_de_champ.rb create mode 100644 app/models/types_de_champ/civilite_type_de_champ.rb create mode 100644 app/models/types_de_champ/date_type_de_champ.rb create mode 100644 app/models/types_de_champ/datetime_type_de_champ.rb create mode 100644 app/models/types_de_champ/departement_type_de_champ.rb create mode 100644 app/models/types_de_champ/dossier_link_type_de_champ.rb create mode 100644 app/models/types_de_champ/drop_down_list_type_de_champ.rb create mode 100644 app/models/types_de_champ/email_type_de_champ.rb create mode 100644 app/models/types_de_champ/engagement_type_de_champ.rb create mode 100644 app/models/types_de_champ/explication_type_de_champ.rb create mode 100644 app/models/types_de_champ/header_section_type_de_champ.rb create mode 100644 app/models/types_de_champ/multiple_drop_down_list_type_de_champ.rb create mode 100644 app/models/types_de_champ/number_type_de_champ.rb create mode 100644 app/models/types_de_champ/pays_type_de_champ.rb create mode 100644 app/models/types_de_champ/phone_type_de_champ.rb create mode 100644 app/models/types_de_champ/piece_justificative_type_de_champ.rb create mode 100644 app/models/types_de_champ/region_type_de_champ.rb create mode 100644 app/models/types_de_champ/text_type_de_champ.rb create mode 100644 app/models/types_de_champ/textarea_type_de_champ.rb create mode 100644 app/models/types_de_champ/yes_no_type_de_champ.rb diff --git a/app/models/type_de_champ.rb b/app/models/type_de_champ.rb index ac4eaffe4..a10e445a7 100644 --- a/app/models/type_de_champ.rb +++ b/app/models/type_de_champ.rb @@ -1,6 +1,4 @@ class TypeDeChamp < ApplicationRecord - self.inheritance_column = :_type_disabled - enum type_champs: { text: 'text', textarea: 'textarea', diff --git a/app/models/types_de_champ/address_type_de_champ.rb b/app/models/types_de_champ/address_type_de_champ.rb new file mode 100644 index 000000000..d1d82c0d9 --- /dev/null +++ b/app/models/types_de_champ/address_type_de_champ.rb @@ -0,0 +1,2 @@ +class TypesDeChamp::AddressTypeDeChamp < TypesDeChamp::TextTypeDeChamp +end diff --git a/app/models/types_de_champ/checkbox_type_de_champ.rb b/app/models/types_de_champ/checkbox_type_de_champ.rb new file mode 100644 index 000000000..498c2ef7d --- /dev/null +++ b/app/models/types_de_champ/checkbox_type_de_champ.rb @@ -0,0 +1,2 @@ +class TypesDeChamp::CheckboxTypeDeChamp < TypeDeChamp +end diff --git a/app/models/types_de_champ/civilite_type_de_champ.rb b/app/models/types_de_champ/civilite_type_de_champ.rb new file mode 100644 index 000000000..d252cf452 --- /dev/null +++ b/app/models/types_de_champ/civilite_type_de_champ.rb @@ -0,0 +1,2 @@ +class TypesDeChamp::CiviliteTypeDeChamp < TypeDeChamp +end diff --git a/app/models/types_de_champ/date_type_de_champ.rb b/app/models/types_de_champ/date_type_de_champ.rb new file mode 100644 index 000000000..8d87350ed --- /dev/null +++ b/app/models/types_de_champ/date_type_de_champ.rb @@ -0,0 +1,2 @@ +class TypesDeChamp::DateTypeDeChamp < TypeDeChamp +end diff --git a/app/models/types_de_champ/datetime_type_de_champ.rb b/app/models/types_de_champ/datetime_type_de_champ.rb new file mode 100644 index 000000000..e2a9406b3 --- /dev/null +++ b/app/models/types_de_champ/datetime_type_de_champ.rb @@ -0,0 +1,2 @@ +class TypesDeChamp::DatetimeTypeDeChamp < TypeDeChamp +end diff --git a/app/models/types_de_champ/departement_type_de_champ.rb b/app/models/types_de_champ/departement_type_de_champ.rb new file mode 100644 index 000000000..58a8cb3d0 --- /dev/null +++ b/app/models/types_de_champ/departement_type_de_champ.rb @@ -0,0 +1,2 @@ +class TypesDeChamp::DepartementTypeDeChamp < TypesDeChamp::TextTypeDeChamp +end diff --git a/app/models/types_de_champ/dossier_link_type_de_champ.rb b/app/models/types_de_champ/dossier_link_type_de_champ.rb new file mode 100644 index 000000000..1b3352998 --- /dev/null +++ b/app/models/types_de_champ/dossier_link_type_de_champ.rb @@ -0,0 +1,2 @@ +class TypesDeChamp::DossierLinkTypeDeChamp < TypeDeChamp +end diff --git a/app/models/types_de_champ/drop_down_list_type_de_champ.rb b/app/models/types_de_champ/drop_down_list_type_de_champ.rb new file mode 100644 index 000000000..94c77c016 --- /dev/null +++ b/app/models/types_de_champ/drop_down_list_type_de_champ.rb @@ -0,0 +1,2 @@ +class TypesDeChamp::DropDownListTypeDeChamp < TypeDeChamp +end diff --git a/app/models/types_de_champ/email_type_de_champ.rb b/app/models/types_de_champ/email_type_de_champ.rb new file mode 100644 index 000000000..022330d3c --- /dev/null +++ b/app/models/types_de_champ/email_type_de_champ.rb @@ -0,0 +1,2 @@ +class TypesDeChamp::EmailTypeDeChamp < TypesDeChamp::TextTypeDeChamp +end diff --git a/app/models/types_de_champ/engagement_type_de_champ.rb b/app/models/types_de_champ/engagement_type_de_champ.rb new file mode 100644 index 000000000..3b67be850 --- /dev/null +++ b/app/models/types_de_champ/engagement_type_de_champ.rb @@ -0,0 +1,2 @@ +class TypesDeChamp::EngagementTypeDeChamp < TypesDeChamp::CheckboxTypeDeChamp +end diff --git a/app/models/types_de_champ/explication_type_de_champ.rb b/app/models/types_de_champ/explication_type_de_champ.rb new file mode 100644 index 000000000..d0ce5aeb0 --- /dev/null +++ b/app/models/types_de_champ/explication_type_de_champ.rb @@ -0,0 +1,2 @@ +class TypesDeChamp::ExplicationTypeDeChamp < TypesDeChamp::TextTypeDeChamp +end diff --git a/app/models/types_de_champ/header_section_type_de_champ.rb b/app/models/types_de_champ/header_section_type_de_champ.rb new file mode 100644 index 000000000..73f9112dd --- /dev/null +++ b/app/models/types_de_champ/header_section_type_de_champ.rb @@ -0,0 +1,2 @@ +class TypesDeChamp::HeaderSectionTypeDeChamp < TypeDeChamp +end diff --git a/app/models/types_de_champ/multiple_drop_down_list_type_de_champ.rb b/app/models/types_de_champ/multiple_drop_down_list_type_de_champ.rb new file mode 100644 index 000000000..5a99093f3 --- /dev/null +++ b/app/models/types_de_champ/multiple_drop_down_list_type_de_champ.rb @@ -0,0 +1,2 @@ +class TypesDeChamp::MultipleDropDownListTypeDeChamp < TypeDeChamp +end diff --git a/app/models/types_de_champ/number_type_de_champ.rb b/app/models/types_de_champ/number_type_de_champ.rb new file mode 100644 index 000000000..c47c1347f --- /dev/null +++ b/app/models/types_de_champ/number_type_de_champ.rb @@ -0,0 +1,2 @@ +class TypesDeChamp::NumberTypeDeChamp < TypeDeChamp +end diff --git a/app/models/types_de_champ/pays_type_de_champ.rb b/app/models/types_de_champ/pays_type_de_champ.rb new file mode 100644 index 000000000..c35e06d78 --- /dev/null +++ b/app/models/types_de_champ/pays_type_de_champ.rb @@ -0,0 +1,2 @@ +class TypesDeChamp::PaysTypeDeChamp < TypesDeChamp::TextTypeDeChamp +end diff --git a/app/models/types_de_champ/phone_type_de_champ.rb b/app/models/types_de_champ/phone_type_de_champ.rb new file mode 100644 index 000000000..6cd42ac46 --- /dev/null +++ b/app/models/types_de_champ/phone_type_de_champ.rb @@ -0,0 +1,2 @@ +class TypesDeChamp::PhoneTypeDeChamp < TypesDeChamp::TextTypeDeChamp +end diff --git a/app/models/types_de_champ/piece_justificative_type_de_champ.rb b/app/models/types_de_champ/piece_justificative_type_de_champ.rb new file mode 100644 index 000000000..5fd09c459 --- /dev/null +++ b/app/models/types_de_champ/piece_justificative_type_de_champ.rb @@ -0,0 +1,2 @@ +class TypesDeChamp::PieceJustificativeTypeDeChamp < TypeDeChamp +end diff --git a/app/models/types_de_champ/region_type_de_champ.rb b/app/models/types_de_champ/region_type_de_champ.rb new file mode 100644 index 000000000..b694303fb --- /dev/null +++ b/app/models/types_de_champ/region_type_de_champ.rb @@ -0,0 +1,2 @@ +class TypesDeChamp::RegionTypeDeChamp < TypesDeChamp::TextTypeDeChamp +end diff --git a/app/models/types_de_champ/text_type_de_champ.rb b/app/models/types_de_champ/text_type_de_champ.rb new file mode 100644 index 000000000..5d0a0a2f6 --- /dev/null +++ b/app/models/types_de_champ/text_type_de_champ.rb @@ -0,0 +1,2 @@ +class TypesDeChamp::TextTypeDeChamp < TypeDeChamp +end diff --git a/app/models/types_de_champ/textarea_type_de_champ.rb b/app/models/types_de_champ/textarea_type_de_champ.rb new file mode 100644 index 000000000..69d45a343 --- /dev/null +++ b/app/models/types_de_champ/textarea_type_de_champ.rb @@ -0,0 +1,2 @@ +class TypesDeChamp::TextareaTypeDeChamp < TypesDeChamp::TextTypeDeChamp +end diff --git a/app/models/types_de_champ/yes_no_type_de_champ.rb b/app/models/types_de_champ/yes_no_type_de_champ.rb new file mode 100644 index 000000000..fa95f366c --- /dev/null +++ b/app/models/types_de_champ/yes_no_type_de_champ.rb @@ -0,0 +1,2 @@ +class TypesDeChamp::YesNoTypeDeChamp < TypesDeChamp::CheckboxTypeDeChamp +end From 9cc6d494a41e400b8d82050517962d97d332f8a2 Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Wed, 14 Feb 2018 15:12:57 +0100 Subject: [PATCH 3/3] Spec STI loading champ/type de champ --- .../dossiers_controller_spec.rb | 4 +- spec/decorators/champ_decorator_spec.rb | 14 ++-- spec/factories/champ.rb | 10 +-- spec/factories/procedure.rb | 47 ++++++------ spec/factories/type_de_champ.rb | 73 +++++++++++++++---- spec/features/new_user/dossier_spec.rb | 2 +- .../2018_03_06_clean_html_textareas_spec.rb | 2 +- spec/models/champ_shared_example.rb | 2 +- spec/models/champ_spec.rb | 15 ++-- .../concern/tags_substitution_concern_spec.rb | 4 +- spec/models/drop_down_list_spec.rb | 4 +- spec/models/procedure_spec.rb | 4 +- spec/models/type_de_champ_shared_example.rb | 10 +++ spec/services/champs_service_spec.rb | 2 +- .../champs/_date.html.haml_spec.rb | 2 +- .../champs/_dossier_link.html.haml_spec.rb | 2 +- .../champs/_engagement.html.haml_spec.rb | 2 +- .../_render_list_champs.html.haml_spec.rb | 4 +- .../champs/_yes_no.html.haml_spec.rb | 2 +- 19 files changed, 126 insertions(+), 79 deletions(-) diff --git a/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb b/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb index 2c4622bfe..5b4a5b7ce 100644 --- a/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb +++ b/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb @@ -369,11 +369,11 @@ describe NewGestionnaire::DossiersController, type: :controller do describe "#update_annotations" do let(:champ_multiple_drop_down_list) do - create(:type_de_champ, :private, type_champ: 'multiple_drop_down_list', libelle: 'libelle').champ.create + create(:type_de_champ_multiple_drop_down_list, :private, libelle: 'libelle').champ.create end let(:champ_datetime) do - create(:type_de_champ, :private, type_champ: 'datetime', libelle: 'libelle').champ.create + create(:type_de_champ_datetime, :private, libelle: 'libelle').champ.create end let(:dossier) do diff --git a/spec/decorators/champ_decorator_spec.rb b/spec/decorators/champ_decorator_spec.rb index 101483406..cc4a00757 100644 --- a/spec/decorators/champ_decorator_spec.rb +++ b/spec/decorators/champ_decorator_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe ChampDecorator do - let(:type_de_champ) { create(:type_de_champ, type_champ: type_champ) } + let(:type_de_champ) { create(:type_de_champ) } let(:champ) { type_de_champ.champ.create } let(:decorator) { champ.decorate } @@ -9,7 +9,7 @@ describe ChampDecorator do subject { decorator.value } describe 'for a checkbox' do - let(:type_champ) { :checkbox } + let(:type_de_champ) { create(:type_de_champ_checkbox) } context 'when value is on' do before { champ.update value: 'on' } @@ -22,7 +22,7 @@ describe ChampDecorator do end describe 'for a engagement' do - let(:type_champ) { :engagement } + let(:type_de_champ) { create(:type_de_champ_engagement) } context 'when value is on' do before { champ.update value: 'on' } @@ -35,7 +35,7 @@ describe ChampDecorator do end describe 'for a multiple_drop_down_list' do - let(:type_champ) { :multiple_drop_down_list } + let(:type_de_champ) { create(:type_de_champ_multiple_drop_down_list) } context 'when value is an array' do before { champ.update value: '["1", "2"]' } @@ -49,7 +49,7 @@ describe ChampDecorator do end describe "for a date" do - let(:type_champ) { :date } + let(:type_de_champ) { create(:type_de_champ_date) } context "when value is an ISO date" do before { champ.update value: "2017-12-31" } @@ -67,7 +67,7 @@ describe ChampDecorator do subject { decorator.date_for_input } describe "for a date" do - let(:type_champ) { :date } + let(:type_de_champ) { create(:type_de_champ_date) } context "when value is an ISO date" do before { champ.update value: "2017-12-31" } @@ -81,7 +81,7 @@ describe ChampDecorator do end describe "for a datetime" do - let(:type_champ) { :date } + let(:type_de_champ) { create(:type_de_champ_date) } context "when value is an formatted datetime" do before { champ.update value: "2017-12-30 23:17" } diff --git a/spec/factories/champ.rb b/spec/factories/champ.rb index f6570f6f4..45b2637e6 100644 --- a/spec/factories/champ.rb +++ b/spec/factories/champ.rb @@ -1,21 +1,21 @@ FactoryBot.define do factory :champ do - type_de_champ { FactoryBot.create(:type_de_champ) } + type_de_champ { create(:type_de_champ) } trait :checkbox do - type_de_champ { FactoryBot.create(:type_de_champ, :checkbox) } + type_de_champ { create(:type_de_champ_checkbox) } end trait :header_section do - type_de_champ { FactoryBot.create(:type_de_champ, :header_section) } + type_de_champ { create(:type_de_champ_header_section) } end trait :explication do - type_de_champ { FactoryBot.create(:type_de_champ, :explication) } + type_de_champ { create(:type_de_champ_explication) } end trait :dossier_link do - type_de_champ { FactoryBot.create(:type_de_champ, :type_dossier_link) } + type_de_champ { create(:type_de_champ_dossier_link) } end end end diff --git a/spec/factories/procedure.rb b/spec/factories/procedure.rb index bb2597ccd..e8b73a57e 100644 --- a/spec/factories/procedure.rb +++ b/spec/factories/procedure.rb @@ -67,7 +67,7 @@ FactoryBot.define do trait :with_datetime do after(:build) do |procedure, _evaluator| - type_de_champ = create(:type_de_champ, mandatory: true, type_champ: :datetime) + type_de_champ = create(:type_de_champ_datetime, mandatory: true) procedure.types_de_champ << type_de_champ end @@ -75,7 +75,7 @@ FactoryBot.define do trait :with_dossier_link do after(:build) do |procedure, _evaluator| - type_de_champ = create(:type_de_champ, :type_dossier_link) + type_de_champ = create(:type_de_champ_dossier_link) procedure.types_de_champ << type_de_champ end @@ -83,7 +83,7 @@ FactoryBot.define do trait :with_yes_no do after(:build) do |procedure, _evaluator| - type_de_champ = create(:type_de_champ, :type_yes_no) + type_de_champ = create(:type_de_champ_yes_no) procedure.types_de_champ << type_de_champ end @@ -114,27 +114,26 @@ FactoryBot.define do trait :with_all_champs_mandatory do after(:build) do |procedure, _evaluator| tdcs = [] - tdcs << create(:type_de_champ, type_champ: 'text', mandatory: true, libelle: 'text') - tdcs << create(:type_de_champ, type_champ: 'textarea', mandatory: true, libelle: 'textarea') - tdcs << create(:type_de_champ, type_champ: 'date', mandatory: true, libelle: 'date') - tdcs << create(:type_de_champ, type_champ: 'datetime', mandatory: true, libelle: 'datetime') - tdcs << create(:type_de_champ, type_champ: 'number', mandatory: true, libelle: 'number') - tdcs << create(:type_de_champ, type_champ: 'checkbox', mandatory: true, libelle: 'checkbox') - tdcs << create(:type_de_champ, type_champ: 'civilite', mandatory: true, libelle: 'civilite') - tdcs << create(:type_de_champ, type_champ: 'email', mandatory: true, libelle: 'email') - tdcs << create(:type_de_champ, type_champ: 'phone', mandatory: true, libelle: 'phone') - tdcs << create(:type_de_champ, type_champ: 'yes_no', mandatory: true, libelle: 'yes_no') - tdcs << create(:type_de_champ, :type_drop_down_list, mandatory: true, libelle: 'simple_drop_down_list') - tdcs << create(:type_de_champ, :type_drop_down_list, type_champ: 'multiple_drop_down_list', mandatory: true, libelle: 'multiple_drop_down_list') - tdcs << create(:type_de_champ, type_champ: 'pays', mandatory: true, libelle: 'pays') - tdcs << create(:type_de_champ, type_champ: 'regions', mandatory: true, libelle: 'regions') - tdcs << create(:type_de_champ, type_champ: 'departements', mandatory: true, libelle: 'departements') - tdcs << create(:type_de_champ, type_champ: 'engagement', mandatory: true, libelle: 'engagement') - tdcs << create(:type_de_champ, type_champ: 'header_section', mandatory: true, libelle: 'header_section') - tdcs << create(:type_de_champ, type_champ: 'explication', mandatory: true, libelle: 'explication') - tdcs << create(:type_de_champ, :type_dossier_link, mandatory: true, libelle: 'dossier_link') - tdcs << create(:type_de_champ, type_champ: 'piece_justificative', mandatory: true, libelle: 'piece_justificative') - + tdcs << create(:type_de_champ, mandatory: true, libelle: 'text') + tdcs << create(:type_de_champ_textarea, mandatory: true, libelle: 'textarea') + tdcs << create(:type_de_champ_date, mandatory: true, libelle: 'date') + tdcs << create(:type_de_champ_datetime, mandatory: true, libelle: 'datetime') + tdcs << create(:type_de_champ_number, mandatory: true, libelle: 'number') + tdcs << create(:type_de_champ_checkbox, mandatory: true, libelle: 'checkbox') + tdcs << create(:type_de_champ_civilite, mandatory: true, libelle: 'civilite') + tdcs << create(:type_de_champ_email, mandatory: true, libelle: 'email') + tdcs << create(:type_de_champ_phone, mandatory: true, libelle: 'phone') + tdcs << create(:type_de_champ_yes_no, mandatory: true, libelle: 'yes_no') + tdcs << create(:type_de_champ_drop_down_list, mandatory: true, libelle: 'simple_drop_down_list') + tdcs << create(:type_de_champ_multiple_drop_down_list, mandatory: true, libelle: 'multiple_drop_down_list') + tdcs << create(:type_de_champ_pays, mandatory: true, libelle: 'pays') + tdcs << create(:type_de_champ_regions, mandatory: true, libelle: 'regions') + tdcs << create(:type_de_champ_departements, mandatory: true, libelle: 'departements') + tdcs << create(:type_de_champ_engagement, mandatory: true, libelle: 'engagement') + tdcs << create(:type_de_champ_header_section, mandatory: true, libelle: 'header_section') + tdcs << create(:type_de_champ_explication, mandatory: true, libelle: 'explication') + tdcs << create(:type_de_champ_dossier_link, mandatory: true, libelle: 'dossier_link') + tdcs << create(:type_de_champ_piece_justificative, mandatory: true, libelle: 'piece_justificative') procedure.types_de_champ = tdcs end end diff --git a/spec/factories/type_de_champ.rb b/spec/factories/type_de_champ.rb index 5752a5aec..db149fa9f 100644 --- a/spec/factories/type_de_champ.rb +++ b/spec/factories/type_de_champ.rb @@ -1,5 +1,5 @@ FactoryBot.define do - factory :type_de_champ do + factory :type_de_champ, class: 'TypesDeChamp::TextTypeDeChamp' do private false sequence(:libelle) { |n| "Libelle du champ #{n}" } sequence(:description) { |n| "description du champ #{n}" } @@ -7,33 +7,74 @@ FactoryBot.define do order_place 1 mandatory false - trait :checkbox do + factory :type_de_champ_text, class: 'TypesDeChamp::TextTypeDeChamp' do + type_champ 'text' + end + factory :type_de_champ_textarea, class: 'TypesDeChamp::TextareaTypeDeChamp' do + type_champ 'textarea' + end + factory :type_de_champ_number, class: 'TypesDeChamp::NumberTypeDeChamp' do + type_champ 'number' + end + factory :type_de_champ_checkbox, class: 'TypesDeChamp::CheckboxTypeDeChamp' do type_champ 'checkbox' end - - trait :header_section do - type_champ 'header_section' + factory :type_de_champ_civilite, class: 'TypesDeChamp::CiviliteTypeDeChamp' do + type_champ 'civilite' end - - trait :explication do - type_champ 'explication' + factory :type_de_champ_email, class: 'TypesDeChamp::EmailTypeDeChamp' do + type_champ 'email' end - - trait :type_dossier_link do - libelle 'Référence autre dossier' - type_champ 'dossier_link' + factory :type_de_champ_phone, class: 'TypesDeChamp::PhoneTypeDeChamp' do + type_champ 'phone' end - - trait :type_yes_no do + factory :type_de_champ_address, class: 'TypesDeChamp::AddressTypeDeChamp' do + type_champ 'address' + end + factory :type_de_champ_yes_no, class: 'TypesDeChamp::YesNoTypeDeChamp' do libelle 'Yes/no' type_champ 'yes_no' end - - trait :type_drop_down_list do + factory :type_de_champ_date, class: 'TypesDeChamp::DateTypeDeChamp' do + type_champ 'date' + end + factory :type_de_champ_datetime, class: 'TypesDeChamp::DatetimeTypeDeChamp' do + type_champ 'datetime' + end + factory :type_de_champ_drop_down_list, class: 'TypesDeChamp::DropDownListTypeDeChamp' do libelle 'Menu déroulant' type_champ 'drop_down_list' drop_down_list { create(:drop_down_list) } end + factory :type_de_champ_multiple_drop_down_list, class: 'TypesDeChamp::MultipleDropDownListTypeDeChamp' do + type_champ 'multiple_drop_down_list' + drop_down_list { create(:drop_down_list) } + end + factory :type_de_champ_pays, class: 'TypesDeChamp::PaysTypeDeChamp' do + type_champ 'pays' + end + factory :type_de_champ_regions, class: 'TypesDeChamp::RegionTypeDeChamp' do + type_champ 'regions' + end + factory :type_de_champ_departements, class: 'TypesDeChamp::DepartementTypeDeChamp' do + type_champ 'departements' + end + factory :type_de_champ_engagement, class: 'TypesDeChamp::EngagementTypeDeChamp' do + type_champ 'engagement' + end + factory :type_de_champ_header_section, class: 'TypesDeChamp::HeaderSectionTypeDeChamp' do + type_champ 'header_section' + end + factory :type_de_champ_explication, class: 'TypesDeChamp::ExplicationTypeDeChamp' do + type_champ 'explication' + end + factory :type_de_champ_dossier_link, class: 'TypesDeChamp::DossierLinkTypeDeChamp' do + libelle 'Référence autre dossier' + type_champ 'dossier_link' + end + factory :type_de_champ_piece_justificative, class: 'TypesDeChamp::PieceJustificativeTypeDeChamp' do + type_champ 'piece_justificative' + end trait :private do private true diff --git a/spec/features/new_user/dossier_spec.rb b/spec/features/new_user/dossier_spec.rb index f6b7aa135..763b9555e 100644 --- a/spec/features/new_user/dossier_spec.rb +++ b/spec/features/new_user/dossier_spec.rb @@ -84,7 +84,7 @@ feature 'The user' do end let(:simple_procedure) do - tdcs = [create(:type_de_champ, type_champ: 'text', mandatory: true, libelle: 'text')] + tdcs = [create(:type_de_champ, mandatory: true, libelle: 'text')] create(:procedure, :published, :for_individual, types_de_champ: tdcs) end diff --git a/spec/lib/rake/2018_03_06_clean_html_textareas_spec.rb b/spec/lib/rake/2018_03_06_clean_html_textareas_spec.rb index 86bcd3a91..e1790f6f4 100644 --- a/spec/lib/rake/2018_03_06_clean_html_textareas_spec.rb +++ b/spec/lib/rake/2018_03_06_clean_html_textareas_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe '2018_03_06_clean_html_textareas#clean' do let(:procedure) { create(:procedure) } - let(:type_champ) { create(:type_de_champ, procedure: procedure, type_champ: :textarea) } + let(:type_champ) { create(:type_de_champ_textarea, procedure: procedure) } let(:champ) { type_champ.champ.create(value: "

Gnahar
greu bouahaha

") } let(:champ_date) { Time.local(1995) } let(:rake_date) { Time.local(2018) } diff --git a/spec/models/champ_shared_example.rb b/spec/models/champ_shared_example.rb index 2fd1a1a3f..a424fc824 100644 --- a/spec/models/champ_shared_example.rb +++ b/spec/models/champ_shared_example.rb @@ -33,7 +33,7 @@ shared_examples 'champ_spec' do end context "when type_champ=date" do - let(:type_de_champ) { create(:type_de_champ, type_champ: "date") } + let(:type_de_champ) { create(:type_de_champ_date) } let(:champ) { type_de_champ.champ.create } it "should convert %d/%m/%Y format to ISO" do diff --git a/spec/models/champ_spec.rb b/spec/models/champ_spec.rb index aa4c20705..2d7767e9c 100644 --- a/spec/models/champ_spec.rb +++ b/spec/models/champ_spec.rb @@ -23,7 +23,7 @@ describe Champ do end describe '#format_datetime' do - let(:type_de_champ) { build(:type_de_champ, type_champ: 'datetime') } + let(:type_de_champ) { build(:type_de_champ_datetime) } let(:champ) { type_de_champ.champ.build(value: value) } before { champ.save } @@ -42,7 +42,7 @@ describe Champ do end describe '#multiple_select_to_string' do - let(:type_de_champ) { build(:type_de_champ, type_champ: 'multiple_drop_down_list') } + let(:type_de_champ) { build(:type_de_champ_multiple_drop_down_list) } let(:champ) { type_de_champ.champ.build(value: value) } before { champ.save } @@ -80,27 +80,26 @@ describe Champ do end describe 'for_export' do - let(:type_de_champ) { create(:type_de_champ, type_champ: type_champ) } + let(:type_de_champ) { create(:type_de_champ) } let(:champ) { type_de_champ.champ.build(value: value) } before { champ.save } context 'when type_de_champ is text' do - let(:type_champ) { 'text' } let(:value) { '123' } it { expect(champ.for_export).to eq('123') } end context 'when type_de_champ is textarea' do - let(:type_champ) { 'textarea' } + let(:type_de_champ) { create(:type_de_champ_textarea) } let(:value) { 'gras' } it { expect(champ.for_export).to eq('gras') } end context 'when type_de_champ is yes_no' do - let(:type_champ) { 'yes_no' } + let(:type_de_champ) { create(:type_de_champ_yes_no) } context 'if yes' do let(:value) { 'true' } @@ -122,11 +121,9 @@ describe Champ do end context 'when type_de_champ is multiple_drop_down_list' do - let(:type_champ) { 'multiple_drop_down_list' } + let(:type_de_champ) { create(:type_de_champ_multiple_drop_down_list) } let(:value) { '["Crétinier", "Mousserie"]' } - before { type_de_champ.drop_down_list = create(:drop_down_list) } - it { expect(champ.for_export).to eq('Crétinier, Mousserie') } end end diff --git a/spec/models/concern/tags_substitution_concern_spec.rb b/spec/models/concern/tags_substitution_concern_spec.rb index 7a2d2e52e..5825c7c98 100644 --- a/spec/models/concern/tags_substitution_concern_spec.rb +++ b/spec/models/concern/tags_substitution_concern_spec.rb @@ -161,8 +161,8 @@ describe TagsSubstitutionConcern, type: :model do context 'when the procedure has 2 types de champ date and datetime' do let(:types_de_champ) do [ - create(:type_de_champ, libelle: 'date', type_champ: 'date'), - create(:type_de_champ, libelle: 'datetime', type_champ: 'datetime') + create(:type_de_champ_date, libelle: 'date'), + create(:type_de_champ_datetime, libelle: 'datetime') ] end diff --git a/spec/models/drop_down_list_spec.rb b/spec/models/drop_down_list_spec.rb index 130edcdd1..e4ce2adf2 100644 --- a/spec/models/drop_down_list_spec.rb +++ b/spec/models/drop_down_list_spec.rb @@ -47,14 +47,14 @@ describe DropDownList do end context 'when multiple' do - let(:type_de_champ) { build(:type_de_champ, type_champ: 'multiple_drop_down_list') } + let(:type_de_champ) { build(:type_de_champ_multiple_drop_down_list) } let(:champ) { type_de_champ.champ.build(value: '["1","2"]').decorate } it { expect(dropdownlist.selected_options(champ)).to match(['1', '2']) } end context 'when simple' do - let(:type_de_champ) { build(:type_de_champ, type_champ: 'drop_down_list') } + let(:type_de_champ) { build(:type_de_champ_drop_down_list) } let(:champ) { type_de_champ.champ.build(value: '1').decorate } it { expect(dropdownlist.selected_options(champ)).to match(['1']) } diff --git a/spec/models/procedure_spec.rb b/spec/models/procedure_spec.rb index 6f51f19a0..5dfb915b0 100644 --- a/spec/models/procedure_spec.rb +++ b/spec/models/procedure_spec.rb @@ -155,10 +155,10 @@ describe Procedure do let(:procedure) { create(:procedure, archived_at: archived_at, published_at: published_at, received_mail: received_mail) } let!(:type_de_champ_0) { create(:type_de_champ, procedure: procedure, order_place: 0) } let!(:type_de_champ_1) { create(:type_de_champ, procedure: procedure, order_place: 1) } - let!(:type_de_champ_2) { create(:type_de_champ, :type_drop_down_list, procedure: procedure, order_place: 2) } + let!(:type_de_champ_2) { create(:type_de_champ_drop_down_list, procedure: procedure, order_place: 2) } let!(:type_de_champ_private_0) { create(:type_de_champ, :private, procedure: procedure, order_place: 0) } let!(:type_de_champ_private_1) { create(:type_de_champ, :private, procedure: procedure, order_place: 1) } - let!(:type_de_champ_private_2) { create(:type_de_champ, :private, :type_drop_down_list, procedure: procedure, order_place: 2) } + let!(:type_de_champ_private_2) { create(:type_de_champ_drop_down_list, :private, procedure: procedure, order_place: 2) } let!(:piece_justificative_0) { create(:type_de_piece_justificative, procedure: procedure, order_place: 0) } let!(:piece_justificative_1) { create(:type_de_piece_justificative, procedure: procedure, order_place: 1) } let(:received_mail){ create(:received_mail) } diff --git a/spec/models/type_de_champ_shared_example.rb b/spec/models/type_de_champ_shared_example.rb index 1da5c0e22..cebd27f95 100644 --- a/spec/models/type_de_champ_shared_example.rb +++ b/spec/models/type_de_champ_shared_example.rb @@ -15,6 +15,16 @@ shared_examples 'type_de_champ_spec' do it { is_expected.to allow_value('datetime').for(:type_champ) } it { is_expected.to allow_value('number').for(:type_champ) } it { is_expected.to allow_value('checkbox').for(:type_champ) } + + it do + TypeDeChamp.type_champs.each do |(type_champ, _)| + type_de_champ = create(:"type_de_champ_#{type_champ}") + champ = type_de_champ.champ.create + + expect(type_de_champ.class.name).to match(/^TypesDeChamp::/) + expect(champ.class.name).to match(/^Champs::/) + end + end end context 'order_place' do diff --git a/spec/services/champs_service_spec.rb b/spec/services/champs_service_spec.rb index 4aa2578e0..3d7703348 100644 --- a/spec/services/champs_service_spec.rb +++ b/spec/services/champs_service_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe ChampsService do let(:type_de_champ) { create(:type_de_champ) } let(:type_de_champ_mandatory) { create(:type_de_champ, libelle: 'mandatory', mandatory: true) } - let(:type_de_champ_datetime) { create(:type_de_champ, type_champ: :datetime) } + let(:type_de_champ_datetime) { create(:type_de_champ_datetime) } let!(:champ) { type_de_champ.champ.create(value: 'toto') } let!(:champ_mandatory_empty) { type_de_champ_mandatory.champ.create } let!(:champ_datetime) { type_de_champ_datetime.champ.create } diff --git a/spec/views/users/description/champs/_date.html.haml_spec.rb b/spec/views/users/description/champs/_date.html.haml_spec.rb index 5cb1ed190..cbed678bf 100644 --- a/spec/views/users/description/champs/_date.html.haml_spec.rb +++ b/spec/views/users/description/champs/_date.html.haml_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe 'users/description/champs/date.html.haml', type: :view do - let(:type_champ) { create(:type_de_champ, type_champ: :date) } + let(:type_champ) { create(:type_de_champ_date) } before do render 'users/description/champs/date.html.haml', champ: champ diff --git a/spec/views/users/description/champs/_dossier_link.html.haml_spec.rb b/spec/views/users/description/champs/_dossier_link.html.haml_spec.rb index 2a01477e8..6d6849ff8 100644 --- a/spec/views/users/description/champs/_dossier_link.html.haml_spec.rb +++ b/spec/views/users/description/champs/_dossier_link.html.haml_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe 'users/description/champs/dossier_link.html.haml', type: :view do - let(:type_champ) { create(:type_de_champ, type_champ: :dossier_link) } + let(:type_champ) { create(:type_de_champ_dossier_link) } before do render 'users/description/champs/dossier_link.html.haml', champ: champ diff --git a/spec/views/users/description/champs/_engagement.html.haml_spec.rb b/spec/views/users/description/champs/_engagement.html.haml_spec.rb index c35c97662..31a44cc12 100644 --- a/spec/views/users/description/champs/_engagement.html.haml_spec.rb +++ b/spec/views/users/description/champs/_engagement.html.haml_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe 'users/description/champs/engagement.html.haml', type: :view do - let(:type_champ) { create(:type_de_champ, type_champ: :engagement) } + let(:type_champ) { create(:type_de_champ_engagement) } subject { render 'users/description/champs/engagement.html.haml', champ: champ } diff --git a/spec/views/users/description/champs/_render_list_champs.html.haml_spec.rb b/spec/views/users/description/champs/_render_list_champs.html.haml_spec.rb index f790279ab..04443e355 100644 --- a/spec/views/users/description/champs/_render_list_champs.html.haml_spec.rb +++ b/spec/views/users/description/champs/_render_list_champs.html.haml_spec.rb @@ -1,5 +1,5 @@ describe 'users/description/champs/render_list_champs.html.haml', type: :view do - let(:type_champ) { create(:type_de_champ, :checkbox) } + let(:type_champ) { create(:type_de_champ_checkbox) } context "with any champ" do let!(:champ) { create(:champ, type_de_champ: type_champ, value: nil) } @@ -40,7 +40,7 @@ describe 'users/description/champs/render_list_champs.html.haml', type: :view do end context 'with a dossier_link' do - let(:type_champ) { create(:type_de_champ, type_champ: :dossier_link) } + let(:type_champ) { create(:type_de_champ_dossier_link) } let!(:champ) { create(:champ, type_de_champ: type_champ, value: nil) } before do diff --git a/spec/views/users/description/champs/_yes_no.html.haml_spec.rb b/spec/views/users/description/champs/_yes_no.html.haml_spec.rb index 22ece7583..2b8f25a0e 100644 --- a/spec/views/users/description/champs/_yes_no.html.haml_spec.rb +++ b/spec/views/users/description/champs/_yes_no.html.haml_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe 'users/description/champs/yes_no.html.haml', type: :view do - let(:type_champ) { create(:type_de_champ, type_champ: :yes_no) } + let(:type_champ) { create(:type_de_champ_yes_no) } before do render 'users/description/champs/yes_no.html.haml', champ: champ