summaryrefslogtreecommitdiff
path: root/spec/models
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2017-12-14 01:13:44 +0100
committerRémy Coutable <remy@rymai.me>2017-12-14 15:01:55 +0100
commit4af9d592c500d2d97ec091d10ba860488c3702ea (patch)
tree2b3ea135b3119d4d71a829c2b0a80c332fa7877a /spec/models
parentf51141878171c1162818f8fa0133125a5e92d3eb (diff)
downloadgitlab-ce-4af9d592c500d2d97ec091d10ba860488c3702ea.tar.gz
Replace factory_girl_rails with factory_bot_railsrc/use-factory_bot_rails
I've followed the [upgrade guide](https://github.com/thoughtbot/factory_bot/blob/4-9-0-stable/UPGRADE_FROM_FACTORY_GIRL.md) and ran these two commands: ``` grep -e FactoryGirl **/*.rake **/*.rb -s -l | xargs sed -i "" "s|FactoryGirl|FactoryBot|" grep -e factory_girl **/*.rake **/*.rb -s -l | xargs sed -i "" "s|factory_girl|factory_bot|" ``` Signed-off-by: Rémy Coutable <remy@rymai.me>
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/ci/pipeline_spec.rb4
-rw-r--r--spec/models/ci/runner_spec.rb28
-rw-r--r--spec/models/deployment_spec.rb8
-rw-r--r--spec/models/project_spec.rb4
4 files changed, 22 insertions, 22 deletions
diff --git a/spec/models/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb
index bb89e093890..856e17b20bd 100644
--- a/spec/models/ci/pipeline_spec.rb
+++ b/spec/models/ci/pipeline_spec.rb
@@ -116,7 +116,7 @@ describe Ci::Pipeline, :mailer do
end
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
end
end
@@ -435,7 +435,7 @@ describe Ci::Pipeline, :mailer do
describe 'merge request metrics' do
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) }
before do
diff --git a/spec/models/ci/runner_spec.rb b/spec/models/ci/runner_spec.rb
index a93e7e233a8..b2b64e6ff48 100644
--- a/spec/models/ci/runner_spec.rb
+++ b/spec/models/ci/runner_spec.rb
@@ -51,24 +51,24 @@ describe Ci::Runner do
describe '#display_name' 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'
end
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
end
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
end
end
describe '#assign_to' do
- let!(:project) { FactoryGirl.create :project }
- let!(:shared_runner) { FactoryGirl.create(:ci_runner, :shared) }
+ let!(:project) { FactoryBot.create :project }
+ let!(:shared_runner) { FactoryBot.create(:ci_runner, :shared) }
before do
shared_runner.assign_to(project)
@@ -83,15 +83,15 @@ describe Ci::Runner do
subject { described_class.online }
before do
- @runner1 = FactoryGirl.create(:ci_runner, :shared, contacted_at: 1.year.ago)
- @runner2 = FactoryGirl.create(:ci_runner, :shared, contacted_at: 1.second.ago)
+ @runner1 = FactoryBot.create(:ci_runner, :shared, contacted_at: 1.year.ago)
+ @runner2 = FactoryBot.create(:ci_runner, :shared, contacted_at: 1.second.ago)
end
it { is_expected.to eq([@runner2])}
end
describe '#online?' do
- let(:runner) { FactoryGirl.create(:ci_runner, :shared) }
+ let(:runner) { FactoryBot.create(:ci_runner, :shared) }
subject { runner.online? }
@@ -268,7 +268,7 @@ describe Ci::Runner do
end
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 }
@@ -442,9 +442,9 @@ describe Ci::Runner do
describe "belongs_to_one_project?" do
it "returns false if there are two projects runner assigned to" do
- runner = FactoryGirl.create(:ci_runner)
- project = FactoryGirl.create(:project)
- project1 = FactoryGirl.create(:project)
+ runner = FactoryBot.create(:ci_runner)
+ project = FactoryBot.create(:project)
+ project1 = FactoryBot.create(:project)
project.runners << runner
project1.runners << runner
@@ -452,8 +452,8 @@ describe Ci::Runner do
end
it "returns true" do
- runner = FactoryGirl.create(:ci_runner)
- project = FactoryGirl.create(:project)
+ runner = FactoryBot.create(:ci_runner)
+ project = FactoryBot.create(:project)
project.runners << runner
expect(runner.belongs_to_one_project?).to be_truthy
diff --git a/spec/models/deployment_spec.rb b/spec/models/deployment_spec.rb
index c5708e70ef9..ba8aa13d5ad 100644
--- a/spec/models/deployment_spec.rb
+++ b/spec/models/deployment_spec.rb
@@ -126,7 +126,7 @@ describe Deployment do
subject { deployment.stop_action }
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 }
end
@@ -135,13 +135,13 @@ describe Deployment do
let!(:close_action) { create(:ci_build, :manual, pipeline: build.pipeline, name: 'close_app') }
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 }
end
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) }
end
@@ -159,7 +159,7 @@ describe Deployment do
context 'when matching action is defined' do
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') }
it { is_expected.to be_truthy }
diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb
index dd9e8498519..f805f2dcddb 100644
--- a/spec/models/project_spec.rb
+++ b/spec/models/project_spec.rb
@@ -289,12 +289,12 @@ describe Project do
describe 'project token' 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('')
end
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')
end
end