Commit 4fe186c5 authored by Robert Speicher's avatar Robert Speicher

Merge branch 'ee-rc/use-factory_bot_rails' into 'master'

[EE] Replace factory_girl_rails with factory_bot_rails

See merge request gitlab-org/gitlab-ee!3783
parents 65924174 a7957059
...@@ -323,7 +323,7 @@ group :development, :test do ...@@ -323,7 +323,7 @@ group :development, :test do
gem 'fuubar', '~> 2.2.0' gem 'fuubar', '~> 2.2.0'
gem 'database_cleaner', '~> 1.5.0' gem 'database_cleaner', '~> 1.5.0'
gem 'factory_girl_rails', '~> 4.7.0' gem 'factory_bot_rails', '~> 4.8.2'
gem 'rspec-rails', '~> 3.6.0' gem 'rspec-rails', '~> 3.6.0'
gem 'rspec-retry', '~> 0.4.5' gem 'rspec-retry', '~> 0.4.5'
gem 'spinach-rails', '~> 0.2.1' gem 'spinach-rails', '~> 0.2.1'
......
...@@ -216,10 +216,10 @@ GEM ...@@ -216,10 +216,10 @@ GEM
excon (0.57.1) excon (0.57.1)
execjs (2.6.0) execjs (2.6.0)
expression_parser (0.9.0) expression_parser (0.9.0)
factory_girl (4.7.0) factory_bot (4.8.2)
activesupport (>= 3.0.0) activesupport (>= 3.0.0)
factory_girl_rails (4.7.0) factory_bot_rails (4.8.2)
factory_girl (~> 4.7.0) factory_bot (~> 4.8.2)
railties (>= 3.0.0) railties (>= 3.0.0)
faraday (0.12.2) faraday (0.12.2)
multipart-post (>= 1.2, < 3) multipart-post (>= 1.2, < 3)
...@@ -1054,7 +1054,7 @@ DEPENDENCIES ...@@ -1054,7 +1054,7 @@ DEPENDENCIES
elasticsearch-rails (~> 0.1.9) elasticsearch-rails (~> 0.1.9)
email_reply_trimmer (~> 0.1) email_reply_trimmer (~> 0.1)
email_spec (~> 1.6.0) email_spec (~> 1.6.0)
factory_girl_rails (~> 4.7.0) factory_bot_rails (~> 4.8.2)
faraday (~> 0.12) faraday (~> 0.12)
faraday_middleware-aws-signers-v4 faraday_middleware-aws-signers-v4
ffaker (~> 2.4) ffaker (~> 2.4)
......
...@@ -11,7 +11,7 @@ class Projects::NotesController < Projects::ApplicationController ...@@ -11,7 +11,7 @@ class Projects::NotesController < Projects::ApplicationController
# Controller actions are returned from AbstractController::Base and methods of parent classes are # Controller actions are returned from AbstractController::Base and methods of parent classes are
# excluded in order to return only specific controller related methods. # excluded in order to return only specific controller related methods.
# That is ok for the app (no :create method in ancestors) # That is ok for the app (no :create method in ancestors)
# but fails for tests because there is a :create method on FactoryGirl (one of the ancestors) # but fails for tests because there is a :create method on FactoryBot (one of the ancestors)
# #
# see https://github.com/rails/rails/blob/v4.2.7/actionpack/lib/abstract_controller/base.rb#L78 # see https://github.com/rails/rails/blob/v4.2.7/actionpack/lib/abstract_controller/base.rb#L78
# #
......
...@@ -180,7 +180,7 @@ module Gitlab ...@@ -180,7 +180,7 @@ module Gitlab
config.middleware.insert_after ActionDispatch::Flash, 'Gitlab::Middleware::ReadOnly' config.middleware.insert_after ActionDispatch::Flash, 'Gitlab::Middleware::ReadOnly'
config.generators do |g| config.generators do |g|
g.factory_girl false g.factory_bot false
end end
config.after_initialize do config.after_initialize do
......
...@@ -140,8 +140,8 @@ class Gitlab::Seeder::CycleAnalytics ...@@ -140,8 +140,8 @@ class Gitlab::Seeder::CycleAnalytics
issue.update(milestone: @project.milestones.sample) issue.update(milestone: @project.milestones.sample)
else else
label_name = "#{FFaker::Product.brand}-#{FFaker::Product.brand}-#{rand(1000)}" label_name = "#{FFaker::Product.brand}-#{FFaker::Product.brand}-#{rand(1000)}"
list_label = FactoryGirl.create(:label, title: label_name, project: issue.project) list_label = FactoryBot.create(:label, title: label_name, project: issue.project)
FactoryGirl.create(:list, board: FactoryGirl.create(:board, project: issue.project), label: list_label) FactoryBot.create(:list, board: FactoryBot.create(:board, project: issue.project), label: list_label)
issue.update(labels: [list_label]) issue.update(labels: [list_label])
end end
......
...@@ -8,7 +8,7 @@ might encounter or should avoid during development of GitLab CE and EE. ...@@ -8,7 +8,7 @@ might encounter or should avoid during development of GitLab CE and EE.
Consider the following factory: Consider the following factory:
```ruby ```ruby
FactoryGirl.define do FactoryBot.define do
factory :label do factory :label do
sequence(:title) { |n| "label#{n}" } sequence(:title) { |n| "label#{n}" }
end end
...@@ -53,7 +53,7 @@ When run, this spec doesn't do what we might expect: ...@@ -53,7 +53,7 @@ When run, this spec doesn't do what we might expect:
(compared using ==) (compared using ==)
``` ```
That's because FactoryGirl sequences are not reseted for each example. That's because FactoryBot sequences are not reseted for each example.
Please remember that sequence-generated values exist only to avoid having to Please remember that sequence-generated values exist only to avoid having to
explicitly set attributes that have a uniqueness constraint when using a factory. explicitly set attributes that have a uniqueness constraint when using a factory.
......
...@@ -8,8 +8,8 @@ and effective _as well as_ fast. ...@@ -8,8 +8,8 @@ and effective _as well as_ fast.
Here are some things to keep in mind regarding test performance: Here are some things to keep in mind regarding test performance:
- `double` and `spy` are faster than `FactoryGirl.build(...)` - `double` and `spy` are faster than `FactoryBot.build(...)`
- `FactoryGirl.build(...)` and `.build_stubbed` are faster than `.create`. - `FactoryBot.build(...)` and `.build_stubbed` are faster than `.create`.
- Don't `create` an object when `build`, `build_stubbed`, `attributes_for`, - Don't `create` an object when `build`, `build_stubbed`, `attributes_for`,
`spy`, or `double` will do. Database persistence is slow! `spy`, or `double` will do. Database persistence is slow!
- Don't mark a feature as requiring JavaScript (through `@javascript` in - Don't mark a feature as requiring JavaScript (through `@javascript` in
...@@ -254,13 +254,13 @@ end ...@@ -254,13 +254,13 @@ end
### Factories ### Factories
GitLab uses [factory_girl] as a test fixture replacement. GitLab uses [factory_bot] as a test fixture replacement.
- Factory definitions live in `spec/factories/`, named using the pluralization - Factory definitions live in `spec/factories/`, named using the pluralization
of their corresponding model (`User` factories are defined in `users.rb`). of their corresponding model (`User` factories are defined in `users.rb`).
- There should be only one top-level factory definition per file. - There should be only one top-level factory definition per file.
- FactoryGirl methods are mixed in to all RSpec groups. This means you can (and - FactoryBot methods are mixed in to all RSpec groups. This means you can (and
should) call `create(...)` instead of `FactoryGirl.create(...)`. should) call `create(...)` instead of `FactoryBot.create(...)`.
- Make use of [traits] to clean up definitions and usages. - Make use of [traits] to clean up definitions and usages.
- When defining a factory, don't define attributes that are not required for the - When defining a factory, don't define attributes that are not required for the
resulting record to pass validation. resulting record to pass validation.
...@@ -269,8 +269,8 @@ GitLab uses [factory_girl] as a test fixture replacement. ...@@ -269,8 +269,8 @@ GitLab uses [factory_girl] as a test fixture replacement.
- Factories don't have to be limited to `ActiveRecord` objects. - Factories don't have to be limited to `ActiveRecord` objects.
[See example](https://gitlab.com/gitlab-org/gitlab-ce/commit/0b8cefd3b2385a21cfed779bd659978c0402766d). [See example](https://gitlab.com/gitlab-org/gitlab-ce/commit/0b8cefd3b2385a21cfed779bd659978c0402766d).
[factory_girl]: https://github.com/thoughtbot/factory_girl [factory_bot]: https://github.com/thoughtbot/factory_bot
[traits]: http://www.rubydoc.info/gems/factory_girl/file/GETTING_STARTED.md#Traits [traits]: http://www.rubydoc.info/gems/factory_bot/file/GETTING_STARTED.md#Traits
### Fixtures ### Fixtures
......
...@@ -33,7 +33,7 @@ changes should be tested. ...@@ -33,7 +33,7 @@ changes should be tested.
## [Testing best practices](best_practices.md) ## [Testing best practices](best_practices.md)
Everything you should know about how to write good tests: RSpec, FactoryGirl, Everything you should know about how to write good tests: RSpec, FactoryBot,
system tests, parameterized tests etc. system tests, parameterized tests etc.
--- ---
......
...@@ -35,7 +35,7 @@ Spinach.hooks.before_run do ...@@ -35,7 +35,7 @@ Spinach.hooks.before_run do
# web editor and merge # web editor and merge
TestEnv.disable_pre_receive TestEnv.disable_pre_receive
include FactoryGirl::Syntax::Methods include FactoryBot::Syntax::Methods
include GitlabRoutingHelper include GitlabRoutingHelper
end end
......
require 'spec_helper' require 'spec_helper'
describe Gitlab::Geo::JwtRequestDecoder do describe Gitlab::Geo::JwtRequestDecoder do
let!(:primary_node) { FactoryGirl.create(:geo_node, :primary) } let!(:primary_node) { FactoryBot.create(:geo_node, :primary) }
let(:data) { { input: 123 } } let(:data) { { input: 123 } }
let(:request) { Gitlab::Geo::TransferRequest.new(data) } let(:request) { Gitlab::Geo::TransferRequest.new(data) }
......
...@@ -2,12 +2,12 @@ require 'spec_helper' ...@@ -2,12 +2,12 @@ require 'spec_helper'
describe Gitlab::Geo::OauthSession do describe Gitlab::Geo::OauthSession do
subject { described_class.new } subject { described_class.new }
let(:oauth_app) { FactoryGirl.create(:doorkeeper_application) } let(:oauth_app) { FactoryBot.create(:doorkeeper_application) }
let(:oauth_return_to) { 'http://localhost:3000/oauth/geo/callback' } let(:oauth_return_to) { 'http://localhost:3000/oauth/geo/callback' }
let(:dummy_state) { 'salt:hmac:return_to' } let(:dummy_state) { 'salt:hmac:return_to' }
let(:valid_state) { described_class.new(return_to: oauth_return_to).generate_oauth_state } let(:valid_state) { described_class.new(return_to: oauth_return_to).generate_oauth_state }
let(:access_token) { FactoryGirl.create(:doorkeeper_access_token).token } let(:access_token) { FactoryBot.create(:doorkeeper_access_token).token }
let(:user) { FactoryGirl.build(:user) } let(:user) { FactoryBot.build(:user) }
before do before do
allow(subject).to receive(:oauth_app) { oauth_app } allow(subject).to receive(:oauth_app) { oauth_app }
......
...@@ -63,7 +63,7 @@ describe GeoNode, type: :model do ...@@ -63,7 +63,7 @@ describe GeoNode, type: :model do
end end
context 'cache expiration' do context 'cache expiration' do
let(:new_node) { FactoryGirl.build(:geo_node) } let(:new_node) { FactoryBot.build(:geo_node) }
it 'expires cache when saved' do it 'expires cache when saved' do
expect(new_node).to receive(:expire_cache!).at_least(:once) expect(new_node).to receive(:expire_cache!).at_least(:once)
......
FactoryGirl.define do FactoryBot.define do
factory :abuse_report do factory :abuse_report do
reporter factory: :user reporter factory: :user
user user
......
# Read about factories at https://github.com/thoughtbot/factory_girl # Read about factories at https://github.com/thoughtbot/factory_bot
FactoryGirl.define do FactoryBot.define do
factory :appearance do factory :appearance do
title "GitLab Enterprise Edition" title "GitLab Enterprise Edition"
description "Open source software to collaborate on code" description "Open source software to collaborate on code"
......
FactoryGirl.define do FactoryBot.define do
factory :application_setting do factory :application_setting do
end end
end end
# Read about factories at https://github.com/thoughtbot/factory_girl # Read about factories at https://github.com/thoughtbot/factory_bot
FactoryGirl.define do FactoryBot.define do
factory :approval do factory :approval do
merge_request merge_request
user user
......
# Read about factories at https://github.com/thoughtbot/factory_girl # Read about factories at https://github.com/thoughtbot/factory_bot
FactoryGirl.define do FactoryBot.define do
factory :approver_group do factory :approver_group do
target factory: :merge_request target factory: :merge_request
group group
......
# Read about factories at https://github.com/thoughtbot/factory_girl # Read about factories at https://github.com/thoughtbot/factory_bot
FactoryGirl.define do FactoryBot.define do
factory :approver do factory :approver do
target factory: :merge_request target factory: :merge_request
user user
......
FactoryGirl.define do FactoryBot.define do
factory :audit_event, aliases: [:user_audit_event] do factory :audit_event, aliases: [:user_audit_event] do
user user
type 'SecurityEvent' type 'SecurityEvent'
......
FactoryGirl.define do FactoryBot.define do
factory :award_emoji do factory :award_emoji do
name "thumbsup" name "thumbsup"
user user
......
FactoryGirl.define do FactoryBot.define do
factory :board_label do factory :board_label do
association :board association :board
association :label association :label
......
FactoryGirl.define do FactoryBot.define do
factory :board do factory :board do
sequence(:name) { |n| "board#{n}" } sequence(:name) { |n| "board#{n}" }
......
FactoryGirl.define do FactoryBot.define do
factory :broadcast_message do factory :broadcast_message do
message "MyText" message "MyText"
starts_at 1.day.ago starts_at 1.day.ago
......
FactoryGirl.define do FactoryBot.define do
factory :chat_name, class: ChatName do factory :chat_name, class: ChatName do
user factory: :user user factory: :user
service factory: :service service factory: :service
......
FactoryGirl.define do FactoryBot.define do
factory :chat_team, class: ChatTeam do factory :chat_team, class: ChatTeam do
sequence(:team_id) { |n| "abcdefghijklm#{n}" } sequence(:team_id) { |n| "abcdefghijklm#{n}" }
namespace factory: :group namespace factory: :group
......
FactoryGirl.define do FactoryBot.define do
factory :ci_build_trace_section_name, class: Ci::BuildTraceSectionName do factory :ci_build_trace_section_name, class: Ci::BuildTraceSectionName do
sequence(:name) { |n| "section_#{n}" } sequence(:name) { |n| "section_#{n}" }
project factory: :project project factory: :project
......
include ActionDispatch::TestProcess include ActionDispatch::TestProcess
FactoryGirl.define do FactoryBot.define do
factory :ci_build, class: Ci::Build do factory :ci_build, class: Ci::Build do
name 'test' name 'test'
stage 'test' stage 'test'
......
FactoryGirl.define do FactoryBot.define do
factory :ci_group_variable, class: Ci::GroupVariable do factory :ci_group_variable, class: Ci::GroupVariable do
sequence(:key) { |n| "VARIABLE_#{n}" } sequence(:key) { |n| "VARIABLE_#{n}" }
value 'VARIABLE_VALUE' value 'VARIABLE_VALUE'
......
include ActionDispatch::TestProcess include ActionDispatch::TestProcess
FactoryGirl.define do FactoryBot.define do
factory :ci_job_artifact, class: Ci::JobArtifact do factory :ci_job_artifact, class: Ci::JobArtifact do
job factory: :ci_build job factory: :ci_build
file_type :archive file_type :archive
......
FactoryGirl.define do FactoryBot.define do
factory :ci_pipeline_schedule, class: Ci::PipelineSchedule do factory :ci_pipeline_schedule, class: Ci::PipelineSchedule do
cron '0 1 * * *' cron '0 1 * * *'
cron_timezone Gitlab::Ci::CronParser::VALID_SYNTAX_SAMPLE_TIME_ZONE cron_timezone Gitlab::Ci::CronParser::VALID_SYNTAX_SAMPLE_TIME_ZONE
......
FactoryGirl.define do FactoryBot.define do
factory :ci_pipeline_schedule_variable, class: Ci::PipelineScheduleVariable do factory :ci_pipeline_schedule_variable, class: Ci::PipelineScheduleVariable do
sequence(:key) { |n| "VARIABLE_#{n}" } sequence(:key) { |n| "VARIABLE_#{n}" }
value 'VARIABLE_VALUE' value 'VARIABLE_VALUE'
......
FactoryGirl.define do FactoryBot.define do
factory :ci_pipeline_variable, class: Ci::PipelineVariable do factory :ci_pipeline_variable, class: Ci::PipelineVariable do
sequence(:key) { |n| "VARIABLE_#{n}" } sequence(:key) { |n| "VARIABLE_#{n}" }
value 'VARIABLE_VALUE' value 'VARIABLE_VALUE'
......
FactoryGirl.define do FactoryBot.define do
factory :ci_empty_pipeline, class: Ci::Pipeline do factory :ci_empty_pipeline, class: Ci::Pipeline do
source :push source :push
ref 'master' ref 'master'
......
FactoryGirl.define do FactoryBot.define do
factory :ci_runner_project, class: Ci::RunnerProject do factory :ci_runner_project, class: Ci::RunnerProject do
runner factory: :ci_runner runner factory: :ci_runner
project project
......
FactoryGirl.define do FactoryBot.define do
factory :ci_runner, class: Ci::Runner do factory :ci_runner, class: Ci::Runner do
sequence(:description) { |n| "My runner#{n}" } sequence(:description) { |n| "My runner#{n}" }
......
FactoryGirl.define do FactoryBot.define do
factory :ci_sources_pipeline, class: Ci::Sources::Pipeline do factory :ci_sources_pipeline, class: Ci::Sources::Pipeline do
after(:build) do |source| after(:build) do |source|
source.project ||= source.pipeline.project source.project ||= source.pipeline.project
......
FactoryGirl.define do FactoryBot.define do
factory :ci_stage, class: Ci::LegacyStage do factory :ci_stage, class: Ci::LegacyStage do
skip_create skip_create
......
FactoryGirl.define do FactoryBot.define do
factory :ci_trigger_request, class: Ci::TriggerRequest do factory :ci_trigger_request, class: Ci::TriggerRequest do
trigger factory: :ci_trigger trigger factory: :ci_trigger
end end
......
FactoryGirl.define do FactoryBot.define do
factory :ci_trigger_without_token, class: Ci::Trigger do factory :ci_trigger_without_token, class: Ci::Trigger do
owner owner
......
FactoryGirl.define do FactoryBot.define do
factory :ci_variable, class: Ci::Variable do factory :ci_variable, class: Ci::Variable do
sequence(:key) { |n| "VARIABLE_#{n}" } sequence(:key) { |n| "VARIABLE_#{n}" }
value 'VARIABLE_VALUE' value 'VARIABLE_VALUE'
......
FactoryGirl.define do FactoryBot.define do
factory :cluster_applications_helm, class: Clusters::Applications::Helm do factory :cluster_applications_helm, class: Clusters::Applications::Helm do
cluster factory: %i(cluster provided_by_gcp) cluster factory: %i(cluster provided_by_gcp)
......
FactoryGirl.define do FactoryBot.define do
factory :cluster_applications_ingress, class: Clusters::Applications::Ingress do factory :cluster_applications_ingress, class: Clusters::Applications::Ingress do
cluster factory: %i(cluster provided_by_gcp) cluster factory: %i(cluster provided_by_gcp)
......
FactoryGirl.define do FactoryBot.define do
factory :cluster, class: Clusters::Cluster do factory :cluster, class: Clusters::Cluster do
user user
name 'test-cluster' name 'test-cluster'
......
FactoryGirl.define do FactoryBot.define do
factory :cluster_platform_kubernetes, class: Clusters::Platforms::Kubernetes do factory :cluster_platform_kubernetes, class: Clusters::Platforms::Kubernetes do
cluster cluster
namespace nil namespace nil
......
FactoryGirl.define do FactoryBot.define do
factory :cluster_provider_gcp, class: Clusters::Providers::Gcp do factory :cluster_provider_gcp, class: Clusters::Providers::Gcp do
cluster cluster
gcp_project_id 'test-gcp-project' gcp_project_id 'test-gcp-project'
......
FactoryGirl.define do FactoryBot.define do
factory :commit_status, class: CommitStatus do factory :commit_status, class: CommitStatus do
name 'default' name 'default'
stage 'test' stage 'test'
......
require_relative '../support/repo_helpers' require_relative '../support/repo_helpers'
FactoryGirl.define do FactoryBot.define do
factory :commit do factory :commit do
git_commit RepoHelpers.sample_commit git_commit RepoHelpers.sample_commit
project project
......
FactoryGirl.define do FactoryBot.define do
factory :container_repository do factory :container_repository do
name 'test_container_image' name 'test_container_image'
project project
......
FactoryGirl.define do FactoryBot.define do
factory :conversational_development_index_metric, class: ConversationalDevelopmentIndex::Metric do factory :conversational_development_index_metric, class: ConversationalDevelopmentIndex::Metric do
leader_issues 9.256 leader_issues 9.256
instance_issues 1.234 instance_issues 1.234
......
FactoryGirl.define do FactoryBot.define do
factory :deploy_keys_project do factory :deploy_keys_project do
deploy_key deploy_key
project project
......
FactoryGirl.define do FactoryBot.define do
factory :deployment, class: Deployment do factory :deployment, class: Deployment do
sha '97de212e80737a608d939f648d959671fb0a0142' sha '97de212e80737a608d939f648d959671fb0a0142'
ref 'master' ref 'master'
......
FactoryGirl.define do FactoryBot.define do
factory :doorkeeper_access_grant, class: Doorkeeper::AccessGrant do factory :doorkeeper_access_grant, class: Doorkeeper::AccessGrant do
sequence(:resource_owner_id) { |n| n } sequence(:resource_owner_id) { |n| n }
association :application, factory: :doorkeeper_application association :application, factory: :doorkeeper_application
......
FactoryGirl.define do FactoryBot.define do
factory :email do factory :email do
user user
email { generate(:email_alias) } email { generate(:email_alias) }
......
FactoryGirl.define do FactoryBot.define do
factory :environment, class: Environment do factory :environment, class: Environment do
sequence(:name) { |n| "environment#{n}" } sequence(:name) { |n| "environment#{n}" }
......
FactoryGirl.define do FactoryBot.define do
factory :epic_issue do factory :epic_issue do
epic epic
issue issue
......
FactoryGirl.define do FactoryBot.define do
factory :epic do factory :epic do
title { generate(:title) } title { generate(:title) }
group group
......
FactoryGirl.define do FactoryBot.define do
factory :event do factory :event do
project project
author factory: :user author factory: :user
......
FactoryGirl.define do FactoryBot.define do
factory :file_uploader do factory :file_uploader do
skip_create skip_create
......
FactoryGirl.define do FactoryBot.define do
factory :fork_network_member do factory :fork_network_member do
association :project association :project
association :fork_network association :fork_network
......
FactoryGirl.define do FactoryBot.define do
factory :fork_network do factory :fork_network do
association :root_project, factory: :project association :root_project, factory: :project
end end
......
FactoryGirl.define do FactoryBot.define do
factory :forked_project_link do factory :forked_project_link do
association :forked_to_project, factory: [:project, :repository] association :forked_to_project, factory: [:project, :repository]
association :forked_from_project, factory: [:project, :repository] association :forked_from_project, factory: [:project, :repository]
......
FactoryGirl.define do FactoryBot.define do
factory :geo_event_log, class: Geo::EventLog do factory :geo_event_log, class: Geo::EventLog do
trait :created_event do trait :created_event do
repository_created_event factory: :geo_repository_created_event repository_created_event factory: :geo_repository_created_event
......
FactoryGirl.define do FactoryBot.define do
factory :geo_event_log_state, class: Geo::EventLogState do factory :geo_event_log_state, class: Geo::EventLogState do
sequence(:event_id) sequence(:event_id)
end end
......
FactoryGirl.define do FactoryBot.define do
factory :geo_file_registry, class: Geo::FileRegistry do factory :geo_file_registry, class: Geo::FileRegistry do
sequence(:file_id) sequence(:file_id)
file_type :file file_type :file
......
FactoryGirl.define do FactoryBot.define do
factory :geo_project_registry, class: Geo::ProjectRegistry do factory :geo_project_registry, class: Geo::ProjectRegistry do
project project
last_repository_synced_at nil last_repository_synced_at nil
......
FactoryGirl.define do FactoryBot.define do
factory :geo_node_namespace_link do factory :geo_node_namespace_link do
geo_node geo_node
namespace namespace
......
FactoryGirl.define do FactoryBot.define do
factory :geo_node_status do factory :geo_node_status do
sequence(:id) sequence(:id)
geo_node geo_node
......
FactoryGirl.define do FactoryBot.define do
factory :geo_node do factory :geo_node do
# Start at a number higher than the current port to avoid the GeoNode # Start at a number higher than the current port to avoid the GeoNode
# "lock out" validation # "lock out" validation
......
FactoryGirl.define do FactoryBot.define do
sequence(:gitaly_commit_id) { Digest::SHA1.hexdigest(Time.now.to_f.to_s) } sequence(:gitaly_commit_id) { Digest::SHA1.hexdigest(Time.now.to_f.to_s) }
factory :gitaly_commit, class: Gitaly::GitCommit do factory :gitaly_commit, class: Gitaly::GitCommit do
......
FactoryGirl.define do FactoryBot.define do
factory :gitaly_commit_author, class: Gitaly::CommitAuthor do factory :gitaly_commit_author, class: Gitaly::CommitAuthor do
skip_create skip_create
......
require_relative '../support/gpg_helpers' require_relative '../support/gpg_helpers'
FactoryGirl.define do FactoryBot.define do
factory :gpg_key_subkey do factory :gpg_key_subkey do
gpg_key gpg_key
......
require_relative '../support/gpg_helpers' require_relative '../support/gpg_helpers'
FactoryGirl.define do FactoryBot.define do
factory :gpg_key do factory :gpg_key do
key GpgHelpers::User1.public_key key GpgHelpers::User1.public_key
user user
......
require_relative '../support/gpg_helpers' require_relative '../support/gpg_helpers'
FactoryGirl.define do FactoryBot.define do
factory :gpg_signature do factory :gpg_signature do
commit_sha { Digest::SHA1.hexdigest(SecureRandom.hex) } commit_sha { Digest::SHA1.hexdigest(SecureRandom.hex) }
project project
......
FactoryGirl.define do FactoryBot.define do
factory :group_custom_attribute do factory :group_custom_attribute do
group group
sequence(:key) { |n| "key#{n}" } sequence(:key) { |n| "key#{n}" }
......
FactoryGirl.define do FactoryBot.define do
factory :group_hook do factory :group_hook do
url { generate(:url) } url { generate(:url) }
end end
......
FactoryGirl.define do FactoryBot.define do
factory :group_member do factory :group_member do
access_level { GroupMember::OWNER } access_level { GroupMember::OWNER }
group group
......
FactoryGirl.define do FactoryBot.define do
factory :group, class: Group, parent: :namespace do factory :group, class: Group, parent: :namespace do
sequence(:name) { |n| "group#{n}" } sequence(:name) { |n| "group#{n}" }
path { name.downcase.gsub(/\s/, '_') } path { name.downcase.gsub(/\s/, '_') }
......
FactoryGirl.define do FactoryBot.define do
factory :identity do factory :identity do
provider 'ldapmain' provider 'ldapmain'
extern_uid 'my-ldap-id' extern_uid 'my-ldap-id'
......
FactoryGirl.define do FactoryBot.define do
factory :instance_configuration do factory :instance_configuration do
skip_create skip_create
end end
......
FactoryGirl.define do FactoryBot.define do
factory :issue_link do factory :issue_link do
source factory: :issue source factory: :issue
target factory: :issue target factory: :issue
......
FactoryGirl.define do FactoryBot.define do
factory :issue do factory :issue do
title { generate(:title) } title { generate(:title) }
author author
......
require_relative '../support/helpers/key_generator_helper' require_relative '../support/helpers/key_generator_helper'
FactoryGirl.define do FactoryBot.define do
factory :key do factory :key do
title title
key { Spec::Support::Helpers::KeyGeneratorHelper.new(1024).generate + ' dummy@gitlab.com' } key { Spec::Support::Helpers::KeyGeneratorHelper.new(1024).generate + ' dummy@gitlab.com' }
......
FactoryGirl.define do FactoryBot.define do
factory :label_link do factory :label_link do
label label
target factory: :issue target factory: :issue
......
FactoryGirl.define do FactoryBot.define do
factory :label_priority do factory :label_priority do
project project
label label
......
FactoryGirl.define do FactoryBot.define do
trait :base_label do trait :base_label do
title { generate(:label_title) } title { generate(:label_title) }
color "#990000" color "#990000"
......
FactoryGirl.define do FactoryBot.define do
factory :ldap_group_link do factory :ldap_group_link do
cn 'group1' cn 'group1'
group_access Gitlab::Access::GUEST group_access Gitlab::Access::GUEST
......
include ActionDispatch::TestProcess include ActionDispatch::TestProcess
FactoryGirl.define do FactoryBot.define do
factory :lfs_object do factory :lfs_object do
sequence(:oid) { |n| "b68143e6463773b1b6c6fd009a76c32aeec041faff32ba2ed42fd7f708a%05x" % n } sequence(:oid) { |n| "b68143e6463773b1b6c6fd009a76c32aeec041faff32ba2ed42fd7f708a%05x" % n }
size 499013 size 499013
......
FactoryGirl.define do FactoryBot.define do
factory :lfs_objects_project do factory :lfs_objects_project do
lfs_object lfs_object
project project
......
FactoryGirl.define do FactoryBot.define do
factory :gitlab_license, class: "Gitlab::License" do factory :gitlab_license, class: "Gitlab::License" do
skip_create skip_create
......
FactoryGirl.define do FactoryBot.define do
factory :list do factory :list do
board board
label label
......
FactoryGirl.define do FactoryBot.define do
factory :merge_request do factory :merge_request do
title { generate(:title) } title { generate(:title) }
author author
......
FactoryGirl.define do FactoryBot.define do
factory :merge_requests_closing_issues do factory :merge_requests_closing_issues do
issue issue
merge_request merge_request
......
FactoryGirl.define do FactoryBot.define do
factory :milestone do factory :milestone do
title title
......
FactoryGirl.define do FactoryBot.define do
factory :namespace_statistics do factory :namespace_statistics do
namespace factory: :namespace namespace factory: :namespace
end end
......
FactoryGirl.define do FactoryBot.define do
factory :namespace do factory :namespace do
sequence(:name) { |n| "namespace#{n}" } sequence(:name) { |n| "namespace#{n}" }
path { name.downcase.gsub(/\s/, '_') } path { name.downcase.gsub(/\s/, '_') }
......
...@@ -2,7 +2,7 @@ require_relative '../support/repo_helpers' ...@@ -2,7 +2,7 @@ require_relative '../support/repo_helpers'
include ActionDispatch::TestProcess include ActionDispatch::TestProcess
FactoryGirl.define do FactoryBot.define do
factory :note do factory :note do
project project
note { generate(:title) } note { generate(:title) }
......
FactoryGirl.define do FactoryBot.define do
factory :notification_setting do factory :notification_setting do
source factory: :project source factory: :project
user user
......
FactoryGirl.define do FactoryBot.define do
factory :oauth_access_grant do factory :oauth_access_grant do
resource_owner_id { create(:user).id } resource_owner_id { create(:user).id }
application application
......
FactoryGirl.define do FactoryBot.define do
factory :oauth_access_token do factory :oauth_access_token do
resource_owner resource_owner
application application
......
FactoryGirl.define do FactoryBot.define do
factory :oauth_application, class: 'Doorkeeper::Application', aliases: [:application] do factory :oauth_application, class: 'Doorkeeper::Application', aliases: [:application] do
sequence(:name) { |n| "OAuth App #{n}" } sequence(:name) { |n| "OAuth App #{n}" }
uid { Doorkeeper::OAuth::Helpers::UniqueToken.generate } uid { Doorkeeper::OAuth::Helpers::UniqueToken.generate }
......
FactoryGirl.define do FactoryBot.define do
factory :pages_domain, class: 'PagesDomain' do factory :pages_domain, class: 'PagesDomain' do
domain 'my.domain.com' domain 'my.domain.com'
......
FactoryGirl.define do FactoryBot.define do
factory :path_lock do factory :path_lock do
project project
user user
......
FactoryGirl.define do FactoryBot.define do
factory :personal_access_token do factory :personal_access_token do
user user
token { SecureRandom.hex(50) } token { SecureRandom.hex(50) }
......
# EE-only # EE-only
FactoryGirl.define do FactoryBot.define do
factory :plan do factory :plan do
factory :free_plan do factory :free_plan do
name EE::Namespace::FREE_PLAN name EE::Namespace::FREE_PLAN
......
FactoryGirl.define do FactoryBot.define do
factory :project_auto_devops do factory :project_auto_devops do
project project
enabled true enabled true
......
FactoryGirl.define do FactoryBot.define do
factory :project_custom_attribute do factory :project_custom_attribute do
project project
sequence(:key) { |n| "key#{n}" } sequence(:key) { |n| "key#{n}" }
......
FactoryGirl.define do FactoryBot.define do
factory :project_group_link do factory :project_group_link do
project project
group group
......
FactoryGirl.define do FactoryBot.define do
factory :project_hook do factory :project_hook do
url { generate(:url) } url { generate(:url) }
enable_ssl_verification false enable_ssl_verification false
......
FactoryGirl.define do FactoryBot.define do
factory :project_member do factory :project_member do
user user
project project
......
FactoryGirl.define do FactoryBot.define do
factory :project_statistics do factory :project_statistics do
project project
......
FactoryGirl.define do FactoryBot.define do
factory :project_wiki do factory :project_wiki do
skip_create skip_create
......
require_relative '../support/test_env' require_relative '../support/test_env'
FactoryGirl.define do FactoryBot.define do
# Project without repository # Project without repository
# #
# Project does not have bare repository. # Project does not have bare repository.
......
FactoryGirl.define do FactoryBot.define do
factory :protected_branch do factory :protected_branch do
name name
project project
......
FactoryGirl.define do FactoryBot.define do
factory :protected_branch_merge_access_level, class: ProtectedBranch::MergeAccessLevel do factory :protected_branch_merge_access_level, class: ProtectedBranch::MergeAccessLevel do
user nil user nil
group nil group nil
......
FactoryGirl.define do FactoryBot.define do
factory :protected_branch_push_access_level, class: ProtectedBranch::PushAccessLevel do factory :protected_branch_push_access_level, class: ProtectedBranch::PushAccessLevel do
user nil user nil
group nil group nil
......
FactoryGirl.define do FactoryBot.define do
factory :protected_tag do factory :protected_tag do
name name
project project
......
FactoryGirl.define do FactoryBot.define do
factory :protected_tag_create_access_level, class: ProtectedTag::CreateAccessLevel do factory :protected_tag_create_access_level, class: ProtectedTag::CreateAccessLevel do
user nil user nil
group nil group nil
......
# Read about factories at https://github.com/thoughtbot/factory_girl # Read about factories at https://github.com/thoughtbot/factory_bot
FactoryGirl.define do FactoryBot.define do
factory :push_rule do factory :push_rule do
force_push_regex 'feature\/.*' force_push_regex 'feature\/.*'
deny_delete_tag false deny_delete_tag false
......
FactoryGirl.define do FactoryBot.define do
factory :release do factory :release do
tag "v1.1.0" tag "v1.1.0"
description "Awesome release" description "Awesome release"
......
require_relative '../support/test_env' require_relative '../support/test_env'
FactoryGirl.define do FactoryBot.define do
factory :remote_mirror, class: 'RemoteMirror' do factory :remote_mirror, class: 'RemoteMirror' do
association :project, :repository association :project, :repository
url "http://foo:bar@test.com" url "http://foo:bar@test.com"
......
FactoryGirl.define do FactoryBot.define do
factory :sent_notification do factory :sent_notification do
project project
recipient factory: :user recipient factory: :user
......
FactoryGirl.define do FactoryBot.define do
sequence(:username) { |n| "user#{n}" } sequence(:username) { |n| "user#{n}" }
sequence(:name) { |n| "John Doe#{n}" } sequence(:name) { |n| "John Doe#{n}" }
sequence(:email) { |n| "user#{n}@example.org" } sequence(:email) { |n| "user#{n}@example.org" }
......
FactoryGirl.define do FactoryBot.define do
factory :service_hook do factory :service_hook do
url { generate(:url) } url { generate(:url) }
service service
......
FactoryGirl.define do FactoryBot.define do
factory :service do factory :service do
project project
type 'Service' type 'Service'
......
FactoryGirl.define do FactoryBot.define do
factory :slack_integration do factory :slack_integration do
sequence(:team_id) { |n| "T123#{n}" } sequence(:team_id) { |n| "T123#{n}" }
sequence(:user_id) { |n| "U123#{n}" } sequence(:user_id) { |n| "U123#{n}" }
......
FactoryGirl.define do FactoryBot.define do
factory :snippet do factory :snippet do
author author
title { generate(:title) } title { generate(:title) }
......
FactoryGirl.define do FactoryBot.define do
factory :spam_log do factory :spam_log do
user user
sequence(:source_ip) { |n| "42.42.42.#{n % 255}" } sequence(:source_ip) { |n| "42.42.42.#{n % 255}" }
......
FactoryGirl.define do FactoryBot.define do
factory :subscription do factory :subscription do
user user
project project
......
FactoryGirl.define do FactoryBot.define do
factory :system_hook do factory :system_hook do
url { generate(:url) } url { generate(:url) }
end end
......
FactoryGirl.define do FactoryBot.define do
factory :system_note_metadata do factory :system_note_metadata do
note note
action 'merge' action 'merge'
......
# Read about factories at https://github.com/thoughtbot/factory_girl # Read about factories at https://github.com/thoughtbot/factory_bot
FactoryGirl.define do FactoryBot.define do
factory :timelog do factory :timelog do
time_spent 3600 time_spent 3600
user user
......
FactoryGirl.define do FactoryBot.define do
factory :todo do factory :todo do
project project
author author
......
FactoryGirl.define do FactoryBot.define do
# TrendingProject # TrendingProject
factory :trending_project, class: 'TrendingProject' do factory :trending_project, class: 'TrendingProject' do
project project
......
FactoryGirl.define do FactoryBot.define do
factory :u2f_registration do factory :u2f_registration do
certificate { FFaker::BaconIpsum.characters(728) } certificate { FFaker::BaconIpsum.characters(728) }
key_handle { FFaker::BaconIpsum.characters(86) } key_handle { FFaker::BaconIpsum.characters(86) }
......
FactoryGirl.define do FactoryBot.define do
factory :upload do factory :upload do
model { build(:project) } model { build(:project) }
path { "uploads/-/system/project/avatar/avatar.jpg" } path { "uploads/-/system/project/avatar/avatar.jpg" }
......
FactoryGirl.define do FactoryBot.define do
factory :user_agent_detail do factory :user_agent_detail do
ip_address '127.0.0.1' ip_address '127.0.0.1'
user_agent 'AppleWebKit/537.36' user_agent 'AppleWebKit/537.36'
......
FactoryGirl.define do FactoryBot.define do
factory :user_custom_attribute do factory :user_custom_attribute do
user user
sequence(:key) { |n| "key#{n}" } sequence(:key) { |n| "key#{n}" }
......
FactoryGirl.define do FactoryBot.define do
factory :user, aliases: [:author, :assignee, :recipient, :owner, :resource_owner] do factory :user, aliases: [:author, :assignee, :recipient, :owner, :resource_owner] do
email { generate(:email) } email { generate(:email) }
name { generate(:name) } name { generate(:name) }
......
FactoryGirl.define do FactoryBot.define do
factory :web_hook_log do factory :web_hook_log do
web_hook factory: :project_hook web_hook factory: :project_hook
trigger 'push_hooks' trigger 'push_hooks'
......
FactoryGirl.define do FactoryBot.define do
factory :wiki_directory do factory :wiki_directory do
skip_create skip_create
......
require 'ostruct' require 'ostruct'
FactoryGirl.define do FactoryBot.define do
factory :wiki_page do factory :wiki_page do
transient do transient do
attrs do attrs do
......
require 'spec_helper' require 'spec_helper'
describe 'factories' do describe 'factories' do
FactoryGirl.factories.each do |factory| FactoryBot.factories.each do |factory|
describe "#{factory.name} factory" do describe "#{factory.name} factory" do
it 'does not raise error when built' do it 'does not raise error when built' do
expect { build(factory.name) }.not_to raise_error expect { build(factory.name) }.not_to raise_error
......
...@@ -13,8 +13,8 @@ describe "Admin Runners" do ...@@ -13,8 +13,8 @@ describe "Admin Runners" do
context "when there are runners" do context "when there are runners" do
before do before do
runner = FactoryGirl.create(:ci_runner, contacted_at: Time.now) runner = FactoryBot.create(:ci_runner, contacted_at: Time.now)
FactoryGirl.create(:ci_build, pipeline: pipeline, runner_id: runner.id) FactoryBot.create(:ci_build, pipeline: pipeline, runner_id: runner.id)
visit admin_runners_path visit admin_runners_path
end end
...@@ -25,8 +25,8 @@ describe "Admin Runners" do ...@@ -25,8 +25,8 @@ describe "Admin Runners" do
describe 'search' do describe 'search' do
before do before do
FactoryGirl.create :ci_runner, description: 'runner-foo' FactoryBot.create :ci_runner, description: 'runner-foo'
FactoryGirl.create :ci_runner, description: 'runner-bar' FactoryBot.create :ci_runner, description: 'runner-bar'
end end
it 'shows correct runner when description matches' do it 'shows correct runner when description matches' do
...@@ -62,11 +62,11 @@ describe "Admin Runners" do ...@@ -62,11 +62,11 @@ describe "Admin Runners" do
end end
describe "Runner show page" do describe "Runner show page" do
let(:runner) { FactoryGirl.create :ci_runner } let(:runner) { FactoryBot.create :ci_runner }
before do before do
@project1 = FactoryGirl.create(:project) @project1 = FactoryBot.create(:project)
@project2 = FactoryGirl.create(:project) @project2 = FactoryBot.create(:project)
visit admin_runner_path(runner) visit admin_runner_path(runner)
end end
......
...@@ -2,17 +2,17 @@ require 'spec_helper' ...@@ -2,17 +2,17 @@ require 'spec_helper'
describe RunnersHelper do describe RunnersHelper do
it "returns - not contacted yet" do it "returns - not contacted yet" do
runner = FactoryGirl.build :ci_runner runner = FactoryBot.build :ci_runner
expect(runner_status_icon(runner)).to include("not connected yet") expect(runner_status_icon(runner)).to include("not connected yet")
end end
it "returns offline text" do it "returns offline text" do
runner = FactoryGirl.build(:ci_runner, contacted_at: 1.day.ago, active: true) runner = FactoryBot.build(:ci_runner, contacted_at: 1.day.ago, active: true)
expect(runner_status_icon(runner)).to include("Runner is offline") expect(runner_status_icon(runner)).to include("Runner is offline")
end end
it "returns online text" do it "returns online text" do
runner = FactoryGirl.build(:ci_runner, contacted_at: 1.second.ago, active: true) runner = FactoryBot.build(:ci_runner, contacted_at: 1.second.ago, active: true)
expect(runner_status_icon(runner)).to include("Runner is online") expect(runner_status_icon(runner)).to include("Runner is online")
end end
end end
...@@ -228,7 +228,7 @@ describe Gitlab::BackgroundMigration::MigrateEventsToPushEventPayloads, :migrati ...@@ -228,7 +228,7 @@ describe Gitlab::BackgroundMigration::MigrateEventsToPushEventPayloads, :migrati
let(:projects) { table(:projects) } let(:projects) { table(:projects) }
let(:project) { projects.create(namespace_id: namespace.id, creator_id: author.id) } let(:project) { projects.create(namespace_id: namespace.id, creator_id: author.id) }
# We can not rely on FactoryGirl as the state of Event may change in ways that # We can not rely on FactoryBot as the state of Event may change in ways that
# the background migration does not expect, hence we use the Event class of # the background migration does not expect, hence we use the Event class of
# the migration itself. # the migration itself.
def create_push_event(project, author, data = nil) def create_push_event(project, author, data = nil)
......
...@@ -120,7 +120,7 @@ describe Ci::Pipeline, :mailer do ...@@ -120,7 +120,7 @@ describe Ci::Pipeline, :mailer do
end end
it "calculates average when there is one build without coverage" do it "calculates average when there is one build without coverage" do
FactoryGirl.create(:ci_build, pipeline: pipeline) FactoryBot.create(:ci_build, pipeline: pipeline)
expect(pipeline.coverage).to be_nil expect(pipeline.coverage).to be_nil
end end
end end
...@@ -439,7 +439,7 @@ describe Ci::Pipeline, :mailer do ...@@ -439,7 +439,7 @@ describe Ci::Pipeline, :mailer do
describe 'merge request metrics' do describe 'merge request metrics' do
let(:project) { create(:project, :repository) } let(:project) { create(:project, :repository) }
let(:pipeline) { FactoryGirl.create(:ci_empty_pipeline, status: 'created', project: project, ref: 'master', sha: project.repository.commit('master').id) } let(:pipeline) { FactoryBot.create(:ci_empty_pipeline, status: 'created', project: project, ref: 'master', sha: project.repository.commit('master').id) }
let!(:merge_request) { create(:merge_request, source_project: project, source_branch: pipeline.ref) } let!(:merge_request) { create(:merge_request, source_project: project, source_branch: pipeline.ref) }
before do before do
......
...@@ -51,24 +51,24 @@ describe Ci::Runner do ...@@ -51,24 +51,24 @@ describe Ci::Runner do
describe '#display_name' do describe '#display_name' do
it 'returns the description if it has a value' do it 'returns the description if it has a value' do
runner = FactoryGirl.build(:ci_runner, description: 'Linux/Ruby-1.9.3-p448') runner = FactoryBot.build(:ci_runner, description: 'Linux/Ruby-1.9.3-p448')
expect(runner.display_name).to eq 'Linux/Ruby-1.9.3-p448' expect(runner.display_name).to eq 'Linux/Ruby-1.9.3-p448'
end end
it 'returns the token if it does not have a description' do it 'returns the token if it does not have a description' do
runner = FactoryGirl.create(:ci_runner) runner = FactoryBot.create(:ci_runner)
expect(runner.display_name).to eq runner.description expect(runner.display_name).to eq runner.description
end end
it 'returns the token if the description is an empty string' do it 'returns the token if the description is an empty string' do
runner = FactoryGirl.build(:ci_runner, description: '', token: 'token') runner = FactoryBot.build(:ci_runner, description: '', token: 'token')
expect(runner.display_name).to eq runner.token expect(runner.display_name).to eq runner.token
end end
end end
describe '#assign_to' do describe '#assign_to' do
let!(:project) { FactoryGirl.create :project } let!(:project) { FactoryBot.create :project }
let!(:shared_runner) { FactoryGirl.create(:ci_runner, :shared) } let!(:shared_runner) { FactoryBot.create(:ci_runner, :shared) }
before do before do
shared_runner.assign_to(project) shared_runner.assign_to(project)
...@@ -83,15 +83,15 @@ describe Ci::Runner do ...@@ -83,15 +83,15 @@ describe Ci::Runner do
subject { described_class.online } subject { described_class.online }
before do before do
@runner1 = FactoryGirl.create(:ci_runner, :shared, contacted_at: 1.year.ago) @runner1 = FactoryBot.create(:ci_runner, :shared, contacted_at: 1.year.ago)
@runner2 = FactoryGirl.create(:ci_runner, :shared, contacted_at: 1.second.ago) @runner2 = FactoryBot.create(:ci_runner, :shared, contacted_at: 1.second.ago)
end end
it { is_expected.to eq([@runner2])} it { is_expected.to eq([@runner2])}
end end
describe '#online?' do describe '#online?' do
let(:runner) { FactoryGirl.create(:ci_runner, :shared) } let(:runner) { FactoryBot.create(:ci_runner, :shared) }
subject { runner.online? } subject { runner.online? }
...@@ -268,7 +268,7 @@ describe Ci::Runner do ...@@ -268,7 +268,7 @@ describe Ci::Runner do
end end
describe '#status' do describe '#status' do
let(:runner) { FactoryGirl.create(:ci_runner, :shared, contacted_at: 1.second.ago) } let(:runner) { FactoryBot.create(:ci_runner, :shared, contacted_at: 1.second.ago) }
subject { runner.status } subject { runner.status }
...@@ -442,9 +442,9 @@ describe Ci::Runner do ...@@ -442,9 +442,9 @@ describe Ci::Runner do
describe "belongs_to_one_project?" do describe "belongs_to_one_project?" do
it "returns false if there are two projects runner assigned to" do it "returns false if there are two projects runner assigned to" do
runner = FactoryGirl.create(:ci_runner) runner = FactoryBot.create(:ci_runner)
project = FactoryGirl.create(:project) project = FactoryBot.create(:project)
project1 = FactoryGirl.create(:project) project1 = FactoryBot.create(:project)
project.runners << runner project.runners << runner
project1.runners << runner project1.runners << runner
...@@ -452,8 +452,8 @@ describe Ci::Runner do ...@@ -452,8 +452,8 @@ describe Ci::Runner do
end end
it "returns true" do it "returns true" do
runner = FactoryGirl.create(:ci_runner) runner = FactoryBot.create(:ci_runner)
project = FactoryGirl.create(:project) project = FactoryBot.create(:project)
project.runners << runner project.runners << runner
expect(runner.belongs_to_one_project?).to be_truthy expect(runner.belongs_to_one_project?).to be_truthy
......
...@@ -126,7 +126,7 @@ describe Deployment do ...@@ -126,7 +126,7 @@ describe Deployment do
subject { deployment.stop_action } subject { deployment.stop_action }
context 'when no other actions' do context 'when no other actions' do
let(:deployment) { FactoryGirl.build(:deployment, deployable: build) } let(:deployment) { FactoryBot.build(:deployment, deployable: build) }
it { is_expected.to be_nil } it { is_expected.to be_nil }
end end
...@@ -135,13 +135,13 @@ describe Deployment do ...@@ -135,13 +135,13 @@ describe Deployment do
let!(:close_action) { create(:ci_build, :manual, pipeline: build.pipeline, name: 'close_app') } let!(:close_action) { create(:ci_build, :manual, pipeline: build.pipeline, name: 'close_app') }
context 'when matching action is defined' do context 'when matching action is defined' do
let(:deployment) { FactoryGirl.build(:deployment, deployable: build, on_stop: 'close_other_app') } let(:deployment) { FactoryBot.build(:deployment, deployable: build, on_stop: 'close_other_app') }
it { is_expected.to be_nil } it { is_expected.to be_nil }
end end
context 'when no matching action is defined' do context 'when no matching action is defined' do
let(:deployment) { FactoryGirl.build(:deployment, deployable: build, on_stop: 'close_app') } let(:deployment) { FactoryBot.build(:deployment, deployable: build, on_stop: 'close_app') }
it { is_expected.to eq(close_action) } it { is_expected.to eq(close_action) }
end end
...@@ -159,7 +159,7 @@ describe Deployment do ...@@ -159,7 +159,7 @@ describe Deployment do
context 'when matching action is defined' do context 'when matching action is defined' do
let(:build) { create(:ci_build) } let(:build) { create(:ci_build) }
let(:deployment) { FactoryGirl.build(:deployment, deployable: build, on_stop: 'close_app') } let(:deployment) { FactoryBot.build(:deployment, deployable: build, on_stop: 'close_app') }
let!(:close_action) { create(:ci_build, :manual, pipeline: build.pipeline, name: 'close_app') } let!(:close_action) { create(:ci_build, :manual, pipeline: build.pipeline, name: 'close_app') }
it { is_expected.to be_truthy } it { is_expected.to be_truthy }
......
...@@ -327,12 +327,12 @@ describe Project do ...@@ -327,12 +327,12 @@ describe Project do
describe 'project token' do describe 'project token' do
it 'sets an random token if none provided' do it 'sets an random token if none provided' do
project = FactoryGirl.create :project, runners_token: '' project = FactoryBot.create :project, runners_token: ''
expect(project.runners_token).not_to eq('') expect(project.runners_token).not_to eq('')
end end
it 'does not set an random token if one provided' do it 'does not set an random token if one provided' do
project = FactoryGirl.create :project, runners_token: 'my-token' project = FactoryBot.create :project, runners_token: 'my-token'
expect(project.runners_token).to eq('my-token') expect(project.runners_token).to eq('my-token')
end end
end end
......
...@@ -234,7 +234,7 @@ describe RemoteMirror do ...@@ -234,7 +234,7 @@ describe RemoteMirror do
end end
def create_mirror(params) def create_mirror(params)
project = FactoryGirl.create(:project, :repository) project = FactoryBot.create(:project, :repository)
project.remote_mirrors.create!(params) project.remote_mirrors.create!(params)
end end
end end
...@@ -2,11 +2,11 @@ require 'spec_helper' ...@@ -2,11 +2,11 @@ require 'spec_helper'
module Ci module Ci
describe RegisterJobService do describe RegisterJobService do
let!(:project) { FactoryGirl.create :project, shared_runners_enabled: false } let!(:project) { FactoryBot.create :project, shared_runners_enabled: false }
let!(:pipeline) { FactoryGirl.create :ci_pipeline, project: project } let!(:pipeline) { FactoryBot.create :ci_pipeline, project: project }
let!(:pending_job) { FactoryGirl.create :ci_build, pipeline: pipeline } let!(:pending_job) { FactoryBot.create :ci_build, pipeline: pipeline }
let!(:shared_runner) { FactoryGirl.create(:ci_runner, is_shared: true) } let!(:shared_runner) { FactoryBot.create(:ci_runner, is_shared: true) }
let!(:specific_runner) { FactoryGirl.create(:ci_runner, is_shared: false) } let!(:specific_runner) { FactoryBot.create(:ci_runner, is_shared: false) }
before do before do
specific_runner.assign_to(project) specific_runner.assign_to(project)
...@@ -74,11 +74,11 @@ module Ci ...@@ -74,11 +74,11 @@ module Ci
let!(:project3) { create :project, shared_runners_enabled: true } let!(:project3) { create :project, shared_runners_enabled: true }
let!(:pipeline3) { create :ci_pipeline, project: project3 } let!(:pipeline3) { create :ci_pipeline, project: project3 }
let!(:build1_project1) { pending_job } let!(:build1_project1) { pending_job }
let!(:build2_project1) { FactoryGirl.create :ci_build, pipeline: pipeline } let!(:build2_project1) { FactoryBot.create :ci_build, pipeline: pipeline }
let!(:build3_project1) { FactoryGirl.create :ci_build, pipeline: pipeline } let!(:build3_project1) { FactoryBot.create :ci_build, pipeline: pipeline }
let!(:build1_project2) { FactoryGirl.create :ci_build, pipeline: pipeline2 } let!(:build1_project2) { FactoryBot.create :ci_build, pipeline: pipeline2 }
let!(:build2_project2) { FactoryGirl.create :ci_build, pipeline: pipeline2 } let!(:build2_project2) { FactoryBot.create :ci_build, pipeline: pipeline2 }
let!(:build1_project3) { FactoryGirl.create :ci_build, pipeline: pipeline3 } let!(:build1_project3) { FactoryBot.create :ci_build, pipeline: pipeline3 }
it 'prefers projects without builds first' do it 'prefers projects without builds first' do
# it gets for one build from each of the projects # it gets for one build from each of the projects
......
...@@ -41,7 +41,7 @@ describe Ci::RetryBuildService do ...@@ -41,7 +41,7 @@ describe Ci::RetryBuildService do
description: 'my-job', stage: 'test', pipeline: pipeline, description: 'my-job', stage: 'test', pipeline: pipeline,
auto_canceled_by: create(:ci_empty_pipeline, project: project)) do |build| auto_canceled_by: create(:ci_empty_pipeline, project: project)) do |build|
## ##
# TODO, workaround for FactoryGirl limitation when having both # TODO, workaround for FactoryBot limitation when having both
# stage (text) and stage_id (integer) columns in the table. # stage (text) and stage_id (integer) columns in the table.
build.stage_id = stage.id build.stage_id = stage.id
end end
......
require 'spec_helper' require 'spec_helper'
describe Oauth2::LogoutTokenValidationService do describe Oauth2::LogoutTokenValidationService do
let(:user) { FactoryGirl.create(:user) } let(:user) { FactoryBot.create(:user) }
let(:access_token) { FactoryGirl.create(:doorkeeper_access_token, resource_owner_id: user.id).token } let(:access_token) { FactoryBot.create(:doorkeeper_access_token, resource_owner_id: user.id).token }
let(:logout_state) { Gitlab::Geo::OauthSession.new(access_token: access_token).generate_logout_state } let(:logout_state) { Gitlab::Geo::OauthSession.new(access_token: access_token).generate_logout_state }
context '#execute' do context '#execute' do
......
...@@ -199,7 +199,7 @@ RSpec::Matchers.define :match_asset_path do |expected| ...@@ -199,7 +199,7 @@ RSpec::Matchers.define :match_asset_path do |expected|
end end
end end
FactoryGirl::SyntaxRunner.class_eval do FactoryBot::SyntaxRunner.class_eval do
include RSpec::Mocks::ExampleMethods include RSpec::Mocks::ExampleMethods
end end
......
RSpec.configure do |config| RSpec.configure do |config|
config.include FactoryGirl::Syntax::Methods config.include FactoryBot::Syntax::Methods
end end
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
# The class renders `spec/fixtures/markdown.md.erb` using ERB, allowing for # The class renders `spec/fixtures/markdown.md.erb` using ERB, allowing for
# reference to the factory-created objects. # reference to the factory-created objects.
class MarkdownFeature class MarkdownFeature
include FactoryGirl::Syntax::Methods include FactoryBot::Syntax::Methods
def user def user
@user ||= create(:user) @user ||= create(:user)
......
...@@ -83,10 +83,10 @@ module TestEnv ...@@ -83,10 +83,10 @@ module TestEnv
setup_gitaly setup_gitaly
# Create repository for FactoryGirl.create(:project) # Create repository for FactoryBot.create(:project)
setup_factory_repo setup_factory_repo
# Create repository for FactoryGirl.create(:forked_project_with_submodules) # Create repository for FactoryBot.create(:forked_project_with_submodules)
setup_forked_repo setup_forked_repo
end end
......
...@@ -2,6 +2,6 @@ class TestLicense ...@@ -2,6 +2,6 @@ class TestLicense
def self.init def self.init
Gitlab::License.encryption_key = OpenSSL::PKey::RSA.generate(2048) Gitlab::License.encryption_key = OpenSSL::PKey::RSA.generate(2048)
FactoryGirl.create(:license) FactoryBot.create(:license)
end end
end end
...@@ -8,7 +8,7 @@ describe RecordsUploads do ...@@ -8,7 +8,7 @@ describe RecordsUploads do
storage :file storage :file
def model def model
FactoryGirl.build_stubbed(:user) FactoryBot.build_stubbed(:user)
end end
end end
......
...@@ -187,7 +187,7 @@ describe 'projects/jobs/show' do ...@@ -187,7 +187,7 @@ describe 'projects/jobs/show' do
context 'when incomplete trigger_request is used' do context 'when incomplete trigger_request is used' do
before do before do
build.trigger_request = FactoryGirl.build(:ci_trigger_request, trigger: nil) build.trigger_request = FactoryBot.build(:ci_trigger_request, trigger: nil)
end end
it 'test should not render token block' do it 'test should not render token block' do
...@@ -199,7 +199,7 @@ describe 'projects/jobs/show' do ...@@ -199,7 +199,7 @@ describe 'projects/jobs/show' do
context 'when complete trigger_request is used' do context 'when complete trigger_request is used' do
before do before do
build.trigger_request = FactoryGirl.build(:ci_trigger_request) build.trigger_request = FactoryBot.build(:ci_trigger_request)
end end
it 'should render token' do it 'should render token' do
......
...@@ -6,7 +6,7 @@ describe HistoricalDataWorker do ...@@ -6,7 +6,7 @@ describe HistoricalDataWorker do
describe '#perform' do describe '#perform' do
context 'with a trial license' do context 'with a trial license' do
before do before do
FactoryGirl.create(:license, trial: true) FactoryBot.create(:license, trial: true)
end end
it 'does not track historical data' do it 'does not track historical data' do
...@@ -18,7 +18,7 @@ describe HistoricalDataWorker do ...@@ -18,7 +18,7 @@ describe HistoricalDataWorker do
context 'with a non trial license' do context 'with a non trial license' do
before do before do
FactoryGirl.create(:license) FactoryBot.create(:license)
end end
it 'tracks historical data' do it 'tracks historical data' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment