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
path: root/spec
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-02-25 21:09:02 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-02-25 21:09:02 +0300
commit951616a26a61e880860ad862c1d45a8e3762b4bc (patch)
treeed6fe722e955aff38e13ca02d2aa7fdd4239c863 /spec
parente06d0e779673d745972863302858105aad9032e5 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/admin/serverless/domains_controller_spec.rb90
-rw-r--r--spec/frontend/clusters/components/__snapshots__/remove_cluster_confirmation_spec.js.snap9
-rw-r--r--spec/lib/gitlab/git/blob_spec.rb34
-rw-r--r--spec/lib/gitlab/sidekiq_config/cli_methods_spec.rb32
-rw-r--r--spec/models/pages_domain_spec.rb1
-rw-r--r--spec/support/shared_examples/tasks/gitlab/import_export/measurable_shared_examples.rb (renamed from spec/support/shared_examples/tasks/gitlab/import_export/import_measurement_shared_examples.rb)2
-rw-r--r--spec/tasks/gitlab/import_export/export_rake_spec.rb37
-rw-r--r--spec/tasks/gitlab/import_export/import_rake_spec.rb2
8 files changed, 177 insertions, 30 deletions
diff --git a/spec/controllers/admin/serverless/domains_controller_spec.rb b/spec/controllers/admin/serverless/domains_controller_spec.rb
index aed83e190be..43c3f0117bc 100644
--- a/spec/controllers/admin/serverless/domains_controller_spec.rb
+++ b/spec/controllers/admin/serverless/domains_controller_spec.rb
@@ -15,7 +15,7 @@ describe Admin::Serverless::DomainsController do
it 'responds with 404' do
get :index
- expect(response.status).to eq(404)
+ expect(response).to have_gitlab_http_status(:not_found)
end
end
@@ -33,7 +33,7 @@ describe Admin::Serverless::DomainsController do
it 'responds with 404' do
get :index
- expect(response.status).to eq(404)
+ expect(response).to have_gitlab_http_status(:not_found)
end
end
@@ -81,7 +81,7 @@ describe Admin::Serverless::DomainsController do
it 'responds with 404' do
post :create, params: { pages_domain: create_params }
- expect(response.status).to eq(404)
+ expect(response).to have_gitlab_http_status(:not_found)
end
end
@@ -98,7 +98,7 @@ describe Admin::Serverless::DomainsController do
it 'responds with 404' do
post :create, params: { pages_domain: create_params }
- expect(response.status).to eq(404)
+ expect(response).to have_gitlab_http_status(:not_found)
end
end
@@ -169,7 +169,7 @@ describe Admin::Serverless::DomainsController do
it 'responds with 404' do
put :update, params: { id: domain.id, pages_domain: update_params }
- expect(response.status).to eq(404)
+ expect(response).to have_gitlab_http_status(:not_found)
end
end
@@ -186,7 +186,7 @@ describe Admin::Serverless::DomainsController do
it 'responds with 404' do
put :update, params: { id: domain.id, pages_domain: update_params }
- expect(response.status).to eq(404)
+ expect(response).to have_gitlab_http_status(:not_found)
end
end
@@ -221,7 +221,7 @@ describe Admin::Serverless::DomainsController do
it 'returns 404' do
put :update, params: { id: 0, pages_domain: update_params }
- expect(response.status).to eq(404)
+ expect(response).to have_gitlab_http_status(:not_found)
end
end
@@ -247,7 +247,7 @@ describe Admin::Serverless::DomainsController do
it 'responds with 404' do
post :verify, params: { id: domain.id }
- expect(response.status).to eq(404)
+ expect(response).to have_gitlab_http_status(:not_found)
end
end
@@ -272,7 +272,7 @@ describe Admin::Serverless::DomainsController do
it 'responds with 404' do
post :verify, params: { id: domain.id }
- expect(response.status).to eq(404)
+ expect(response).to have_gitlab_http_status(:not_found)
end
end
@@ -295,4 +295,76 @@ describe Admin::Serverless::DomainsController do
end
end
end
+
+ describe '#destroy' do
+ let!(:domain) { create(:pages_domain, :instance_serverless) }
+
+ context 'non-admin user' do
+ before do
+ sign_in(user)
+ end
+
+ it 'responds with 404' do
+ delete :destroy, params: { id: domain.id }
+
+ expect(response).to have_gitlab_http_status(:not_found)
+ end
+ end
+
+ context 'admin user' do
+ before do
+ sign_in(admin)
+ end
+
+ context 'with serverless_domain feature disabled' do
+ before do
+ stub_feature_flags(serverless_domain: false)
+ end
+
+ it 'responds with 404' do
+ delete :destroy, params: { id: domain.id }
+
+ expect(response).to have_gitlab_http_status(:not_found)
+ end
+ end
+
+ context 'when domain exists' do
+ context 'and is not associated to any clusters' do
+ it 'deletes the domain' do
+ expect { delete :destroy, params: { id: domain.id } }
+ .to change { PagesDomain.count }.from(1).to(0)
+
+ expect(response).to have_gitlab_http_status(:found)
+ expect(flash[:notice]).to include('Domain was successfully deleted.')
+ end
+ end
+
+ context 'and is associated to any clusters' do
+ before do
+ create(:serverless_domain_cluster, pages_domain: domain)
+ end
+
+ it 'does not delete the domain' do
+ expect { delete :destroy, params: { id: domain.id } }
+ .not_to change { PagesDomain.count }
+
+ expect(response).to have_gitlab_http_status(:conflict)
+ expect(flash[:notice]).to include('Domain cannot be deleted while associated to one or more clusters.')
+ end
+ end
+ end
+
+ context 'when domain does not exist' do
+ before do
+ domain.destroy!
+ end
+
+ it 'responds with 404' do
+ delete :destroy, params: { id: domain.id }
+
+ expect(response).to have_gitlab_http_status(:not_found)
+ end
+ end
+ end
+ end
end
diff --git a/spec/frontend/clusters/components/__snapshots__/remove_cluster_confirmation_spec.js.snap b/spec/frontend/clusters/components/__snapshots__/remove_cluster_confirmation_spec.js.snap
index a35348d86ea..d4269bf14ba 100644
--- a/spec/frontend/clusters/components/__snapshots__/remove_cluster_confirmation_spec.js.snap
+++ b/spec/frontend/clusters/components/__snapshots__/remove_cluster_confirmation_spec.js.snap
@@ -9,9 +9,12 @@ exports[`Remove cluster confirmation modal renders splitbutton with modal includ
class="btn btn-danger"
type="button"
>
-
- Remove integration and resources
-
+ <span
+ class="gl-dropdown-toggle-text"
+ >
+ Remove integration and resources
+ </span>
+
<!---->
</button>
<button
diff --git a/spec/lib/gitlab/git/blob_spec.rb b/spec/lib/gitlab/git/blob_spec.rb
index 079f01c2c4e..9c2f0e910b1 100644
--- a/spec/lib/gitlab/git/blob_spec.rb
+++ b/spec/lib/gitlab/git/blob_spec.rb
@@ -613,6 +613,40 @@ describe Gitlab::Git::Blob, :seed_helper do
end
end
+ describe '#truncated?' do
+ context 'when blob.size is nil' do
+ let(:nil_size_blob) { Gitlab::Git::Blob.new(name: 'test', data: 'abcd') }
+
+ it 'returns false' do
+ expect(nil_size_blob.truncated?).to be_falsey
+ end
+ end
+
+ context 'when blob.data is missing' do
+ let(:nil_data_blob) { Gitlab::Git::Blob.new(name: 'test', size: 4) }
+
+ it 'returns false' do
+ expect(nil_data_blob.truncated?).to be_falsey
+ end
+ end
+
+ context 'when the blob is truncated' do
+ let(:truncated_blob) { Gitlab::Git::Blob.new(name: 'test', size: 40, data: 'abcd') }
+
+ it 'returns true' do
+ expect(truncated_blob.truncated?).to be_truthy
+ end
+ end
+
+ context 'when the blob is untruncated' do
+ let(:untruncated_blob) { Gitlab::Git::Blob.new(name: 'test', size: 4, data: 'abcd') }
+
+ it 'returns false' do
+ expect(untruncated_blob.truncated?).to be_falsey
+ end
+ end
+ end
+
describe 'metrics' do
it 'defines :gitlab_blob_truncated_true counter' do
expect(described_class).to respond_to(:gitlab_blob_truncated_true)
diff --git a/spec/lib/gitlab/sidekiq_config/cli_methods_spec.rb b/spec/lib/gitlab/sidekiq_config/cli_methods_spec.rb
index e6d0055df64..4ba5726732c 100644
--- a/spec/lib/gitlab/sidekiq_config/cli_methods_spec.rb
+++ b/spec/lib/gitlab/sidekiq_config/cli_methods_spec.rb
@@ -128,7 +128,7 @@ describe Gitlab::SidekiqConfig::CliMethods do
resource_boundary: :cpu
},
{
- name: 'a_2',
+ name: 'a:2',
feature_category: :category_a,
has_external_dependencies: false,
latency_sensitive: true,
@@ -154,40 +154,40 @@ describe Gitlab::SidekiqConfig::CliMethods do
context 'with valid input' do
where(:query, :selected_queues) do
# feature_category
- 'feature_category=category_a' | %w(a a_2)
- 'feature_category=category_a,category_c' | %w(a a_2 c)
- 'feature_category=category_a|feature_category=category_c' | %w(a a_2 c)
+ 'feature_category=category_a' | %w(a a:2)
+ 'feature_category=category_a,category_c' | %w(a a:2 c)
+ 'feature_category=category_a|feature_category=category_c' | %w(a a:2 c)
'feature_category!=category_a' | %w(b c)
# has_external_dependencies
'has_external_dependencies=true' | %w(b)
- 'has_external_dependencies=false' | %w(a a_2 c)
- 'has_external_dependencies=true,false' | %w(a a_2 b c)
- 'has_external_dependencies=true|has_external_dependencies=false' | %w(a a_2 b c)
- 'has_external_dependencies!=true' | %w(a a_2 c)
+ 'has_external_dependencies=false' | %w(a a:2 c)
+ 'has_external_dependencies=true,false' | %w(a a:2 b c)
+ 'has_external_dependencies=true|has_external_dependencies=false' | %w(a a:2 b c)
+ 'has_external_dependencies!=true' | %w(a a:2 c)
# latency_sensitive
- 'latency_sensitive=true' | %w(a_2 b)
+ 'latency_sensitive=true' | %w(a:2 b)
'latency_sensitive=false' | %w(a c)
- 'latency_sensitive=true,false' | %w(a a_2 b c)
- 'latency_sensitive=true|latency_sensitive=false' | %w(a a_2 b c)
+ 'latency_sensitive=true,false' | %w(a a:2 b c)
+ 'latency_sensitive=true|latency_sensitive=false' | %w(a a:2 b c)
'latency_sensitive!=true' | %w(a c)
# name
'name=a' | %w(a)
'name=a,b' | %w(a b)
- 'name=a,a_2|name=b' | %w(a a_2 b)
- 'name!=a,a_2' | %w(b c)
+ 'name=a,a:2|name=b' | %w(a a:2 b)
+ 'name!=a,a:2' | %w(b c)
# resource_boundary
'resource_boundary=memory' | %w(b c)
'resource_boundary=memory,cpu' | %w(a b c)
'resource_boundary=memory|resource_boundary=cpu' | %w(a b c)
- 'resource_boundary!=memory,cpu' | %w(a_2)
+ 'resource_boundary!=memory,cpu' | %w(a:2)
# combinations
- 'feature_category=category_a&latency_sensitive=true' | %w(a_2)
- 'feature_category=category_a&latency_sensitive=true|feature_category=category_c' | %w(a_2 c)
+ 'feature_category=category_a&latency_sensitive=true' | %w(a:2)
+ 'feature_category=category_a&latency_sensitive=true|feature_category=category_c' | %w(a:2 c)
end
with_them do
diff --git a/spec/models/pages_domain_spec.rb b/spec/models/pages_domain_spec.rb
index d2a54c3eea7..7b24ca5eb23 100644
--- a/spec/models/pages_domain_spec.rb
+++ b/spec/models/pages_domain_spec.rb
@@ -9,6 +9,7 @@ describe PagesDomain do
describe 'associations' do
it { is_expected.to belong_to(:project) }
+ it { is_expected.to have_many(:serverless_domain_clusters) }
end
describe 'validate domain' do
diff --git a/spec/support/shared_examples/tasks/gitlab/import_export/import_measurement_shared_examples.rb b/spec/support/shared_examples/tasks/gitlab/import_export/measurable_shared_examples.rb
index e232f237df9..4df81478639 100644
--- a/spec/support/shared_examples/tasks/gitlab/import_export/import_measurement_shared_examples.rb
+++ b/spec/support/shared_examples/tasks/gitlab/import_export/measurable_shared_examples.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-RSpec.shared_examples 'import measurement' do
+RSpec.shared_examples 'measurable' do
context 'when measurement is enabled' do
let(:measurement_enabled) { true }
diff --git a/spec/tasks/gitlab/import_export/export_rake_spec.rb b/spec/tasks/gitlab/import_export/export_rake_spec.rb
new file mode 100644
index 00000000000..b665b46fe1c
--- /dev/null
+++ b/spec/tasks/gitlab/import_export/export_rake_spec.rb
@@ -0,0 +1,37 @@
+# frozen_string_literal: true
+
+require 'rake_helper'
+
+describe 'gitlab:import_export:export rake task' do
+ let(:username) { 'root' }
+ let(:namespace_path) { username }
+ let!(:user) { create(:user, username: username) }
+ let(:measurement_enabled) { false }
+ let(:task_params) { [username, namespace_path, project_name, archive_path, measurement_enabled] }
+
+ before do
+ Rake.application.rake_require('tasks/gitlab/import_export/export')
+ end
+
+ subject { run_rake_task('gitlab:import_export:export', task_params) }
+
+ context 'when project is found' do
+ let(:project) { create(:project, creator: user, namespace: user.namespace) }
+ let(:project_name) { project.name }
+ let(:archive_path) { 'spec/fixtures/gitlab/import_export/test_project_export.tar.gz' }
+
+ around do |example|
+ example.run
+ ensure
+ File.delete(archive_path)
+ end
+
+ it 'performs project export successfully' do
+ expect { subject }.to output(/Done!/).to_stdout
+
+ expect(File).to exist(archive_path)
+ end
+
+ it_behaves_like 'measurable'
+ end
+end
diff --git a/spec/tasks/gitlab/import_export/import_rake_spec.rb b/spec/tasks/gitlab/import_export/import_rake_spec.rb
index 3a819d23299..3e0bf2d0832 100644
--- a/spec/tasks/gitlab/import_export/import_rake_spec.rb
+++ b/spec/tasks/gitlab/import_export/import_rake_spec.rb
@@ -70,7 +70,7 @@ describe 'gitlab:import_export:import rake task' do
subject
end
- it_behaves_like 'import measurement'
+ it_behaves_like 'measurable'
end
context 'when project import is invalid' do