Skip to content

Commit 627a968

Browse files
author
Robert Speicher
committed
Merge branch 'rc/use-factory_bot_rails' into 'master'
Replace factory_girl_rails with factory_bot_rails See merge request gitlab-org/gitlab-ce!15919
2 parents d2f313d + 4af9d59 commit 627a968

File tree

125 files changed

+175
-175
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

125 files changed

+175
-175
lines changed

Gemfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ group :development, :test do
311311
gem 'fuubar', '~> 2.2.0'
312312

313313
gem 'database_cleaner', '~> 1.5.0'
314-
gem 'factory_girl_rails', '~> 4.7.0'
314+
gem 'factory_bot_rails', '~> 4.8.2'
315315
gem 'rspec-rails', '~> 3.6.0'
316316
gem 'rspec-retry', '~> 0.4.5'
317317
gem 'spinach-rails', '~> 0.2.1'

Gemfile.lock

+4-4
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,10 @@ GEM
195195
excon (0.57.1)
196196
execjs (2.6.0)
197197
expression_parser (0.9.0)
198-
factory_girl (4.7.0)
198+
factory_bot (4.8.2)
199199
activesupport (>= 3.0.0)
200-
factory_girl_rails (4.7.0)
201-
factory_girl (~> 4.7.0)
200+
factory_bot_rails (4.8.2)
201+
factory_bot (~> 4.8.2)
202202
railties (>= 3.0.0)
203203
faraday (0.12.2)
204204
multipart-post (>= 1.2, < 3)
@@ -1020,7 +1020,7 @@ DEPENDENCIES
10201020
dropzonejs-rails (~> 0.7.1)
10211021
email_reply_trimmer (~> 0.1)
10221022
email_spec (~> 1.6.0)
1023-
factory_girl_rails (~> 4.7.0)
1023+
factory_bot_rails (~> 4.8.2)
10241024
faraday (~> 0.12)
10251025
ffaker (~> 2.4)
10261026
flay (~> 2.8.0)

app/controllers/projects/notes_controller.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class Projects::NotesController < Projects::ApplicationController
1111
# Controller actions are returned from AbstractController::Base and methods of parent classes are
1212
# excluded in order to return only specific controller related methods.
1313
# That is ok for the app (no :create method in ancestors)
14-
# but fails for tests because there is a :create method on FactoryGirl (one of the ancestors)
14+
# but fails for tests because there is a :create method on FactoryBot (one of the ancestors)
1515
#
1616
# see https://github.com/rails/rails/blob/v4.2.7/actionpack/lib/abstract_controller/base.rb#L78
1717
#

config/application.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ class Application < Rails::Application
163163
config.middleware.insert_after ActionDispatch::Flash, 'Gitlab::Middleware::ReadOnly'
164164

165165
config.generators do |g|
166-
g.factory_girl false
166+
g.factory_bot false
167167
end
168168

169169
config.after_initialize do

db/fixtures/development/17_cycle_analytics.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,8 @@ def add_milestones_and_list_labels(issues)
140140
issue.update(milestone: @project.milestones.sample)
141141
else
142142
label_name = "#{FFaker::Product.brand}-#{FFaker::Product.brand}-#{rand(1000)}"
143-
list_label = FactoryGirl.create(:label, title: label_name, project: issue.project)
144-
FactoryGirl.create(:list, board: FactoryGirl.create(:board, project: issue.project), label: list_label)
143+
list_label = FactoryBot.create(:label, title: label_name, project: issue.project)
144+
FactoryBot.create(:list, board: FactoryBot.create(:board, project: issue.project), label: list_label)
145145
issue.update(labels: [list_label])
146146
end
147147

doc/development/gotchas.md

+2-2

doc/development/testing_guide/best_practices.md

+7-7

doc/development/testing_guide/index.md

+1-1

features/support/env.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
# web editor and merge
2828
TestEnv.disable_pre_receive
2929

30-
include FactoryGirl::Syntax::Methods
30+
include FactoryBot::Syntax::Methods
3131
include GitlabRoutingHelper
3232
end
3333

spec/factories/abuse_reports.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FactoryGirl.define do
1+
FactoryBot.define do
22
factory :abuse_report do
33
reporter factory: :user
44
user

spec/factories/appearances.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Read about factories at https://github.com/thoughtbot/factory_girl
1+
# Read about factories at https://github.com/thoughtbot/factory_bot
22

3-
FactoryGirl.define do
3+
FactoryBot.define do
44
factory :appearance do
55
title "MepMep"
66
description "This is my Community Edition instance"
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FactoryGirl.define do
1+
FactoryBot.define do
22
factory :application_setting do
33
end
44
end

spec/factories/award_emoji.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FactoryGirl.define do
1+
FactoryBot.define do
22
factory :award_emoji do
33
name "thumbsup"
44
user

spec/factories/boards.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FactoryGirl.define do
1+
FactoryBot.define do
22
factory :board do
33
project
44

spec/factories/broadcast_messages.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FactoryGirl.define do
1+
FactoryBot.define do
22
factory :broadcast_message do
33
message "MyText"
44
starts_at 1.day.ago

spec/factories/chat_names.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FactoryGirl.define do
1+
FactoryBot.define do
22
factory :chat_name, class: ChatName do
33
user factory: :user
44
service factory: :service

spec/factories/chat_teams.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FactoryGirl.define do
1+
FactoryBot.define do
22
factory :chat_team, class: ChatTeam do
33
sequence(:team_id) { |n| "abcdefghijklm#{n}" }
44
namespace factory: :group

spec/factories/ci/build_trace_section_names.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FactoryGirl.define do
1+
FactoryBot.define do
22
factory :ci_build_trace_section_name, class: Ci::BuildTraceSectionName do
33
sequence(:name) { |n| "section_#{n}" }
44
project factory: :project

spec/factories/ci/builds.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
include ActionDispatch::TestProcess
22

3-
FactoryGirl.define do
3+
FactoryBot.define do
44
factory :ci_build, class: Ci::Build do
55
name 'test'
66
stage 'test'

spec/factories/ci/group_variables.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FactoryGirl.define do
1+
FactoryBot.define do
22
factory :ci_group_variable, class: Ci::GroupVariable do
33
sequence(:key) { |n| "VARIABLE_#{n}" }
44
value 'VARIABLE_VALUE'

spec/factories/ci/job_artifacts.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
include ActionDispatch::TestProcess
22

3-
FactoryGirl.define do
3+
FactoryBot.define do
44
factory :ci_job_artifact, class: Ci::JobArtifact do
55
job factory: :ci_build
66
file_type :archive

spec/factories/ci/pipeline_schedule.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FactoryGirl.define do
1+
FactoryBot.define do
22
factory :ci_pipeline_schedule, class: Ci::PipelineSchedule do
33
cron '0 1 * * *'
44
cron_timezone Gitlab::Ci::CronParser::VALID_SYNTAX_SAMPLE_TIME_ZONE

spec/factories/ci/pipeline_schedule_variables.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FactoryGirl.define do
1+
FactoryBot.define do
22
factory :ci_pipeline_schedule_variable, class: Ci::PipelineScheduleVariable do
33
sequence(:key) { |n| "VARIABLE_#{n}" }
44
value 'VARIABLE_VALUE'

spec/factories/ci/pipeline_variables.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FactoryGirl.define do
1+
FactoryBot.define do
22
factory :ci_pipeline_variable, class: Ci::PipelineVariable do
33
sequence(:key) { |n| "VARIABLE_#{n}" }
44
value 'VARIABLE_VALUE'

spec/factories/ci/pipelines.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FactoryGirl.define do
1+
FactoryBot.define do
22
factory :ci_empty_pipeline, class: Ci::Pipeline do
33
source :push
44
ref 'master'

spec/factories/ci/runner_projects.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FactoryGirl.define do
1+
FactoryBot.define do
22
factory :ci_runner_project, class: Ci::RunnerProject do
33
runner factory: :ci_runner
44
project

spec/factories/ci/runners.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FactoryGirl.define do
1+
FactoryBot.define do
22
factory :ci_runner, class: Ci::Runner do
33
sequence(:description) { |n| "My runner#{n}" }
44

spec/factories/ci/stages.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FactoryGirl.define do
1+
FactoryBot.define do
22
factory :ci_stage, class: Ci::LegacyStage do
33
skip_create
44

spec/factories/ci/trigger_requests.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FactoryGirl.define do
1+
FactoryBot.define do
22
factory :ci_trigger_request, class: Ci::TriggerRequest do
33
trigger factory: :ci_trigger
44
end

spec/factories/ci/triggers.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FactoryGirl.define do
1+
FactoryBot.define do
22
factory :ci_trigger_without_token, class: Ci::Trigger do
33
owner
44

