factory_girl is now factory_bot

This commit is contained in:
gregoirenovel 2018-01-23 17:15:42 +01:00
parent 5eb4f12b48
commit a2f4e8b283
40 changed files with 72 additions and 72 deletions

View file

@ -120,7 +120,7 @@ gem 'rack-mini-profiler'
group :test do group :test do
gem 'capybara' gem 'capybara'
gem 'launchy' gem 'launchy'
gem 'factory_girl' gem 'factory_bot'
gem 'database_cleaner' gem 'database_cleaner'
gem 'webmock' gem 'webmock'
gem 'shoulda-matchers', require: false gem 'shoulda-matchers', require: false

View file

@ -191,7 +191,7 @@ GEM
eventmachine (1.2.1) eventmachine (1.2.1)
excon (0.60.0) excon (0.60.0)
execjs (2.7.0) execjs (2.7.0)
factory_girl (4.9.0) factory_bot (4.8.2)
activesupport (>= 3.0.0) activesupport (>= 3.0.0)
faraday (0.12.2) faraday (0.12.2)
multipart-post (>= 1.2, < 3) multipart-post (>= 1.2, < 3)
@ -780,7 +780,7 @@ DEPENDENCIES
devise devise
dotenv-rails dotenv-rails
draper draper
factory_girl factory_bot
fog fog
fog-openstack fog-openstack
font-awesome-rails font-awesome-rails

View file

@ -4,11 +4,11 @@ describe StatsController, type: :controller do
describe "#last_four_months_hash" do describe "#last_four_months_hash" do
context "while a regular user is logged in" do context "while a regular user is logged in" do
before do before do
FactoryGirl.create(:procedure, :created_at => 6.months.ago, :updated_at => 6.months.ago) FactoryBot.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) FactoryBot.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) FactoryBot.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) FactoryBot.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 => 2.months.ago, :updated_at => Time.now)
@controller = StatsController.new @controller = StatsController.new
allow(@controller).to receive(:administration_signed_in?).and_return(false) 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 context "while a super admin is logged in" do
before do before do
FactoryGirl.create(:procedure, :updated_at => 6.months.ago) FactoryBot.create(:procedure, :updated_at => 6.months.ago)
FactoryGirl.create(:procedure, :updated_at => 45.days.ago) FactoryBot.create(:procedure, :updated_at => 45.days.ago)
FactoryGirl.create(:procedure, :updated_at => 1.day.ago) FactoryBot.create(:procedure, :updated_at => 1.day.ago)
FactoryGirl.create(:procedure, :updated_at => 1.day.ago) FactoryBot.create(:procedure, :updated_at => 1.day.ago)
@controller = StatsController.new @controller = StatsController.new
@ -54,11 +54,11 @@ describe StatsController, type: :controller do
describe '#cumulative_hash' do describe '#cumulative_hash' do
before do before do
Timecop.freeze(Time.new(2016, 10, 2)) Timecop.freeze(Time.new(2016, 10, 2))
FactoryGirl.create(:procedure, :created_at => 55.days.ago, :updated_at => 43.days.ago) FactoryBot.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) FactoryBot.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) FactoryBot.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) FactoryBot.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 => 15.days.ago, :updated_at => 1.hour.ago)
end end
after { Timecop.return } after { Timecop.return }
@ -142,21 +142,21 @@ describe StatsController, type: :controller do
# dossier_p1_c: 5 days # dossier_p1_c: 5 days
before do before do
procedure_1 = FactoryGirl.create(:procedure) procedure_1 = FactoryBot.create(:procedure)
procedure_2 = FactoryGirl.create(:procedure) procedure_2 = FactoryBot.create(:procedure)
dossier_p1_a = FactoryGirl.create(:dossier, dossier_p1_a = FactoryBot.create(:dossier,
:procedure => procedure_1, :procedure => procedure_1,
:en_construction_at => 2.months.ago.beginning_of_month, :en_construction_at => 2.months.ago.beginning_of_month,
:processed_at => 2.months.ago.beginning_of_month + 3.days) :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, :procedure => procedure_1,
:en_construction_at => 2.months.ago.beginning_of_month, :en_construction_at => 2.months.ago.beginning_of_month,
:processed_at => 2.months.ago.beginning_of_month + 1.days) :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, :procedure => procedure_1,
:en_construction_at => 1.months.ago.beginning_of_month, :en_construction_at => 1.months.ago.beginning_of_month,
:processed_at => 1.months.ago.beginning_of_month + 5.days) :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, :procedure => procedure_2,
:en_construction_at => 2.month.ago.beginning_of_month, :en_construction_at => 2.month.ago.beginning_of_month,
:processed_at => 2.month.ago.beginning_of_month + 4.days) :processed_at => 2.month.ago.beginning_of_month + 4.days)
@ -190,24 +190,24 @@ describe StatsController, type: :controller do
# dossier_p1_c: 50 minutes # dossier_p1_c: 50 minutes
before do before do
procedure_1 = FactoryGirl.create(:procedure, :with_type_de_champ, :types_de_champ_count => 24) procedure_1 = FactoryBot.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) procedure_2 = FactoryBot.create(:procedure, :with_type_de_champ, :types_de_champ_count => 48)
dossier_p1_a = FactoryGirl.create(:dossier, dossier_p1_a = FactoryBot.create(:dossier,
:procedure => procedure_1, :procedure => procedure_1,
:created_at => 2.months.ago.beginning_of_month, :created_at => 2.months.ago.beginning_of_month,
:en_construction_at => 2.months.ago.beginning_of_month + 30.minutes, :en_construction_at => 2.months.ago.beginning_of_month + 30.minutes,
:processed_at => 2.months.ago.beginning_of_month + 1.day) :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, :procedure => procedure_1,
:created_at => 2.months.ago.beginning_of_month, :created_at => 2.months.ago.beginning_of_month,
:en_construction_at => 2.months.ago.beginning_of_month + 10.minutes, :en_construction_at => 2.months.ago.beginning_of_month + 10.minutes,
:processed_at => 2.months.ago.beginning_of_month + 1.day) :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, :procedure => procedure_1,
:created_at => 1.months.ago.beginning_of_month, :created_at => 1.months.ago.beginning_of_month,
:en_construction_at => 1.months.ago.beginning_of_month + 50.minutes, :en_construction_at => 1.months.ago.beginning_of_month + 50.minutes,
:processed_at => 1.months.ago.beginning_of_month + 1.day) :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, :procedure => procedure_2,
:created_at => 2.month.ago.beginning_of_month, :created_at => 2.month.ago.beginning_of_month,
:en_construction_at => 2.month.ago.beginning_of_month + 80.minutes, :en_construction_at => 2.month.ago.beginning_of_month + 80.minutes,

