diff --git a/Gemfile b/Gemfile index dd2d8e625..9b8da43bd 100644 --- a/Gemfile +++ b/Gemfile @@ -120,7 +120,7 @@ gem 'rack-mini-profiler' group :test do gem 'capybara' gem 'launchy' - gem 'factory_girl' + gem 'factory_bot' gem 'database_cleaner' gem 'webmock' gem 'shoulda-matchers', require: false diff --git a/Gemfile.lock b/Gemfile.lock index d4d8f6bee..259680f49 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -191,7 +191,7 @@ GEM eventmachine (1.2.1) excon (0.60.0) execjs (2.7.0) - factory_girl (4.9.0) + factory_bot (4.8.2) activesupport (>= 3.0.0) faraday (0.12.2) multipart-post (>= 1.2, < 3) @@ -780,7 +780,7 @@ DEPENDENCIES devise dotenv-rails draper - factory_girl + factory_bot fog fog-openstack font-awesome-rails diff --git a/spec/controllers/stats_controller_spec.rb b/spec/controllers/stats_controller_spec.rb index 625b56133..34594386b 100644 --- a/spec/controllers/stats_controller_spec.rb +++ b/spec/controllers/stats_controller_spec.rb @@ -4,11 +4,11 @@ describe StatsController, type: :controller do describe "#last_four_months_hash" do context "while a regular user is logged in" do before do - FactoryGirl.create(:procedure, :created_at => 6.months.ago, :updated_at => 6.months.ago) - FactoryGirl.create(:procedure, :created_at => 2.months.ago, :updated_at => 62.days.ago) - FactoryGirl.create(:procedure, :created_at => 2.months.ago, :updated_at => 62.days.ago) - FactoryGirl.create(:procedure, :created_at => 2.months.ago, :updated_at => 31.days.ago) - FactoryGirl.create(:procedure, :created_at => 2.months.ago, :updated_at => Time.now) + FactoryBot.create(:procedure, :created_at => 6.months.ago, :updated_at => 6.months.ago) + FactoryBot.create(:procedure, :created_at => 2.months.ago, :updated_at => 62.days.ago) + FactoryBot.create(:procedure, :created_at => 2.months.ago, :updated_at => 62.days.ago) + FactoryBot.create(:procedure, :created_at => 2.months.ago, :updated_at => 31.days.ago) + FactoryBot.create(:procedure, :created_at => 2.months.ago, :updated_at => Time.now) @controller = StatsController.new allow(@controller).to receive(:administration_signed_in?).and_return(false) @@ -28,10 +28,10 @@ describe StatsController, type: :controller do context "while a super admin is logged in" do before do - FactoryGirl.create(:procedure, :updated_at => 6.months.ago) - FactoryGirl.create(:procedure, :updated_at => 45.days.ago) - FactoryGirl.create(:procedure, :updated_at => 1.day.ago) - FactoryGirl.create(:procedure, :updated_at => 1.day.ago) + FactoryBot.create(:procedure, :updated_at => 6.months.ago) + FactoryBot.create(:procedure, :updated_at => 45.days.ago) + FactoryBot.create(:procedure, :updated_at => 1.day.ago) + FactoryBot.create(:procedure, :updated_at => 1.day.ago) @controller = StatsController.new @@ -54,11 +54,11 @@ describe StatsController, type: :controller do describe '#cumulative_hash' do before do Timecop.freeze(Time.new(2016, 10, 2)) - FactoryGirl.create(:procedure, :created_at => 55.days.ago, :updated_at => 43.days.ago) - FactoryGirl.create(:procedure, :created_at => 45.days.ago, :updated_at => 40.days.ago) - FactoryGirl.create(:procedure, :created_at => 45.days.ago, :updated_at => 20.days.ago) - FactoryGirl.create(:procedure, :created_at => 15.days.ago, :updated_at => 20.days.ago) - FactoryGirl.create(:procedure, :created_at => 15.days.ago, :updated_at => 1.hour.ago) + FactoryBot.create(:procedure, :created_at => 55.days.ago, :updated_at => 43.days.ago) + FactoryBot.create(:procedure, :created_at => 45.days.ago, :updated_at => 40.days.ago) + FactoryBot.create(:procedure, :created_at => 45.days.ago, :updated_at => 20.days.ago) + FactoryBot.create(:procedure, :created_at => 15.days.ago, :updated_at => 20.days.ago) + FactoryBot.create(:procedure, :created_at => 15.days.ago, :updated_at => 1.hour.ago) end after { Timecop.return } @@ -142,21 +142,21 @@ describe StatsController, type: :controller do # dossier_p1_c: 5 days before do - procedure_1 = FactoryGirl.create(:procedure) - procedure_2 = FactoryGirl.create(:procedure) - dossier_p1_a = FactoryGirl.create(:dossier, + procedure_1 = FactoryBot.create(:procedure) + procedure_2 = FactoryBot.create(:procedure) + dossier_p1_a = FactoryBot.create(:dossier, :procedure => procedure_1, :en_construction_at => 2.months.ago.beginning_of_month, :processed_at => 2.months.ago.beginning_of_month + 3.days) - dossier_p1_b = FactoryGirl.create(:dossier, + dossier_p1_b = FactoryBot.create(:dossier, :procedure => procedure_1, :en_construction_at => 2.months.ago.beginning_of_month, :processed_at => 2.months.ago.beginning_of_month + 1.days) - dossier_p1_c = FactoryGirl.create(:dossier, + dossier_p1_c = FactoryBot.create(:dossier, :procedure => procedure_1, :en_construction_at => 1.months.ago.beginning_of_month, :processed_at => 1.months.ago.beginning_of_month + 5.days) - dossier_p2_a = FactoryGirl.create(:dossier, + dossier_p2_a = FactoryBot.create(:dossier, :procedure => procedure_2, :en_construction_at => 2.month.ago.beginning_of_month, :processed_at => 2.month.ago.beginning_of_month + 4.days) @@ -190,24 +190,24 @@ describe StatsController, type: :controller do # dossier_p1_c: 50 minutes before do - procedure_1 = FactoryGirl.create(:procedure, :with_type_de_champ, :types_de_champ_count => 24) - procedure_2 = FactoryGirl.create(:procedure, :with_type_de_champ, :types_de_champ_count => 48) - dossier_p1_a = FactoryGirl.create(:dossier, + procedure_1 = FactoryBot.create(:procedure, :with_type_de_champ, :types_de_champ_count => 24) + procedure_2 = FactoryBot.create(:procedure, :with_type_de_champ, :types_de_champ_count => 48) + dossier_p1_a = FactoryBot.create(:dossier, :procedure => procedure_1, :created_at => 2.months.ago.beginning_of_month, :en_construction_at => 2.months.ago.beginning_of_month + 30.minutes, :processed_at => 2.months.ago.beginning_of_month + 1.day) - dossier_p1_b = FactoryGirl.create(:dossier, + dossier_p1_b = FactoryBot.create(:dossier, :procedure => procedure_1, :created_at => 2.months.ago.beginning_of_month, :en_construction_at => 2.months.ago.beginning_of_month + 10.minutes, :processed_at => 2.months.ago.beginning_of_month + 1.day) - dossier_p1_c = FactoryGirl.create(:dossier, + dossier_p1_c = FactoryBot.create(:dossier, :procedure => procedure_1, :created_at => 1.months.ago.beginning_of_month, :en_construction_at => 1.months.ago.beginning_of_month + 50.minutes, :processed_at => 1.months.ago.beginning_of_month + 1.day) - dossier_p2_a = FactoryGirl.create(:dossier, + dossier_p2_a = FactoryBot.create(:dossier, :procedure => procedure_2, :created_at => 2.month.ago.beginning_of_month, :en_construction_at => 2.month.ago.beginning_of_month + 80.minutes, diff --git a/spec/factories/administrateur.rb b/spec/factories/administrateur.rb index f81e5a6a9..be7cac11a 100644 --- a/spec/factories/administrateur.rb +++ b/spec/factories/administrateur.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do sequence(:administrateur_email) { |n| "admin#{n}@admin.com" } factory :administrateur do email { generate(:administrateur_email) } diff --git a/spec/factories/administration.rb b/spec/factories/administration.rb index 216a5b70c..5f55b5971 100644 --- a/spec/factories/administration.rb +++ b/spec/factories/administration.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do sequence(:administration_email) { |n| "plop#{n}@plop.com" } factory :administration do email { generate(:administration_email) } diff --git a/spec/factories/assign_to.rb b/spec/factories/assign_to.rb index 82976c8b9..7a5110f36 100644 --- a/spec/factories/assign_to.rb +++ b/spec/factories/assign_to.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory :assign_to do end end diff --git a/spec/factories/attestation_template.rb b/spec/factories/attestation_template.rb index 46eb4bee1..faefd5e5c 100644 --- a/spec/factories/attestation_template.rb +++ b/spec/factories/attestation_template.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory :attestation_template do title 'title' body 'body' diff --git a/spec/factories/avis.rb b/spec/factories/avis.rb index 90d830c8f..679b16605 100644 --- a/spec/factories/avis.rb +++ b/spec/factories/avis.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory :avis do introduction 'Bonjour, merci de me donner votre avis sur ce dossier' diff --git a/spec/factories/cadastre.rb b/spec/factories/cadastre.rb index 5323ff278..fe6833b4e 100644 --- a/spec/factories/cadastre.rb +++ b/spec/factories/cadastre.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory :cadastre do numero '001' feuille 1 diff --git a/spec/factories/cerfa.rb b/spec/factories/cerfa.rb index 7e29db2ac..c6ccc5bc4 100644 --- a/spec/factories/cerfa.rb +++ b/spec/factories/cerfa.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory :cerfa do end end diff --git a/spec/factories/champ.rb b/spec/factories/champ.rb index a53ae8808..ee5917834 100644 --- a/spec/factories/champ.rb +++ b/spec/factories/champ.rb @@ -1,21 +1,21 @@ -FactoryGirl.define do +FactoryBot.define do factory :champ do - type_de_champ { FactoryGirl.create(:type_de_champ_public) } + type_de_champ { FactoryBot.create(:type_de_champ_public) } trait :checkbox do - type_de_champ { FactoryGirl.create(:type_de_champ_public, :checkbox) } + type_de_champ { FactoryBot.create(:type_de_champ_public, :checkbox) } end trait :header_section do - type_de_champ { FactoryGirl.create(:type_de_champ_public, :header_section) } + type_de_champ { FactoryBot.create(:type_de_champ_public, :header_section) } end trait :explication do - type_de_champ { FactoryGirl.create(:type_de_champ_public, :explication) } + type_de_champ { FactoryBot.create(:type_de_champ_public, :explication) } end trait :dossier_link do - type_de_champ { FactoryGirl.create(:type_de_champ_public, :type_dossier_link) } + type_de_champ { FactoryBot.create(:type_de_champ_public, :type_dossier_link) } end end end diff --git a/spec/factories/commentaire.rb b/spec/factories/commentaire.rb index 6242281e4..c03091049 100644 --- a/spec/factories/commentaire.rb +++ b/spec/factories/commentaire.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory :commentaire do body 'plop' diff --git a/spec/factories/dossier.rb b/spec/factories/dossier.rb index 9b1ce3a04..4fa1978de 100644 --- a/spec/factories/dossier.rb +++ b/spec/factories/dossier.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory :dossier do state 'brouillon' association :user, factory: [:user] diff --git a/spec/factories/drop_down_list.rb b/spec/factories/drop_down_list.rb index 0aeabf30d..9b7de1e7e 100644 --- a/spec/factories/drop_down_list.rb +++ b/spec/factories/drop_down_list.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory :drop_down_list do value "val1\r\nval2\r\n--separateur--\r\nval3" end diff --git a/spec/factories/entreprise.rb b/spec/factories/entreprise.rb index 95a2ae53c..51752b3b8 100644 --- a/spec/factories/entreprise.rb +++ b/spec/factories/entreprise.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory :entreprise do siren '440117620' capital_social 537_100_000 diff --git a/spec/factories/etablissement.rb b/spec/factories/etablissement.rb index 2a442271d..3c4d43be5 100644 --- a/spec/factories/etablissement.rb +++ b/spec/factories/etablissement.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory :etablissement do siret '44011762001530' siege_social true diff --git a/spec/factories/exercice.rb b/spec/factories/exercice.rb index bf804d551..b9c6f38cc 100644 --- a/spec/factories/exercice.rb +++ b/spec/factories/exercice.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory :exercice do ca '12345678' dateFinExercice "2014-12-30 23:00:00" diff --git a/spec/factories/follow.rb b/spec/factories/follow.rb index 9db1f67ce..fb8047450 100644 --- a/spec/factories/follow.rb +++ b/spec/factories/follow.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory :follow do end end diff --git a/spec/factories/france_connect_information.rb b/spec/factories/france_connect_information.rb index 522552cca..64f5ac533 100644 --- a/spec/factories/france_connect_information.rb +++ b/spec/factories/france_connect_information.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory :france_connect_information do given_name 'plop' family_name 'plip' diff --git a/spec/factories/gestionnaire.rb b/spec/factories/gestionnaire.rb index 02ee8d5eb..1595ce313 100644 --- a/spec/factories/gestionnaire.rb +++ b/spec/factories/gestionnaire.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do sequence(:gestionnaire_email) { |n| "gest#{n}@gest.com" } factory :gestionnaire do email { generate(:gestionnaire_email) } diff --git a/spec/factories/individual.rb b/spec/factories/individual.rb index 0e2330b20..05128e117 100644 --- a/spec/factories/individual.rb +++ b/spec/factories/individual.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory :individual do gender 'M.' nom 'Julien' diff --git a/spec/factories/invite.rb b/spec/factories/invite.rb index 3e8083023..ec5142cc2 100644 --- a/spec/factories/invite.rb +++ b/spec/factories/invite.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory :invite do email 'plop@octo.com' diff --git a/spec/factories/invite_user.rb b/spec/factories/invite_user.rb index 01280169b..e1cc5a6f6 100644 --- a/spec/factories/invite_user.rb +++ b/spec/factories/invite_user.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory :invite_user do email 'plop@octo.com' diff --git a/spec/factories/mail_templates.rb b/spec/factories/mail_templates.rb index 43f358bdb..ab8b31ab2 100644 --- a/spec/factories/mail_templates.rb +++ b/spec/factories/mail_templates.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory :closed_mail, class: Mails::ClosedMail do subject "Subject, voila voila" body "Blabla ceci est mon body" diff --git a/spec/factories/module_api_carto.rb b/spec/factories/module_api_carto.rb index 742bea6e6..d76698ee5 100644 --- a/spec/factories/module_api_carto.rb +++ b/spec/factories/module_api_carto.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory :module_api_carto do use_api_carto false quartiers_prioritaires false diff --git a/spec/factories/notification.rb b/spec/factories/notification.rb index fc1a119fb..b8a9c81aa 100644 --- a/spec/factories/notification.rb +++ b/spec/factories/notification.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory :notification do type_notif 'commentaire' liste [] diff --git a/spec/factories/piece_justificative.rb b/spec/factories/piece_justificative.rb index abe3f319c..c15d09d18 100644 --- a/spec/factories/piece_justificative.rb +++ b/spec/factories/piece_justificative.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory :piece_justificative do trait :rib do content Rack::Test::UploadedFile.new("./spec/support/files/RIB.pdf", 'application/pdf') diff --git a/spec/factories/procedure.rb b/spec/factories/procedure.rb index 46477a14b..29892706d 100644 --- a/spec/factories/procedure.rb +++ b/spec/factories/procedure.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do sequence(:published_path) { |n| "fake_path#{n}" } factory :procedure do lien_demarche 'http://localhost' diff --git a/spec/factories/procedure_path.rb b/spec/factories/procedure_path.rb index 4620abe6e..651696899 100644 --- a/spec/factories/procedure_path.rb +++ b/spec/factories/procedure_path.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory :procedure_path do path 'fake_path' end diff --git a/spec/factories/quartier_prioritaire.rb b/spec/factories/quartier_prioritaire.rb index 7cc428083..3d1de0e59 100644 --- a/spec/factories/quartier_prioritaire.rb +++ b/spec/factories/quartier_prioritaire.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory :quartier_prioritaire do code 'QPcode' commune 'Paris' diff --git a/spec/factories/rna_information.rb b/spec/factories/rna_information.rb index 70aef163d..bba5d5371 100644 --- a/spec/factories/rna_information.rb +++ b/spec/factories/rna_information.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory :rna_information do association_id "W072000535" titre "ASSOCIATION POUR LA PROMOTION DE SPECTACLES AU CHATEAU DE ROCHEMAURE" diff --git a/spec/factories/type_de_champ_private.rb b/spec/factories/type_de_champ_private.rb index 327a9e80f..d804dd42b 100644 --- a/spec/factories/type_de_champ_private.rb +++ b/spec/factories/type_de_champ_private.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory :type_de_champ_private do sequence(:libelle) { |n| "Libelle champ privé #{n}" } sequence(:description) { |n| "description du champ privé #{n}" } diff --git a/spec/factories/type_de_champ_public.rb b/spec/factories/type_de_champ_public.rb index 0add6b480..7f63092cf 100644 --- a/spec/factories/type_de_champ_public.rb +++ b/spec/factories/type_de_champ_public.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory :type_de_champ_public do sequence(:libelle) { |n| "Libelle du champ #{n}" } sequence(:description) { |n| "description du champ #{n}" } diff --git a/spec/factories/type_de_piece_justificative.rb b/spec/factories/type_de_piece_justificative.rb index 76af4cf37..b461f700e 100644 --- a/spec/factories/type_de_piece_justificative.rb +++ b/spec/factories/type_de_piece_justificative.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory :type_de_piece_justificative do libelle 'RIB' description 'Releve identité bancaire' diff --git a/spec/factories/user.rb b/spec/factories/user.rb index c2d09396b..eedc7efd1 100644 --- a/spec/factories/user.rb +++ b/spec/factories/user.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do sequence(:user_email) { |n| "user#{n}@user.com" } factory :user do email { generate(:user_email) } diff --git a/spec/features/new_gestionnaire/gestionnaire_spec.rb b/spec/features/new_gestionnaire/gestionnaire_spec.rb index ed4cacc89..cd9f01d41 100644 --- a/spec/features/new_gestionnaire/gestionnaire_spec.rb +++ b/spec/features/new_gestionnaire/gestionnaire_spec.rb @@ -107,7 +107,7 @@ feature 'The gestionnaire part' do end scenario 'A gestionnaire can see the personnes impliquées' do - gestionnaire2 = FactoryGirl.create(:gestionnaire, password: password) + gestionnaire2 = FactoryBot.create(:gestionnaire, password: password) log_in(gestionnaire.email, password) diff --git a/spec/models/commentaire_spec.rb b/spec/models/commentaire_spec.rb index 802f9ae85..a476cca39 100644 --- a/spec/models/commentaire_spec.rb +++ b/spec/models/commentaire_spec.rb @@ -30,7 +30,7 @@ describe Commentaire do let(:user_invite) { create(:user) } before do - FactoryGirl.create(:invite_user, email: "invite@tps.apientreprise.fr", dossier: dossier, user: user_invite) + FactoryBot.create(:invite_user, email: "invite@tps.apientreprise.fr", dossier: dossier, user: user_invite) end it "calls notify_gestionnaires" do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 4960225b8..8ab5e7d15 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -26,7 +26,7 @@ require 'database_cleaner' require 'webmock/rspec' require 'shoulda-matchers' require 'devise' -require 'factory_girl' +require 'factory_bot' require 'selenium/webdriver' Capybara.javascript_driver = :headless_chrome @@ -109,7 +109,7 @@ RSpec.configure do |config| config.include Devise::Test::ControllerHelpers, type: :controller config.include Devise::Test::ControllerHelpers, type: :view - config.include FactoryGirl::Syntax::Methods + config.include FactoryBot::Syntax::Methods config.before(:each) do allow_any_instance_of(PieceJustificativeUploader).to receive(:generate_secure_token).and_return("3dbb3535-5388-4a37-bc2d-778327b9f997") diff --git a/spec/support/factory_girl.rb b/spec/support/factory_girl.rb index eec437fb3..c7890e49c 100644 --- a/spec/support/factory_girl.rb +++ b/spec/support/factory_girl.rb @@ -1,3 +1,3 @@ RSpec.configure do |config| - config.include FactoryGirl::Syntax::Methods + config.include FactoryBot::Syntax::Methods end diff --git a/spec/support/feature_helpers.rb b/spec/support/feature_helpers.rb index 57f7f3291..2e59ec736 100644 --- a/spec/support/feature_helpers.rb +++ b/spec/support/feature_helpers.rb @@ -11,7 +11,7 @@ module FeatureHelpers end def create_dossier - dossier = FactoryGirl.create(:dossier) + dossier = FactoryBot.create(:dossier) dossier end end