spec/factories/ci/variables.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FactoryGirl.define do
1+
FactoryBot.define do
22
factory :ci_variable, class: Ci::Variable do
33
sequence(:key) { |n| "VARIABLE_#{n}" }
44
value 'VARIABLE_VALUE'

spec/factories/clusters/applications/helm.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FactoryGirl.define do
1+
FactoryBot.define do
22
factory :cluster_applications_helm, class: Clusters::Applications::Helm do
33
cluster factory: %i(cluster provided_by_gcp)
44

spec/factories/clusters/applications/ingress.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FactoryGirl.define do
1+
FactoryBot.define do
22
factory :cluster_applications_ingress, class: Clusters::Applications::Ingress do
33
cluster factory: %i(cluster provided_by_gcp)
44

spec/factories/clusters/clusters.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FactoryGirl.define do
1+
FactoryBot.define do
22
factory :cluster, class: Clusters::Cluster do
33
user
44
name 'test-cluster'

spec/factories/clusters/platforms/kubernetes.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FactoryGirl.define do
1+
FactoryBot.define do
22
factory :cluster_platform_kubernetes, class: Clusters::Platforms::Kubernetes do
33
cluster
44
namespace nil

spec/factories/clusters/providers/gcp.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FactoryGirl.define do
1+
FactoryBot.define do
22
factory :cluster_provider_gcp, class: Clusters::Providers::Gcp do
33
cluster
44
gcp_project_id 'test-gcp-project'

spec/factories/commit_statuses.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FactoryGirl.define do
1+
FactoryBot.define do
22
factory :commit_status, class: CommitStatus do
33
name 'default'
44
stage 'test'

spec/factories/commits.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require_relative '../support/repo_helpers'
22

3-
FactoryGirl.define do
3+
FactoryBot.define do
44
factory :commit do
55
transient do
66
author nil

spec/factories/container_repositories.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FactoryGirl.define do
1+
FactoryBot.define do
22
factory :container_repository do
33
name 'test_container_image'
44
project

spec/factories/conversational_development_index_metrics.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FactoryGirl.define do
1+
FactoryBot.define do
22
factory :conversational_development_index_metric, class: ConversationalDevelopmentIndex::Metric do
33
leader_issues 9.256
44
instance_issues 1.234

spec/factories/deploy_keys_projects.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FactoryGirl.define do
1+
FactoryBot.define do
22
factory :deploy_keys_project do
33
deploy_key
44
project

spec/factories/deployments.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FactoryGirl.define do
1+
FactoryBot.define do
22
factory :deployment, class: Deployment do
33
sha '97de212e80737a608d939f648d959671fb0a0142'
44
ref 'master'

spec/factories/emails.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FactoryGirl.define do
1+
FactoryBot.define do
22
factory :email do
33
user
44
email { generate(:email_alias) }

spec/factories/environments.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FactoryGirl.define do
1+
FactoryBot.define do
22
factory :environment, class: Environment do
33
sequence(:name) { |n| "environment#{n}" }
44

spec/factories/events.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FactoryGirl.define do
1+
FactoryBot.define do
22
factory :event do
33
project
44
author factory: :user

spec/factories/file_uploaders.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FactoryGirl.define do
1+
FactoryBot.define do
22
factory :file_uploader do
33
skip_create
44

spec/factories/fork_network_members.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FactoryGirl.define do
1+
FactoryBot.define do
22
factory :fork_network_member do
33
association :project
44
association :fork_network

spec/factories/fork_networks.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FactoryGirl.define do
1+
FactoryBot.define do
22
factory :fork_network do
33
association :root_project, factory: :project
44
end

spec/factories/forked_project_links.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FactoryGirl.define do
1+
FactoryBot.define do
22
factory :forked_project_link do
33
association :forked_to_project, factory: [:project, :repository]
44
association :forked_from_project, factory: [:project, :repository]

spec/factories/gitaly/commit.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FactoryGirl.define do
1+
FactoryBot.define do
22
sequence(:gitaly_commit_id) { Digest::SHA1.hexdigest(Time.now.to_f.to_s) }
33

44
factory :gitaly_commit, class: Gitaly::GitCommit do

spec/factories/gitaly/commit_author.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FactoryGirl.define do
1+
FactoryBot.define do
22
factory :gitaly_commit_author, class: Gitaly::CommitAuthor do
33
skip_create
44

0 commit comments

Comments
 (0)