summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-11-11 09:06:38 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2019-11-11 09:06:38 +0000
commit4a45f0eff2a25c64bdd83926e35a8894a4f0469f (patch)
tree8068fff1731ccf4182605c2661c25f0a1c936866 /spec
parentd9c3a63a4394990bcdccbaca73c58278469236b4 (diff)
downloadgitlab-ce-4a45f0eff2a25c64bdd83926e35a8894a4f0469f.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/javascripts/blob/viewer/index_spec.js25
-rw-r--r--spec/lib/container_registry/client_spec.rb12
-rw-r--r--spec/migrations/add_default_and_free_plans_spec.rb34
-rw-r--r--spec/services/projects/container_repository/delete_tags_service_spec.rb31
4 files changed, 77 insertions, 25 deletions
diff --git a/spec/javascripts/blob/viewer/index_spec.js b/spec/javascripts/blob/viewer/index_spec.js
index 766c3378584..bbc59632f3c 100644
--- a/spec/javascripts/blob/viewer/index_spec.js
+++ b/spec/javascripts/blob/viewer/index_spec.js
@@ -176,36 +176,19 @@ describe('Blob viewer', () => {
});
});
- describe('linkifyURLs', () => {
- it('renders a plain url as a link in simple view', done => {
+ describe('a URL inside the blob content', () => {
+ beforeEach(() => {
mock.onGet('http://test.host/snippets/1.json?viewer=simple').reply(200, {
html:
'<div class="js-blob-content"><pre class="code"><code><span class="line" lang="yaml"><span class="c1">To install gitlab-shell you also need a Go compiler version 1.8 or newer. https://golang.org/dl/</span></span></code></pre></div>',
});
-
- asyncClick()
- .then(() => {
- expect(document.querySelector('.blob-viewer[data-type="simple"]').innerHTML).toContain(
- '<a href="https://golang.org/dl/">https://golang.org/dl/</a>',
- );
- done();
- })
- .catch(() => {
- fail();
- done();
- });
});
- it('leaves an unescaped url untouched', done => {
- mock.onGet('http://test.host/snippets/1.json?viewer=simple').reply(200, {
- html:
- '<div class="js-blob-content"><pre class="code"><code><span class="line" lang="yaml"><a href="https://golang.org/dl/">golang</a></span></span></code></pre></div>',
- });
-
+ it('is rendered as a link in simple view', done => {
asyncClick()
.then(() => {
expect(document.querySelector('.blob-viewer[data-type="simple"]').innerHTML).toContain(
- '<a href="https://golang.org/dl/">golang</a>',
+ '<a href="https://golang.org/dl/">https://golang.org/dl/</a>',
);
done();
})
diff --git a/spec/lib/container_registry/client_spec.rb b/spec/lib/container_registry/client_spec.rb
index 3782c30e88a..a493b96b1e4 100644
--- a/spec/lib/container_registry/client_spec.rb
+++ b/spec/lib/container_registry/client_spec.rb
@@ -99,8 +99,8 @@ describe ContainerRegistry::Client do
stub_upload('path', 'content', 'sha256:123', 400)
end
- it 'returns nil' do
- expect(subject).to be nil
+ it 'returns a failure' do
+ expect(subject).not_to be_success
end
end
end
@@ -125,6 +125,14 @@ describe ContainerRegistry::Client do
expect(subject).to eq(result_manifest)
end
+
+ context 'when upload fails' do
+ before do
+ stub_upload('path', "{\n \"config\": {\n }\n}", 'sha256:4435000728ee66e6a80e55637fc22725c256b61de344a2ecdeaac6bdb36e8bc3', 500)
+ end
+
+ it { is_expected.to be nil }
+ end
end
describe '#put_tag' do
diff --git a/spec/migrations/add_default_and_free_plans_spec.rb b/spec/migrations/add_default_and_free_plans_spec.rb
new file mode 100644
index 00000000000..ae40b5b10c2
--- /dev/null
+++ b/spec/migrations/add_default_and_free_plans_spec.rb
@@ -0,0 +1,34 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+require Rails.root.join('db', 'migrate', '20191023152913_add_default_and_free_plans.rb')
+
+describe AddDefaultAndFreePlans, :migration do
+ describe 'migrate' do
+ let(:plans) { table(:plans) }
+
+ context 'when on Gitlab.com' do
+ before do
+ expect(Gitlab).to receive(:com?) { true }
+ end
+
+ it 'creates free and default plans' do
+ expect { migrate! }.to change { plans.count }.by 2
+
+ expect(plans.last(2).pluck(:name)).to eq %w[free default]
+ end
+ end
+
+ context 'when on self-hosted' do
+ before do
+ expect(Gitlab).to receive(:com?) { false }
+ end
+
+ it 'creates only a default plan' do
+ expect { migrate! }.to change { plans.count }.by 1
+
+ expect(plans.last.name).to eq 'default'
+ end
+ end
+ end
+end
diff --git a/spec/services/projects/container_repository/delete_tags_service_spec.rb b/spec/services/projects/container_repository/delete_tags_service_spec.rb
index 91b668495d8..1cfe3582e56 100644
--- a/spec/services/projects/container_repository/delete_tags_service_spec.rb
+++ b/spec/services/projects/container_repository/delete_tags_service_spec.rb
@@ -88,6 +88,33 @@ describe Projects::ContainerRepository::DeleteTagsService do
is_expected.to include(status: :success)
end
+
+ context 'with failures' do
+ context 'when the dummy manifest generation fails' do
+ before do
+ stub_upload("{\n \"config\": {\n }\n}", 'sha256:4435000728ee66e6a80e55637fc22725c256b61de344a2ecdeaac6bdb36e8bc3', success: false)
+ end
+
+ it { is_expected.to include(status: :error) }
+ end
+
+ context 'when updating the tags fails' do
+ before do
+ stub_upload("{\n \"config\": {\n }\n}", 'sha256:4435000728ee66e6a80e55637fc22725c256b61de344a2ecdeaac6bdb36e8bc3')
+
+ stub_request(:put, "http://registry.gitlab/v2/#{repository.path}/manifests/A")
+ .to_return(status: 500, body: "", headers: { 'docker-content-digest' => 'sha256:dummy' })
+
+ stub_request(:put, "http://registry.gitlab/v2/#{repository.path}/manifests/Ba")
+ .to_return(status: 500, body: "", headers: { 'docker-content-digest' => 'sha256:dummy' })
+
+ stub_request(:delete, "http://registry.gitlab/v2/#{repository.path}/manifests/sha256:4435000728ee66e6a80e55637fc22725c256b61de344a2ecdeaac6bdb36e8bc3")
+ .to_return(status: 200, body: "", headers: {})
+ end
+
+ it { is_expected.to include(status: :error) }
+ end
+ end
end
end
end
@@ -107,10 +134,10 @@ describe Projects::ContainerRepository::DeleteTagsService do
end
end
- def stub_upload(content, digest)
+ def stub_upload(content, digest, success: true)
expect_any_instance_of(ContainerRegistry::Client)
.to receive(:upload_blob)
- .with(repository.path, content, digest) { double(success?: true ) }
+ .with(repository.path, content, digest) { double(success?: success ) }
end
def expect_delete_tag(digest)