Commit a05477b0 authored by GitLab Bot's avatar GitLab Bot
Browse files

Add latest changes from gitlab-org/gitlab@master

parent 09d81de5e5f6
......@@ -38,12 +38,14 @@
end
end
context 'when there is only one <testcase> in <testsuite>' do
context 'when there is only one <testsuite> in <testsuites>' do
let(:junit) do
<<-EOF.strip_heredoc
<testsuite>
<testcase classname='Calculator' name='sumTest1' time='0.01'></testcase>
</testsuite>
<testsuites>
<testsuite>
<testcase classname='Calculator' name='sumTest1' time='0.01'></testcase>
</testsuite>
</testsuites>
EOF
end
......@@ -56,23 +58,65 @@
end
end
context 'when there is only one <testsuite> in <testsuites>' do
context 'when there is <testcase>' do
let(:junit) do
<<-EOF.strip_heredoc
<testsuites>
<testsuite>
<testcase classname='Calculator' name='sumTest1' time='0.01'></testcase>
<testcase classname='Calculator' name='sumTest1' time='0.01'>
#{testcase_content}
</testcase>
</testsuite>
</testsuites>
EOF
end
it 'parses XML and adds a test case to a suite' do
let(:test_case) { test_cases[0] }
before do
expect { subject }.not_to raise_error
end
expect(test_cases[0].classname).to eq('Calculator')
expect(test_cases[0].name).to eq('sumTest1')
expect(test_cases[0].execution_time).to eq(0.01)
shared_examples_for '<testcase> XML parser' do |status, output|
it 'parses XML and adds a test case to the suite' do
aggregate_failures do
expect(test_case.classname).to eq('Calculator')
expect(test_case.name).to eq('sumTest1')
expect(test_case.execution_time).to eq(0.01)
expect(test_case.status).to eq(status)
expect(test_case.system_output).to eq(output)
end
end
end
context 'and has failure' do
let(:testcase_content) { '<failure>Some failure</failure>' }
it_behaves_like '<testcase> XML parser',
::Gitlab::Ci::Reports::TestCase::STATUS_FAILED,
'Some failure'
end
context 'and has error' do
let(:testcase_content) { '<error>Some error</error>' }
it_behaves_like '<testcase> XML parser',
::Gitlab::Ci::Reports::TestCase::STATUS_FAILED,
'Some error'
end
context 'and has an unknown type' do
let(:testcase_content) { '<foo>Some foo</foo>' }
it_behaves_like '<testcase> XML parser',
::Gitlab::Ci::Reports::TestCase::STATUS_SUCCESS,
nil
end
context 'and has no content' do
let(:testcase_content) { '' }
it_behaves_like '<testcase> XML parser',
::Gitlab::Ci::Reports::TestCase::STATUS_SUCCESS,
nil
end
end
......
......@@ -18,13 +18,13 @@
context 'Gitaly server is up' do
let(:gitaly_check) { double(check: { success: true }) }
it { is_expected.to eq([result_class.new(true, nil, shard: 'default')]) }
it { is_expected.to eq([result_class.new('gitaly_check', true, nil, shard: 'default')]) }
end
context 'Gitaly server is down' do
let(:gitaly_check) { double(check: { success: false, message: 'Connection refused' }) }
it { is_expected.to eq([result_class.new(false, 'Connection refused', shard: 'default')]) }
it { is_expected.to eq([result_class.new('gitaly_check', false, 'Connection refused', shard: 'default')]) }
end
end
......
describe Gitlab::HealthChecks::PrometheusTextFormat do
let(:metric_class) { Gitlab::HealthChecks::Metric }
subject { described_class.new }
describe '#marshal' do
let(:sample_metrics) do
[metric_class.new('metric1', 1),
metric_class.new('metric2', 2)]
end
it 'marshal to text with non repeating type definition' do
expected = <<-EXPECTED.strip_heredoc
# TYPE metric1 gauge
metric1 1
# TYPE metric2 gauge
metric2 2
EXPECTED
expect(subject.marshal(sample_metrics)).to eq(expected)
end
context 'metrics where name repeats' do
let(:sample_metrics) do
[metric_class.new('metric1', 1),
metric_class.new('metric1', 2),
metric_class.new('metric2', 3)]
end
it 'marshal to text with non repeating type definition' do
expected = <<-EXPECTED.strip_heredoc
# TYPE metric1 gauge
metric1 1
metric1 2
# TYPE metric2 gauge
metric2 3
EXPECTED
expect(subject.marshal(sample_metrics)).to eq(expected)
end
end
end
end
......@@ -411,6 +411,7 @@ project:
- external_pull_requests
- pages_metadatum
- alerts_service
- grafana_integration
award_emoji:
- awardable
- user
......
......@@ -62,6 +62,14 @@
expect { subject }.to raise_error(described_class::BlockedUrlError)
end
end
context 'when domain is too long' do
let(:import_url) { 'https://example' + 'a' * 1024 + '.com' }
it 'raises an error' do
expect { subject }.to raise_error(described_class::BlockedUrlError)
end
end
end
context 'when the URL hostname is an IP address' do
......
# frozen_string_literal: true
require 'spec_helper'
describe GrafanaIntegration do
describe 'associations' do
it { is_expected.to belong_to(:project) }
end
describe 'validations' do
it { is_expected.to validate_presence_of(:project) }
it { is_expected.to validate_presence_of(:token) }
it 'disallows invalid urls for grafana_url' do
unsafe_url = %{https://replaceme.com/'><script>alert(document.cookie)</script>}
non_ascii_url = 'http://gitlab.com/api/0/projects/project1/something€'
blank_url = ''
excessively_long_url = 'https://grafan' + 'a' * 1024 + '.com'
is_expected.not_to allow_values(
unsafe_url,
non_ascii_url,
blank_url,
excessively_long_url
).for(:grafana_url)
end
it 'allows valid urls for grafana_url' do
external_url = 'http://grafana.com/'
internal_url = 'http://192.168.1.1'
is_expected.to allow_value(
external_url,
internal_url
).for(:grafana_url)
end
end
end
......@@ -896,32 +896,6 @@ def project_rugged(project)
end
end
end
context 'when :emails_disabled feature flag is off' do
before do
stub_feature_flags(emails_disabled: false)
end
context 'when not a subgroup' do
it 'returns false' do
group = create(:group, emails_disabled: true)
expect(group.emails_disabled?).to be_falsey
end
end
context 'when a subgroup and ancestor emails are disabled' do
let(:grandparent) { create(:group) }
let(:parent) { create(:group, parent: grandparent) }
let(:group) { create(:group, parent: parent) }
it 'returns false' do
grandparent.update_attribute(:emails_disabled, true)
expect(group.emails_disabled?).to be_falsey
end
end
end
end
describe '#pages_virtual_domain' do
......
......@@ -2387,29 +2387,6 @@
expect(project.emails_disabled?).to be_truthy
end
end
context 'when :emails_disabled feature flag is off' do
before do
stub_feature_flags(emails_disabled: false)
end
context 'emails disabled in group' do
it 'returns false' do
allow(project.namespace).to receive(:emails_disabled?) { true }
expect(project.emails_disabled?).to be_falsey
end
end
context 'emails enabled in group' do
it 'returns false' do
allow(project.namespace).to receive(:emails_disabled?) { false }
project.update_attribute(:emails_disabled, true)
expect(project.emails_disabled?).to be_falsey
end
end
end
end
describe '#lfs_enabled?' do
......@@ -3671,14 +3648,6 @@ def enable_lfs
end
end
describe '#ensure_storage_path_exists' do
it 'delegates to gitlab_shell to ensure namespace is created' do
expect(gitlab_shell).to receive(:add_namespace).with(project.repository_storage, project.base_dir)
project.ensure_storage_path_exists
end
end
describe '#legacy_storage?' do
it 'returns true when storage_version is nil' do
project = build(:project, storage_version: nil)
......@@ -3793,16 +3762,6 @@ def enable_lfs
end
end
describe '#ensure_storage_path_exists' do
it 'delegates to gitlab_shell to ensure namespace is created' do
allow(project).to receive(:gitlab_shell).and_return(gitlab_shell)
expect(gitlab_shell).to receive(:add_namespace).with(project.repository_storage, hashed_prefix)
project.ensure_storage_path_exists
end
end
describe '#pages_path' do
it 'returns a path where pages are stored' do
expect(project.pages_path).to eq(File.join(Settings.pages.path, project.namespace.full_path, project.path))
......
......@@ -8,7 +8,7 @@
let!(:user) { create(:user) }
let!(:group) { create(:group) }
let!(:nested_group) { create(:group, parent: group) }
let!(:project) { create(:project, :legacy_storage, namespace: group) }
let!(:project) { create(:project, :repository, :legacy_storage, namespace: group) }
let!(:notification_setting) { create(:notification_setting, source: group)}
let(:gitlab_shell) { Gitlab::Shell.new }
let(:remove_path) { group.path + "+#{group.id}+deleted" }
......
......@@ -170,5 +170,61 @@
expect(project.reload.name).to eq(original_name)
end
end
context 'grafana integration' do
let(:params) do
{
grafana_integration_attributes: {
grafana_url: 'http://new.grafana.com',
token: 'VerySecureToken='
}
}
end
context 'without existing grafana integration' do
it 'creates an integration' do
expect(result[:status]).to eq(:success)
expected_attrs = params[:grafana_integration_attributes]
integration = project.reload.grafana_integration
expect(integration.grafana_url).to eq(expected_attrs[:grafana_url])
expect(integration.token).to eq(expected_attrs[:token])
end
end
context 'with an existing grafana integration' do
before do
create(:grafana_integration, project: project)
end
it 'updates the settings' do
expect(result[:status]).to eq(:success)
expected_attrs = params[:grafana_integration_attributes]
integration = project.reload.grafana_integration
expect(integration.grafana_url).to eq(expected_attrs[:grafana_url])
expect(integration.token).to eq(expected_attrs[:token])
end
context 'with all grafana attributes blank in params' do
let(:params) do
{
grafana_integration_attributes: {
grafana_url: '',
token: ''
}
}
end
it 'destroys the metrics_setting entry in DB' do
expect(result[:status]).to eq(:success)
expect(project.reload.grafana_integration).to be_nil
end
end
end
end
end
end
......@@ -30,8 +30,8 @@
context 'with unhealthy shard' do
let(:default_shard_name) { 'default' }
let(:unhealthy_shard_name) { 'unhealthy' }
let(:default_shard) { Gitlab::HealthChecks::Result.new(true, nil, shard: default_shard_name) }
let(:unhealthy_shard) { Gitlab::HealthChecks::Result.new(false, '14:Connect Failed', shard: unhealthy_shard_name) }
let(:default_shard) { Gitlab::HealthChecks::Result.new('gitaly_check', true, nil, shard: default_shard_name) }
let(:unhealthy_shard) { Gitlab::HealthChecks::Result.new('gitaly_check', false, '14:Connect Failed', shard: unhealthy_shard_name) }
before do
allow(Gitlab::HealthChecks::GitalyCheck).to receive(:readiness).and_return([default_shard, unhealthy_shard])
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment