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
gem 'capybara'
gem 'launchy'
gem 'factory_girl'
gem 'factory_bot'
gem 'database_cleaner'
gem 'webmock'
gem 'shoulda-matchers', require: false

View file

@ -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

View file

@ -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,

View file

@ -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) }

View file

@ -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) }

View file

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

View file

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

View file

@ -1,4 +1,4 @@
FactoryGirl.define do
FactoryBot.define do
factory :avis do
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
numero '001'
feuille 1

View file

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

View file

@ -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

View file

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

View file

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

View file

@ -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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -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) }

View file

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

View file

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

View file

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

View file

@ -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"

View file

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

View file

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

View file

@ -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')

View file

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

View file

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

View file

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

View file

@ -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"

View file

@ -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}" }

View file

@ -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}" }

View file

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

View file

@ -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) }

View file

@ -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)

View file

@ -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

View file

@ -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")

View file

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

View file

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