View file

@ -1,4 +1,4 @@
FactoryGirl.define do FactoryBot.define do
sequence(:administrateur_email) { |n| "admin#{n}@admin.com" } sequence(:administrateur_email) { |n| "admin#{n}@admin.com" }
factory :administrateur do factory :administrateur do
email { generate(:administrateur_email) } email { generate(:administrateur_email) }

View file

@ -1,4 +1,4 @@
FactoryGirl.define do FactoryBot.define do
sequence(:administration_email) { |n| "plop#{n}@plop.com" } sequence(:administration_email) { |n| "plop#{n}@plop.com" }
factory :administration do factory :administration do
email { generate(:administration_email) } email { generate(:administration_email) }

View file

@ -1,4 +1,4 @@
FactoryGirl.define do FactoryBot.define do
factory :assign_to do factory :assign_to do
end end
end end

View file

@ -1,4 +1,4 @@
FactoryGirl.define do FactoryBot.define do
factory :attestation_template do factory :attestation_template do
title 'title' title 'title'
body 'body' body 'body'

View file

@ -1,4 +1,4 @@
FactoryGirl.define do FactoryBot.define do
factory :avis do factory :avis do
introduction 'Bonjour, merci de me donner votre avis sur ce dossier' introduction 'Bonjour, merci de me donner votre avis sur ce dossier'

View file

@ -1,4 +1,4 @@
FactoryGirl.define do FactoryBot.define do
factory :cadastre do factory :cadastre do
numero '001' numero '001'
feuille 1 feuille 1

View file

@ -1,4 +1,4 @@
FactoryGirl.define do FactoryBot.define do
factory :cerfa do factory :cerfa do
end end
end end

View file

@ -1,21 +1,21 @@
FactoryGirl.define do FactoryBot.define do
factory :champ 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 trait :checkbox do
type_de_champ { FactoryGirl.create(:type_de_champ_public, :checkbox) } type_de_champ { FactoryBot.create(:type_de_champ_public, :checkbox) }
end end
trait :header_section do 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 end
trait :explication do trait :explication do
type_de_champ { FactoryGirl.create(:type_de_champ_public, :explication) } type_de_champ { FactoryBot.create(:type_de_champ_public, :explication) }
end end
trait :dossier_link do 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 end
end end

