summaryrefslogtreecommitdiff
path: root/spec/support/stub_gitlab_calls.rb
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-04-03 15:52:24 +0200
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-04-03 15:52:24 +0200
commitbaa00d542478759be225a45dc805d0314e1921d2 (patch)
tree8a959e57256764f536fe36db0b6876171843b70d /spec/support/stub_gitlab_calls.rb
parent0af4cbc57266cd7d2c433442c537da5c8970a3da (diff)
downloadgitlab-ce-baa00d542478759be225a45dc805d0314e1921d2.tar.gz
Refactor container registry repository tag stubs
Diffstat (limited to 'spec/support/stub_gitlab_calls.rb')
-rw-r--r--spec/support/stub_gitlab_calls.rb28
1 files changed, 22 insertions, 6 deletions
diff --git a/spec/support/stub_gitlab_calls.rb b/spec/support/stub_gitlab_calls.rb
index dbf3ace37c3..ded2d593059 100644
--- a/spec/support/stub_gitlab_calls.rb
+++ b/spec/support/stub_gitlab_calls.rb
@@ -31,20 +31,36 @@ module StubGitlabCalls
.to receive(:full_access_token).and_return('token')
end
- def stub_container_registry_tags(*tags)
+ def stub_container_registry_tags(repository: :any, tags:)
+ repository = any_args if repository == :any
+
allow_any_instance_of(ContainerRegistry::Client)
- .to receive(:repository_tags).and_return({ 'tags' => tags })
+ .to receive(:repository_tags).with(repository)
+ .and_return({ 'tags' => tags })
allow_any_instance_of(ContainerRegistry::Client)
- .to receive(:repository_manifest).and_return(
- JSON.parse(File.read(Rails.root + 'spec/fixtures/container_registry/tag_manifest.json')))
+ .to receive(:repository_manifest).with(repository)
+ .and_return(stub_container_registry_tag_manifest)
- allow_any_instance_of(ContainerRegistry::Client).to receive(:blob).and_return(
- File.read(Rails.root + 'spec/fixtures/container_registry/config_blob.json'))
+ allow_any_instance_of(ContainerRegistry::Client)
+ .to receive(:blob).with(repository)
+ .and_return(stub_container_registry_blob)
end
private
+ def stub_container_registry_tag_manifest
+ fixture_path = 'spec/fixtures/container_registry/tag_manifest.json'
+
+ JSON.parse(File.read(Rails.root + fixture_path))
+ end
+
+ def stub_container_registry_blob
+ fixture_path = 'spec/fixtures/container_registry/config_blob.json'
+
+ File.read(Rails.root + fixture_path)
+ end
+
def gitlab_url
Gitlab.config.gitlab.url
end