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>2021-02-23 21:42:02 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-02-23 21:42:02 +0300
commit5a1541a44f745cf9ae4121d6919a1530a7212afe (patch)
tree3841ea24d9eaa1e5521f168348af3fd409aab962 /spec
parentf1bc6c9f752e5dcf11f5798c70498e9ae4a8e3ec (diff)
Add latest changes from gitlab-org/gitlab@13-9-stable-ee
Diffstat (limited to 'spec')
-rw-r--r--spec/frontend/artifacts_settings/components/__snapshots__/keep_latest_artifact_checkbox_spec.js.snap32
-rw-r--r--spec/frontend/artifacts_settings/components/keep_latest_artifact_checkbox_spec.js19
-rw-r--r--spec/frontend/vue_shared/alert_details/alert_details_spec.js7
-rw-r--r--spec/lib/gitlab/current_settings_spec.rb20
-rw-r--r--spec/lib/gitlab/import_export/repo_restorer_spec.rb2
-rw-r--r--spec/lib/object_storage/config_spec.rb63
-rw-r--r--spec/models/repository_spec.rb4
-rw-r--r--spec/requests/api/lint_spec.rb19
-rw-r--r--spec/services/issues/export_csv_service_spec.rb45
9 files changed, 79 insertions, 132 deletions
diff --git a/spec/frontend/artifacts_settings/components/__snapshots__/keep_latest_artifact_checkbox_spec.js.snap b/spec/frontend/artifacts_settings/components/__snapshots__/keep_latest_artifact_checkbox_spec.js.snap
index bfe7e40fb32..bf33aa731ef 100644
--- a/spec/frontend/artifacts_settings/components/__snapshots__/keep_latest_artifact_checkbox_spec.js.snap
+++ b/spec/frontend/artifacts_settings/components/__snapshots__/keep_latest_artifact_checkbox_spec.js.snap
@@ -1,37 +1,5 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
-exports[`Keep latest artifact checkbox when application keep latest artifact setting is disabled checkbox is disabled when application setting is disabled 1`] = `
-<div>
- <!---->
-
- <b-form-checkbox-stub
- checked="true"
- class="gl-form-checkbox"
- disabled="true"
- plain="true"
- value="true"
- >
- <strong
- class="gl-mr-3"
- >
- Keep artifacts from most recent successful jobs
- </strong>
-
- <gl-link-stub
- href="/help/ci/pipelines/job_artifacts"
- >
- More information
- </gl-link-stub>
-
- <p
- class="help-text"
- >
- This feature is disabled at the instance level.
- </p>
- </b-form-checkbox-stub>
-</div>
-`;
-
exports[`Keep latest artifact checkbox when application keep latest artifact setting is enabled sets correct setting value in checkbox with query result 1`] = `
<div>
<!---->
diff --git a/spec/frontend/artifacts_settings/components/keep_latest_artifact_checkbox_spec.js b/spec/frontend/artifacts_settings/components/keep_latest_artifact_checkbox_spec.js
index fe2886d6c95..b0d1b70c198 100644
--- a/spec/frontend/artifacts_settings/components/keep_latest_artifact_checkbox_spec.js
+++ b/spec/frontend/artifacts_settings/components/keep_latest_artifact_checkbox_spec.js
@@ -120,23 +120,4 @@ describe('Keep latest artifact checkbox', () => {
expect(findCheckbox().attributes('disabled')).toBeUndefined();
});
});
-
- describe('when application keep latest artifact setting is disabled', () => {
- it('checkbox is disabled when application setting is disabled', async () => {
- createComponent({
- keepLatestArtifactApplicationQueryHandler: jest.fn().mockResolvedValue({
- data: {
- ciApplicationSettings: {
- keepLatestArtifact: false,
- },
- },
- }),
- });
-
- await wrapper.vm.$nextTick();
-
- expect(wrapper.element).toMatchSnapshot();
- expect(findCheckbox().attributes('disabled')).toBe('true');
- });
- });
});
diff --git a/spec/frontend/vue_shared/alert_details/alert_details_spec.js b/spec/frontend/vue_shared/alert_details/alert_details_spec.js
index dd9a7be6268..ce410a8b3e7 100644
--- a/spec/frontend/vue_shared/alert_details/alert_details_spec.js
+++ b/spec/frontend/vue_shared/alert_details/alert_details_spec.js
@@ -128,6 +128,10 @@ describe('AlertDetails', () => {
expect(wrapper.findByTestId('startTimeItem').exists()).toBe(true);
expect(wrapper.findByTestId('startTimeItem').props('time')).toBe(mockAlert.startedAt);
});
+
+ it('renders the metrics tab', () => {
+ expect(findMetricsTab().exists()).toBe(true);
+ });
});
describe('individual alert fields', () => {
@@ -179,7 +183,8 @@ describe('AlertDetails', () => {
describe('Threat Monitoring details', () => {
it('should not render the metrics tab', () => {
mountComponent({
- data: { alert: mockAlert, provide: { isThreatMonitoringPage: true } },
+ data: { alert: mockAlert },
+ provide: { isThreatMonitoringPage: true },
});
expect(findMetricsTab().exists()).toBe(false);
});
diff --git a/spec/lib/gitlab/current_settings_spec.rb b/spec/lib/gitlab/current_settings_spec.rb
index 01aceec12c5..f5cb1987c5c 100644
--- a/spec/lib/gitlab/current_settings_spec.rb
+++ b/spec/lib/gitlab/current_settings_spec.rb
@@ -24,6 +24,26 @@ RSpec.describe Gitlab::CurrentSettings do
end
end
+ describe '.signup_disabled?' do
+ subject { described_class.signup_disabled? }
+
+ context 'when signup is enabled' do
+ before do
+ create(:application_setting, signup_enabled: true)
+ end
+
+ it { is_expected.to be_falsey }
+ end
+
+ context 'when signup is disabled' do
+ before do
+ create(:application_setting, signup_enabled: false)
+ end
+
+ it { is_expected.to be_truthy }
+ end
+ end
+
describe '#current_application_settings', :use_clean_rails_memory_store_caching do
it 'allows keys to be called directly' do
db_settings = create(:application_setting,
diff --git a/spec/lib/gitlab/import_export/repo_restorer_spec.rb b/spec/lib/gitlab/import_export/repo_restorer_spec.rb
index fe43a23e242..718a23f80a1 100644
--- a/spec/lib/gitlab/import_export/repo_restorer_spec.rb
+++ b/spec/lib/gitlab/import_export/repo_restorer_spec.rb
@@ -46,7 +46,7 @@ RSpec.describe Gitlab::ImportExport::RepoRestorer do
context 'when the repository already exists' do
it 'deletes the existing repository before importing' do
allow(project.repository).to receive(:exists?).and_return(true)
- allow(project.repository).to receive(:path).and_return('repository_path')
+ allow(project.repository).to receive(:disk_path).and_return('repository_path')
expect_next_instance_of(Repositories::DestroyService) do |instance|
expect(instance).to receive(:execute).and_call_original
diff --git a/spec/lib/object_storage/config_spec.rb b/spec/lib/object_storage/config_spec.rb
index 1361d80fe75..0ead2a1d269 100644
--- a/spec/lib/object_storage/config_spec.rb
+++ b/spec/lib/object_storage/config_spec.rb
@@ -1,7 +1,8 @@
# frozen_string_literal: true
-require 'spec_helper'
+require 'fast_spec_helper'
require 'rspec-parameterized'
+require 'fog/core'
RSpec.describe ObjectStorage::Config do
using RSpec::Parameterized::TableSyntax
@@ -33,9 +34,7 @@ RSpec.describe ObjectStorage::Config do
}
end
- subject do
- described_class.new(raw_config.as_json)
- end
+ subject { described_class.new(raw_config.as_json) }
describe '#load_provider' do
before do
@@ -46,10 +45,6 @@ RSpec.describe ObjectStorage::Config do
it 'registers AWS as a provider' do
expect(Fog.providers.keys).to include(:aws)
end
-
- describe '#fog_connection' do
- it { expect(subject.fog_connection).to be_a_kind_of(Fog::AWS::Storage::Real) }
- end
end
context 'with Google' do
@@ -64,10 +59,6 @@ RSpec.describe ObjectStorage::Config do
it 'registers Google as a provider' do
expect(Fog.providers.keys).to include(:google)
end
-
- describe '#fog_connection' do
- it { expect(subject.fog_connection).to be_a_kind_of(Fog::Storage::GoogleXML::Real) }
- end
end
context 'with Azure' do
@@ -82,10 +73,6 @@ RSpec.describe ObjectStorage::Config do
it 'registers AzureRM as a provider' do
expect(Fog.providers.keys).to include(:azurerm)
end
-
- describe '#fog_connection' do
- it { expect(subject.fog_connection).to be_a_kind_of(Fog::Storage::AzureRM::Real) }
- end
end
end
@@ -183,50 +170,6 @@ RSpec.describe ObjectStorage::Config do
it { expect(subject.provider).to eq('AWS') }
it { expect(subject.aws?).to be true }
it { expect(subject.google?).to be false }
-
- it 'returns the default S3 endpoint' do
- subject.load_provider
-
- expect(subject.s3_endpoint).to eq("https://test-bucket.s3.amazonaws.com")
- end
-
- describe 'with a custom endpoint' do
- let(:endpoint) { 'https://my.example.com' }
-
- before do
- credentials[:endpoint] = endpoint
- end
-
- it 'returns the custom endpoint' do
- subject.load_provider
-
- expect(subject.s3_endpoint).to eq(endpoint)
- end
- end
-
- context 'with custom S3 host and port' do
- where(:host, :port, :scheme, :expected) do
- 's3.example.com' | 8080 | nil | 'https://test-bucket.s3.example.com:8080'
- 's3.example.com' | 443 | nil | 'https://test-bucket.s3.example.com'
- 's3.example.com' | 443 | "https" | 'https://test-bucket.s3.example.com'
- 's3.example.com' | nil | nil | 'https://test-bucket.s3.example.com'
- 's3.example.com' | 80 | "http" | 'http://test-bucket.s3.example.com'
- 's3.example.com' | "bogus" | nil | nil
- end
-
- with_them do
- before do
- credentials[:host] = host
- credentials[:port] = port
- credentials[:scheme] = scheme
- subject.load_provider
- end
-
- it 'returns expected host' do
- expect(subject.s3_endpoint).to eq(expected)
- end
- end
- end
end
context 'with Google credentials' do
diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb
index 3a4de7ba279..84347ec2a51 100644
--- a/spec/models/repository_spec.rb
+++ b/spec/models/repository_spec.rb
@@ -1949,8 +1949,8 @@ RSpec.describe Repository do
:root_ref,
:merged_branch_names,
:has_visible_content?,
- :issue_template_names_by_category,
- :merge_request_template_names_by_category,
+ :issue_template_names_hash,
+ :merge_request_template_names_hash,
:user_defined_metrics_dashboard_paths,
:xcode_project?,
:has_ambiguous_refs?
diff --git a/spec/requests/api/lint_spec.rb b/spec/requests/api/lint_spec.rb
index 2316e702c3e..b5bf697e9e3 100644
--- a/spec/requests/api/lint_spec.rb
+++ b/spec/requests/api/lint_spec.rb
@@ -5,7 +5,9 @@ require 'spec_helper'
RSpec.describe API::Lint do
describe 'POST /ci/lint' do
context 'when signup settings are disabled' do
- Gitlab::CurrentSettings.signup_enabled = false
+ before do
+ Gitlab::CurrentSettings.signup_enabled = false
+ end
context 'when unauthenticated' do
it 'returns authentication error' do
@@ -16,22 +18,25 @@ RSpec.describe API::Lint do
end
context 'when authenticated' do
- it 'returns unauthorized error' do
- post api('/ci/lint'), params: { content: 'content' }
+ let_it_be(:api_user) { create(:user) }
+ it 'returns authorized' do
+ post api('/ci/lint', api_user), params: { content: 'content' }
- expect(response).to have_gitlab_http_status(:unauthorized)
+ expect(response).to have_gitlab_http_status(:ok)
end
end
end
context 'when signup settings are enabled' do
- Gitlab::CurrentSettings.signup_enabled = true
+ before do
+ Gitlab::CurrentSettings.signup_enabled = true
+ end
context 'when unauthenticated' do
- it 'returns authentication error' do
+ it 'returns authorized success' do
post api('/ci/lint'), params: { content: 'content' }
- expect(response).to have_gitlab_http_status(:unauthorized)
+ expect(response).to have_gitlab_http_status(:ok)
end
end
diff --git a/spec/services/issues/export_csv_service_spec.rb b/spec/services/issues/export_csv_service_spec.rb
index fd1bcf82ccd..d199f825276 100644
--- a/spec/services/issues/export_csv_service_spec.rb
+++ b/spec/services/issues/export_csv_service_spec.rb
@@ -4,11 +4,11 @@ require 'spec_helper'
RSpec.describe Issues::ExportCsvService do
let_it_be(:user) { create(:user) }
- let(:group) { create(:group) }
- let(:project) { create(:project, :public, group: group) }
- let!(:issue) { create(:issue, project: project, author: user) }
- let!(:bad_issue) { create(:issue, project: project, author: user) }
- let(:subject) { described_class.new(Issue.all, project) }
+ let_it_be(:group) { create(:group) }
+ let_it_be(:project) { create(:project, :public, group: group) }
+ let_it_be(:issue) { create(:issue, project: project, author: user) }
+ let_it_be(:bad_issue) { create(:issue, project: project, author: user) }
+ subject { described_class.new(Issue.all, project) }
it 'renders csv to string' do
expect(subject.csv_data).to be_a String
@@ -33,11 +33,11 @@ RSpec.describe Issues::ExportCsvService do
end
context 'includes' do
- let(:milestone) { create(:milestone, title: 'v1.0', project: project) }
- let(:idea_label) { create(:label, project: project, title: 'Idea') }
- let(:feature_label) { create(:label, project: project, title: 'Feature') }
+ let_it_be(:milestone) { create(:milestone, title: 'v1.0', project: project) }
+ let_it_be(:idea_label) { create(:label, project: project, title: 'Idea') }
+ let_it_be(:feature_label) { create(:label, project: project, title: 'Feature') }
- before do
+ before_all do
# Creating a timelog touches the updated_at timestamp of issue,
# so create these first.
issue.timelogs.create!(time_spent: 360, user: user)
@@ -60,6 +60,10 @@ RSpec.describe Issues::ExportCsvService do
expect(csv.headers).to include('Title', 'Description')
end
+ it 'returns two issues' do
+ expect(csv.count).to eq(2)
+ end
+
specify 'iid' do
expect(csv[0]['Issue ID']).to eq issue.iid.to_s
end
@@ -150,7 +154,7 @@ RSpec.describe Issues::ExportCsvService do
end
context 'with issues filtered by labels and project' do
- let(:subject) do
+ subject do
described_class.new(
IssuesFinder.new(user,
project_id: project.id,
@@ -162,6 +166,27 @@ RSpec.describe Issues::ExportCsvService do
expect(csv[0]['Issue ID']).to eq issue.iid.to_s
end
end
+
+ context 'with label links' do
+ let(:labeled_issues) { create_list(:labeled_issue, 2, project: project, author: user, labels: [feature_label, idea_label]) }
+
+ it 'does not run a query for each label link' do
+ control_count = ActiveRecord::QueryRecorder.new { csv }.count
+
+ labeled_issues
+
+ expect { csv }.not_to exceed_query_limit(control_count)
+ expect(csv.count).to eq(4)
+ end
+
+ it 'returns the labels in sorted order' do
+ labeled_issues
+
+ labeled_rows = csv.select { |entry| labeled_issues.map(&:iid).include?(entry['Issue ID'].to_i) }
+ expect(labeled_rows.count).to eq(2)
+ expect(labeled_rows.map { |entry| entry['Labels'] }).to all( eq("Feature,Idea") )
+ end
+ end
end
context 'with minimal details' do