View file

@ -1,4 +1,4 @@
FactoryGirl.define do FactoryBot.define do
factory :commentaire do factory :commentaire do
body 'plop' body 'plop'

View file

@ -1,4 +1,4 @@
FactoryGirl.define do FactoryBot.define do
factory :dossier do factory :dossier do
state 'brouillon' state 'brouillon'
association :user, factory: [:user] association :user, factory: [:user]

View file

@ -1,4 +1,4 @@
FactoryGirl.define do FactoryBot.define do
factory :drop_down_list do factory :drop_down_list do
value "val1\r\nval2\r\n--separateur--\r\nval3" value "val1\r\nval2\r\n--separateur--\r\nval3"
end end

View file

@ -1,4 +1,4 @@
FactoryGirl.define do FactoryBot.define do
factory :entreprise do factory :entreprise do
siren '440117620' siren '440117620'
capital_social 537_100_000 capital_social 537_100_000

View file

@ -1,4 +1,4 @@
FactoryGirl.define do FactoryBot.define do
factory :etablissement do factory :etablissement do
siret '44011762001530' siret '44011762001530'
siege_social true siege_social true

View file

@ -1,4 +1,4 @@
FactoryGirl.define do FactoryBot.define do
factory :exercice do factory :exercice do
ca '12345678' ca '12345678'
dateFinExercice "2014-12-30 23:00:00" dateFinExercice "2014-12-30 23:00:00"

View file

@ -1,4 +1,4 @@
FactoryGirl.define do FactoryBot.define do
factory :follow do factory :follow do
end end
end end

View file

@ -1,4 +1,4 @@
FactoryGirl.define do FactoryBot.define do
factory :france_connect_information do factory :france_connect_information do
given_name 'plop' given_name 'plop'
family_name 'plip' family_name 'plip'

View file

@ -1,4 +1,4 @@
FactoryGirl.define do FactoryBot.define do
sequence(:gestionnaire_email) { |n| "gest#{n}@gest.com" } sequence(:gestionnaire_email) { |n| "gest#{n}@gest.com" }
factory :gestionnaire do factory :gestionnaire do
email { generate(:gestionnaire_email) } email { generate(:gestionnaire_email) }

View file

@ -1,4 +1,4 @@
FactoryGirl.define do FactoryBot.define do
factory :individual do factory :individual do
gender 'M.' gender 'M.'
nom 'Julien' nom 'Julien'

View file

@ -1,4 +1,4 @@
FactoryGirl.define do FactoryBot.define do
factory :invite do factory :invite do
email 'plop@octo.com' email 'plop@octo.com'

View file

@ -1,4 +1,4 @@
FactoryGirl.define do FactoryBot.define do
factory :invite_user do factory :invite_user do
email 'plop@octo.com' email 'plop@octo.com'

View file

@ -1,4 +1,4 @@
FactoryGirl.define do FactoryBot.define do
factory :closed_mail, class: Mails::ClosedMail do factory :closed_mail, class: Mails::ClosedMail do
subject "Subject, voila voila" subject "Subject, voila voila"
body "Blabla ceci est mon body" body "Blabla ceci est mon body"

View file

@ -1,4 +1,4 @@
FactoryGirl.define do FactoryBot.define do
factory :module_api_carto do factory :module_api_carto do
use_api_carto false use_api_carto false
quartiers_prioritaires false quartiers_prioritaires false

View file

@ -1,4 +1,4 @@
FactoryGirl.define do FactoryBot.define do
factory :notification do factory :notification do
type_notif 'commentaire' type_notif 'commentaire'
liste [] liste []

View file

@ -1,4 +1,4 @@
FactoryGirl.define do FactoryBot.define do
factory :piece_justificative do factory :piece_justificative do
trait :rib do trait :rib do
content Rack::Test::UploadedFile.new("./spec/support/files/RIB.pdf", 'application/pdf') content Rack::Test::UploadedFile.new("./spec/support/files/RIB.pdf", 'application/pdf')

View file

