Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-05-26 09:08:37 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-05-26 09:08:37 +0300
commit864dae0d98424b463501c21eda1b633c14956fa9 (patch)
tree9340f7dad0a32f7e8c8a3b5ad723fbf0de26c3ba /spec/factories
parent47ef8c6c530ee1cac0e1046b098755ec949da894 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/factories')
-rw-r--r--spec/factories/ci/builds.rb6
-rw-r--r--spec/factories/clusters/applications/helm.rb13
-rw-r--r--spec/factories/commits.rb9
-rw-r--r--spec/factories/container_repositories.rb9
-rw-r--r--spec/factories/deployments.rb2
-rw-r--r--spec/factories/merge_requests.rb2
-rw-r--r--spec/factories/projects.rb4
7 files changed, 23 insertions, 22 deletions
diff --git a/spec/factories/ci/builds.rb b/spec/factories/ci/builds.rb
index 56c12d73a3b..645c519aca2 100644
--- a/spec/factories/ci/builds.rb
+++ b/spec/factories/ci/builds.rb
@@ -494,13 +494,15 @@ FactoryBot.define do
trait :with_commit do
after(:build) do |build|
- allow(build).to receive(:commit).and_return build(:commit, :without_author)
+ commit = build(:commit, :without_author)
+ stub_method(build, :commit) { commit }
end
end
trait :with_commit_and_author do
after(:build) do |build|
- allow(build).to receive(:commit).and_return build(:commit)
+ commit = build(:commit)
+ stub_method(build, :commit) { commit }
end
end
diff --git a/spec/factories/clusters/applications/helm.rb b/spec/factories/clusters/applications/helm.rb
index 10fa739acc1..919b45e57e2 100644
--- a/spec/factories/clusters/applications/helm.rb
+++ b/spec/factories/clusters/applications/helm.rb
@@ -10,19 +10,18 @@ FactoryBot.define do
before(:create) do |_record, evaluator|
if evaluator.helm_installed
- allow(Gitlab::Kubernetes::Helm::V2::Certificate).to receive(:generate_root)
- .and_return(
- double(
- key_string: File.read(Rails.root.join('spec/fixtures/clusters/sample_key.key')),
- cert_string: File.read(Rails.root.join('spec/fixtures/clusters/sample_cert.pem'))
- )
+ stub_method(Gitlab::Kubernetes::Helm::V2::Certificate, :generate_root) do
+ OpenStruct.new( # rubocop: disable Style/OpenStructUse
+ key_string: File.read(Rails.root.join('spec/fixtures/clusters/sample_key.key')),
+ cert_string: File.read(Rails.root.join('spec/fixtures/clusters/sample_cert.pem'))
)
+ end
end
end
after(:create) do |_record, evaluator|
if evaluator.helm_installed
- allow(Gitlab::Kubernetes::Helm::V2::Certificate).to receive(:generate_root).and_call_original
+ restore_original_methods(Gitlab::Kubernetes::Helm::V2::Certificate)
end
end
diff --git a/spec/factories/commits.rb b/spec/factories/commits.rb
index d006f9baf1f..4b1c74110ef 100644
--- a/spec/factories/commits.rb
+++ b/spec/factories/commits.rb
@@ -28,19 +28,20 @@ FactoryBot.define do
end
after(:build) do |commit, evaluator|
- allow(commit).to receive(:author).and_return(evaluator.author || build_stubbed(:author))
- allow(commit).to receive(:parent_ids).and_return([])
+ author = evaluator.author || build_stubbed(:author)
+ stub_method(commit, :author) { author }
+ stub_method(commit, :parent_ids) { [] }
end
trait :merge_commit do
after(:build) do |commit|
- allow(commit).to receive(:parent_ids).and_return(Array.new(2) { SecureRandom.hex(20) })
+ stub_method(commit, :parent_ids) { Array.new(2) { SecureRandom.hex(20) } }
end
end
trait :without_author do
after(:build) do |commit|
- allow(commit).to receive(:author).and_return nil
+ stub_method(commit, :author) { nil }
end
end
end
diff --git a/spec/factories/container_repositories.rb b/spec/factories/container_repositories.rb
index ce83e9e8006..210441430b0 100644
--- a/spec/factories/container_repositories.rb
+++ b/spec/factories/container_repositories.rb
@@ -85,13 +85,12 @@ FactoryBot.define do
tags = evaluator.tags
# convert Array into Hash
tags = tags.product(['sha256:4c8e63ca4cb663ce6c688cb06f1c372b088dac5b6d7ad7d49cd620d85cf72a15']).to_h unless tags.is_a?(Hash)
-
- allow(repository.client)
- .to receive(:repository_tags)
- .and_return({
+ stub_method(repository.client, :repository_tags) do |*args|
+ {
'name' => repository.path,
'tags' => tags.keys
- })
+ }
+ end
tags.each_pair do |tag, digest|
allow(repository.client)
diff --git a/spec/factories/deployments.rb b/spec/factories/deployments.rb
index ab1b794632a..204b917fa4a 100644
--- a/spec/factories/deployments.rb
+++ b/spec/factories/deployments.rb
@@ -15,7 +15,7 @@ FactoryBot.define do
deployment.user ||= deployment.project.creator
unless deployment.project.repository_exists?
- allow(deployment.project.repository).to receive(:create_ref)
+ stub_method(deployment.project.repository, :create_ref) { nil }
end
if deployment.cluster && deployment.cluster.project_type? && deployment.cluster.project.nil?
diff --git a/spec/factories/merge_requests.rb b/spec/factories/merge_requests.rb
index cba66b5d414..4941a31982f 100644
--- a/spec/factories/merge_requests.rb
+++ b/spec/factories/merge_requests.rb
@@ -320,7 +320,7 @@ FactoryBot.define do
# Fake `fetch_ref!` if we don't have repository
# We have too many existing tests relying on this behaviour
unless [target_project, source_project].all?(&:repository_exists?)
- allow(merge_request).to receive(:fetch_ref!)
+ stub_method(merge_request, :fetch_ref!) { nil }
end
end
diff --git a/spec/factories/projects.rb b/spec/factories/projects.rb
index c3c02782578..a5efadefc76 100644
--- a/spec/factories/projects.rb
+++ b/spec/factories/projects.rb
@@ -301,8 +301,8 @@ FactoryBot.define do
trait :stubbed_repository do
after(:build) do |project|
- allow(project).to receive(:empty_repo?).and_return(false)
- allow(project.repository).to receive(:empty?).and_return(false)
+ stub_method(project, :empty_repo?) { false }
+ stub_method(project.repository, :empty?) { false }
end
end