@ -1,4 +1,4 @@
FactoryGirl.define do FactoryBot.define do
sequence(:published_path) { |n| "fake_path#{n}" } sequence(:published_path) { |n| "fake_path#{n}" }
factory :procedure do factory :procedure do
lien_demarche 'http://localhost' lien_demarche 'http://localhost'

View file

@ -1,4 +1,4 @@
FactoryGirl.define do FactoryBot.define do
factory :procedure_path do factory :procedure_path do
path 'fake_path' path 'fake_path'
end end

View file

@ -1,4 +1,4 @@
FactoryGirl.define do FactoryBot.define do
factory :quartier_prioritaire do factory :quartier_prioritaire do
code 'QPcode' code 'QPcode'
commune 'Paris' commune 'Paris'

View file

@ -1,4 +1,4 @@
FactoryGirl.define do FactoryBot.define do
factory :rna_information do factory :rna_information do
association_id "W072000535" association_id "W072000535"
titre "ASSOCIATION POUR LA PROMOTION DE SPECTACLES AU CHATEAU DE ROCHEMAURE" titre "ASSOCIATION POUR LA PROMOTION DE SPECTACLES AU CHATEAU DE ROCHEMAURE"

View file

@ -1,4 +1,4 @@
FactoryGirl.define do FactoryBot.define do
factory :type_de_champ_private do factory :type_de_champ_private do
sequence(:libelle) { |n| "Libelle champ privé #{n}" } sequence(:libelle) { |n| "Libelle champ privé #{n}" }
sequence(:description) { |n| "description du champ privé #{n}" } sequence(:description) { |n| "description du champ privé #{n}" }

View file

@ -1,4 +1,4 @@
FactoryGirl.define do FactoryBot.define do
factory :type_de_champ_public do factory :type_de_champ_public do
sequence(:libelle) { |n| "Libelle du champ #{n}" } sequence(:libelle) { |n| "Libelle du champ #{n}" }
sequence(:description) { |n| "description du champ #{n}" } sequence(:description) { |n| "description du champ #{n}" }

View file

@ -1,4 +1,4 @@
FactoryGirl.define do FactoryBot.define do
factory :type_de_piece_justificative do factory :type_de_piece_justificative do
libelle 'RIB' libelle 'RIB'
description 'Releve identité bancaire' description 'Releve identité bancaire'

View file

@ -1,4 +1,4 @@
FactoryGirl.define do FactoryBot.define do
sequence(:user_email) { |n| "user#{n}@user.com" } sequence(:user_email) { |n| "user#{n}@user.com" }
factory :user do factory :user do
email { generate(:user_email) } email { generate(:user_email) }

View file

@ -107,7 +107,7 @@ feature 'The gestionnaire part' do
end end
scenario 'A gestionnaire can see the personnes impliquées' do 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) log_in(gestionnaire.email, password)

View file

@ -30,7 +30,7 @@ describe Commentaire do
let(:user_invite) { create(:user) } let(:user_invite) { create(:user) }
before do 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 end
it "calls notify_gestionnaires" do it "calls notify_gestionnaires" do

View file

@ -26,7 +26,7 @@ require 'database_cleaner'
require 'webmock/rspec' require 'webmock/rspec'
require 'shoulda-matchers' require 'shoulda-matchers'
require 'devise' require 'devise'
require 'factory_girl' require 'factory_bot'
require 'selenium/webdriver' require 'selenium/webdriver'
Capybara.javascript_driver = :headless_chrome 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: :controller
config.include Devise::Test::ControllerHelpers, type: :view config.include Devise::Test::ControllerHelpers, type: :view
config.include FactoryGirl::Syntax::Methods config.include FactoryBot::Syntax::Methods
config.before(:each) do config.before(:each) do
allow_any_instance_of(PieceJustificativeUploader).to receive(:generate_secure_token).and_return("3dbb3535-5388-4a37-bc2d-778327b9f997") allow_any_instance_of(PieceJustificativeUploader).to receive(:generate_secure_token).and_return("3dbb3535-5388-4a37-bc2d-778327b9f997")

View file

@ -1,3 +1,3 @@
RSpec.configure do |config| RSpec.configure do |config|
config.include FactoryGirl::Syntax::Methods config.include FactoryBot::Syntax::Methods
end end

View file

@ -11,7 +11,7 @@ module FeatureHelpers
end end
def create_dossier def create_dossier
dossier = FactoryGirl.create(:dossier) dossier = FactoryBot.create(:dossier)
dossier dossier
end end
end end