Skip to content
Snippets Groups Projects
Commit a89cb5cb authored by GitLab Bot's avatar GitLab Bot
Browse files

Add latest changes from gitlab-org/gitlab@master

parent 0d6fa033
No related branches found
No related tags found
No related merge requests found
Showing
with 268 additions and 64 deletions
Loading
Loading
@@ -106,13 +106,13 @@ describe NavHelper, :do_not_mock_admin_mode do
end
end
 
context '.admin_monitoring_nav_links' do
describe '.admin_monitoring_nav_links' do
subject { helper.admin_monitoring_nav_links }
 
it { is_expected.to all(be_a(String)) }
end
 
context '.group_issues_sub_menu_items' do
describe '.group_issues_sub_menu_items' do
subject { helper.group_issues_sub_menu_items }
 
it { is_expected.to all(be_a(String)) }
Loading
Loading
Loading
Loading
@@ -34,7 +34,7 @@ describe SourcegraphHelper do
end
end
 
context '#sourcegraph_experimental_message' do
describe '#sourcegraph_experimental_message' do
let(:feature_conditional) { false }
let(:public_only) { false }
 
Loading
Loading
import Vue from 'vue';
import externalUrlComp from '~/environments/components/environment_external_url.vue';
describe('External URL Component', () => {
let ExternalUrlComponent;
beforeEach(() => {
ExternalUrlComponent = Vue.extend(externalUrlComp);
});
it('should link to the provided externalUrl prop', () => {
const externalURL = 'https://gitlab.com';
const component = new ExternalUrlComponent({
propsData: {
externalUrl: externalURL,
},
}).$mount();
expect(component.$el.getAttribute('href')).toEqual(externalURL);
expect(component.$el.querySelector('fa-external-link')).toBeDefined();
});
});
Loading
Loading
@@ -14,7 +14,7 @@ describe ContainerRegistry::Registry do
 
it { expect(subject).not_to be_nil }
 
context '#path' do
describe '#path' do
subject { registry.path }
 
context 'path from URL' do
Loading
Loading
Loading
Loading
@@ -70,26 +70,26 @@ describe ContainerRegistry::Tag do
headers: { 'Content-Type' => 'application/vnd.docker.distribution.manifest.v1+prettyjws' })
end
 
context '#layers' do
describe '#layers' do
subject { tag.layers }
 
it { expect(subject.length).to eq(1) }
end
 
context '#total_size' do
describe '#total_size' do
subject { tag.total_size }
 
it { is_expected.to be_nil }
end
 
context 'config processing' do
context '#config' do
describe '#config' do
subject { tag.config }
 
it { is_expected.to be_nil }
end
 
context '#created_at' do
describe '#created_at' do
subject { tag.created_at }
 
it { is_expected.to be_nil }
Loading
Loading
@@ -113,7 +113,7 @@ describe ContainerRegistry::Tag do
body: File.read(Rails.root + 'spec/fixtures/container_registry/config_blob_helm.json'))
end
 
context '#created_at' do
describe '#created_at' do
subject { tag.created_at }
 
it { is_expected.to be_nil }
Loading
Loading
@@ -130,13 +130,13 @@ describe ContainerRegistry::Tag do
headers: { 'Content-Type' => 'application/vnd.docker.distribution.manifest.v2+json' })
end
 
context '#layers' do
describe '#layers' do
subject { tag.layers }
 
it { expect(subject.length).to eq(1) }
end
 
context '#total_size' do
describe '#total_size' do
subject { tag.total_size }
 
it { is_expected.to eq(2319870) }
Loading
Loading
@@ -144,13 +144,13 @@ describe ContainerRegistry::Tag do
 
context 'config processing' do
shared_examples 'a processable' do
context '#config' do
describe '#config' do
subject { tag.config }
 
it { is_expected.not_to be_nil }
end
 
context '#created_at' do
describe '#created_at' do
subject { tag.created_at }
 
it { is_expected.not_to be_nil }
Loading
Loading
# frozen_string_literal: true
require 'spec_helper'
describe Gitlab::Alerting::Alert do
let_it_be(:project) { create(:project) }
let(:alert) { build(:alerting_alert, project: project, payload: payload) }
let(:payload) { {} }
shared_context 'gitlab alert' do
let(:gitlab_alert_id) { gitlab_alert.prometheus_metric_id.to_s }
let!(:gitlab_alert) { create(:prometheus_alert, project: project) }
before do
payload['labels'] = { 'gitlab_alert_id' => gitlab_alert_id }
end
end
shared_examples 'invalid alert' do
it 'is invalid' do
expect(alert).not_to be_valid
end
end
shared_examples 'parse payload' do |*pairs|
context 'without payload' do
it { is_expected.to be_nil }
end
pairs.each do |pair|
context "with #{pair}" do
let(:value) { 'some value' }
before do
section, name = pair.split('/')
payload[section] = { name => value }
end
it { is_expected.to eq(value) }
end
end
end
describe '#gitlab_alert' do
subject { alert.gitlab_alert }
context 'without payload' do
it { is_expected.to be_nil }
end
context 'with gitlab alert' do
include_context 'gitlab alert'
it { is_expected.to eq(gitlab_alert) }
end
context 'with unknown gitlab alert' do
include_context 'gitlab alert' do
let(:gitlab_alert_id) { 'unknown' }
end
it { is_expected.to be_nil }
end
end
describe '#title' do
subject { alert.title }
it_behaves_like 'parse payload',
'annotations/title',
'annotations/summary',
'labels/alertname'
context 'with gitlab alert' do
include_context 'gitlab alert'
context 'with annotations/title' do
let(:value) { 'annotation title' }
before do
payload['annotations'] = { 'title' => value }
end
it { is_expected.to eq(gitlab_alert.title) }
end
end
end
describe '#description' do
subject { alert.description }
it_behaves_like 'parse payload', 'annotations/description'
end
describe '#annotations' do
subject { alert.annotations }
context 'without payload' do
it { is_expected.to eq([]) }
end
context 'with payload' do
before do
payload['annotations'] = { 'foo' => 'value1', 'bar' => 'value2' }
end
it 'parses annotations' do
expect(subject.size).to eq(2)
expect(subject.map(&:label)).to eq(%w[foo bar])
expect(subject.map(&:value)).to eq(%w[value1 value2])
end
end
end
describe '#environment' do
subject { alert.environment }
context 'without gitlab_alert' do
it { is_expected.to be_nil }
end
context 'with gitlab alert' do
include_context 'gitlab alert'
it { is_expected.to eq(gitlab_alert.environment) }
end
end
describe '#starts_at' do
subject { alert.starts_at }
context 'with empty startsAt' do
before do
payload['startsAt'] = nil
end
it { is_expected.to be_nil }
end
context 'with invalid startsAt' do
before do
payload['startsAt'] = 'invalid'
end
it { is_expected.to be_nil }
end
context 'with payload' do
let(:time) { Time.now.change(usec: 0) }
before do
payload['startsAt'] = time.rfc3339
end
it { is_expected.to eq(time) }
end
end
describe '#full_query' do
using RSpec::Parameterized::TableSyntax
subject { alert.full_query }
where(:generator_url, :expected_query) do
nil | nil
'http://localhost' | nil
'invalid url' | nil
'http://localhost:9090/graph?g1.expr=vector%281%29' | nil
'http://localhost:9090/graph?g0.expr=vector%281%29' | 'vector(1)'
end
with_them do
before do
payload['generatorURL'] = generator_url
end
it { is_expected.to eq(expected_query) }
end
context 'with gitlab alert' do
include_context 'gitlab alert'
before do
payload['generatorURL'] = 'http://localhost:9090/graph?g0.expr=vector%281%29'
end
it { is_expected.to eq(gitlab_alert.full_query) }
end
end
describe '#alert_markdown' do
subject { alert.alert_markdown }
it_behaves_like 'parse payload', 'annotations/gitlab_incident_markdown'
end
describe '#valid?' do
before do
payload.update(
'annotations' => { 'title' => 'some title' },
'startsAt' => Time.now.rfc3339
)
end
subject { alert }
it { is_expected.to be_valid }
context 'without project' do
# Redefine to prevent:
# project is a NilClass - rspec-set works with ActiveRecord models only
let(:alert) { build(:alerting_alert, project: nil, payload: payload) }
it { is_expected.not_to be_valid }
end
context 'without starts_at' do
before do
payload['startsAt'] = nil
end
it { is_expected.not_to be_valid }
end
end
end
Loading
Loading
@@ -18,7 +18,7 @@ describe Gitlab::Ci::Build::Rules::Rule::Clause::Exists do
 
before do
stub_const('Gitlab::Ci::Build::Rules::Rule::Clause::Exists::MAX_PATTERN_COMPARISONS', 2)
expect(File).to receive(:fnmatch?).exactly(2).times.and_call_original
expect(File).to receive(:fnmatch?).twice.and_call_original
end
 
it { is_expected.to be_truthy }
Loading
Loading
Loading
Loading
@@ -12,7 +12,7 @@ describe Gitlab::Ci::Trace::ChunkedIO, :clean_gitlab_redis_cache do
stub_feature_flags(ci_enable_live_trace: true)
end
 
context "#initialize" do
describe "#initialize" do
context 'when a chunk exists' do
before do
build.trace.set('ABC')
Loading
Loading
@@ -35,7 +35,7 @@ describe Gitlab::Ci::Trace::ChunkedIO, :clean_gitlab_redis_cache do
end
end
 
context "#seek" do
describe "#seek" do
subject { chunked_io.seek(pos, where) }
 
before do
Loading
Loading
@@ -66,7 +66,7 @@ describe Gitlab::Ci::Trace::ChunkedIO, :clean_gitlab_redis_cache do
end
end
 
context "#eof?" do
describe "#eof?" do
subject { chunked_io.eof? }
 
before do
Loading
Loading
@@ -90,7 +90,7 @@ describe Gitlab::Ci::Trace::ChunkedIO, :clean_gitlab_redis_cache do
end
end
 
context "#each_line" do
describe "#each_line" do
let(:string_io) { StringIO.new(sample_trace_raw) }
 
context 'when buffer size is smaller than file size' do
Loading
Loading
@@ -134,7 +134,7 @@ describe Gitlab::Ci::Trace::ChunkedIO, :clean_gitlab_redis_cache do
end
end
 
context "#read" do
describe "#read" do
subject { chunked_io.read(length) }
 
context 'when read the whole size' do
Loading
Loading
@@ -254,7 +254,7 @@ describe Gitlab::Ci::Trace::ChunkedIO, :clean_gitlab_redis_cache do
end
end
 
context "#readline" do
describe "#readline" do
subject { chunked_io.readline }
 
let(:string_io) { StringIO.new(sample_trace_raw) }
Loading
Loading
@@ -334,7 +334,7 @@ describe Gitlab::Ci::Trace::ChunkedIO, :clean_gitlab_redis_cache do
end
end
 
context "#write" do
describe "#write" do
subject { chunked_io.write(data) }
 
let(:data) { sample_trace_raw }
Loading
Loading
@@ -399,7 +399,7 @@ describe Gitlab::Ci::Trace::ChunkedIO, :clean_gitlab_redis_cache do
end
end
 
context "#truncate" do
describe "#truncate" do
let(:offset) { 10 }
 
context 'when data does not exist' do
Loading
Loading
@@ -432,7 +432,7 @@ describe Gitlab::Ci::Trace::ChunkedIO, :clean_gitlab_redis_cache do
end
end
 
context "#destroy!" do
describe "#destroy!" do
subject { chunked_io.destroy! }
 
before do
Loading
Loading
Loading
Loading
@@ -74,7 +74,7 @@ describe Gitlab::Ci::Trace::SectionParser do
let(:lines) { build_lines(trace) }
 
it 'must handle correctly byte positioning' do
expect(subject).to receive(:find_next_marker).exactly(2).times.and_call_original
expect(subject).to receive(:find_next_marker).twice.and_call_original
 
subject.parse!
 
Loading
Loading
Loading
Loading
@@ -8,8 +8,8 @@ describe Gitlab::Cleanup::ProjectUploads do
let(:logger) { double(:logger) }
 
before do
allow(logger).to receive(:info).at_least(1).times
allow(logger).to receive(:debug).at_least(1).times
allow(logger).to receive(:info).at_least(:once)
allow(logger).to receive(:debug).at_least(:once)
end
 
describe '#run!' do
Loading
Loading
Loading
Loading
@@ -19,7 +19,7 @@ describe Gitlab::ContentSecurityPolicy::ConfigLoader do
}
end
 
context '.default_settings_hash' do
describe '.default_settings_hash' do
it 'returns empty defaults' do
settings = described_class.default_settings_hash
 
Loading
Loading
@@ -33,7 +33,7 @@ describe Gitlab::ContentSecurityPolicy::ConfigLoader do
end
end
 
context '#load' do
describe '#load' do
subject { described_class.new(csp_config[:directives]) }
 
def expected_config(directive)
Loading
Loading
Loading
Loading
@@ -176,7 +176,7 @@ describe Gitlab::Danger::Teammate do
 
it 'returns true if request fails' do
expect(Gitlab::Danger::RequestHelper).to receive(:http_get_json)
.exactly(2).times
.twice
.and_raise(Gitlab::Danger::RequestHelper::HTTPError.new)
 
expect(subject.available?).to be true
Loading
Loading
Loading
Loading
@@ -10,7 +10,7 @@ describe Gitlab::Database::Count do
 
let(:models) { [Project, Identity] }
 
context '.approximate_counts' do
describe '.approximate_counts' do
context 'fallbacks' do
subject { described_class.approximate_counts(models, strategies: strategies) }
 
Loading
Loading
Loading
Loading
@@ -31,7 +31,7 @@ describe Gitlab::Git::RuggedImpl::UseRugged, :seed_helper do
Gitlab::GitalyClient.instance_variable_set(:@can_use_disk, {})
end
 
context '#execute_rugged_call', :request_store do
describe '#execute_rugged_call', :request_store do
let(:args) { ['refs/heads/master', 1] }
 
before do
Loading
Loading
Loading
Loading
@@ -757,7 +757,7 @@ describe Gitlab::GitAccess do
allow(project).to receive(:lfs_enabled?).and_return(true)
 
expect_next_instance_of(Gitlab::Checks::LfsIntegrity) do |instance|
expect(instance).to receive(:objects_missing?).exactly(1).times
expect(instance).to receive(:objects_missing?).once
end
 
push_access_check
Loading
Loading
Loading
Loading
@@ -5,7 +5,7 @@ require 'spec_helper'
describe Gitlab::GitRefValidator do
using RSpec::Parameterized::TableSyntax
 
context '.validate' do
describe '.validate' do
it { expect(described_class.validate('feature/new')).to be true }
it { expect(described_class.validate('implement_@all')).to be true }
it { expect(described_class.validate('my_new_feature')).to be true }
Loading
Loading
@@ -37,7 +37,7 @@ describe Gitlab::GitRefValidator do
it { expect(described_class.validate("\xA0\u0000\xB0")).to be false }
end
 
context '.validate_merge_request_branch' do
describe '.validate_merge_request_branch' do
it { expect(described_class.validate_merge_request_branch('HEAD')).to be true }
it { expect(described_class.validate_merge_request_branch('feature/new')).to be true }
it { expect(described_class.validate_merge_request_branch('implement_@all')).to be true }
Loading
Loading
Loading
Loading
@@ -215,8 +215,8 @@ describe Gitlab::Gpg do
end
 
it 'tries at least 2 times to remove the tmp dir before raising', :aggregate_failures do
expect(Retriable).to receive(:sleep).at_least(2).times
expect(FileUtils).to receive(:remove_entry).with(tmp_dir).at_least(2).times.and_raise('Deletion failed')
expect(Retriable).to receive(:sleep).at_least(:twice)
expect(FileUtils).to receive(:remove_entry).with(tmp_dir).at_least(:twice).and_raise('Deletion failed')
 
expect { described_class.using_tmp_keychain { } }.to raise_error(described_class::CleanupError)
end
Loading
Loading
Loading
Loading
@@ -205,7 +205,7 @@ describe Gitlab::LegacyGithubImport::Importer do
let(:gh_pull_request) { Gitlab::LegacyGithubImport::PullRequestFormatter.new(project, closed_pull_request) }
 
it 'does remove branches' do
expect(subject).to receive(:remove_branch).at_least(2).times
expect(subject).to receive(:remove_branch).at_least(:twice)
subject.send(:clean_up_restored_branches, gh_pull_request)
end
end
Loading
Loading
Loading
Loading
@@ -8,7 +8,7 @@ describe Gitlab::PrivateCommitEmail do
let(:valid_email) { "#{id}-foo@#{hostname}" }
let(:invalid_email) { "#{id}-foo@users.noreply.bar.com" }
 
context '.regex' do
describe '.regex' do
subject { described_class.regex }
 
it { is_expected.to match("1-foo@#{hostname}") }
Loading
Loading
@@ -18,7 +18,7 @@ describe Gitlab::PrivateCommitEmail do
it { is_expected.not_to match('foobar@gitlab.com') }
end
 
context '.user_id_for_email' do
describe '.user_id_for_email' do
it 'parses user id from email' do
expect(described_class.user_id_for_email(valid_email)).to eq(id)
end
Loading
Loading
@@ -28,7 +28,7 @@ describe Gitlab::PrivateCommitEmail do
end
end
 
context '.user_ids_for_email' do
describe '.user_ids_for_email' do
it 'returns deduplicated user IDs for each valid email' do
result = described_class.user_ids_for_emails([valid_email, valid_email, invalid_email])
 
Loading
Loading
@@ -41,7 +41,7 @@ describe Gitlab::PrivateCommitEmail do
end
end
 
context '.for_user' do
describe '.for_user' do
it 'returns email in the format id-username@hostname' do
user = create(:user)
 
Loading
Loading
Loading
Loading
@@ -15,7 +15,7 @@ describe Gitlab::RuggedInstrumentation, :request_store do
end
end
 
context '.increment_query_count' do
describe '.increment_query_count' do
it 'tracks query counts' do
expect(subject.query_count).to eq(0)
 
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment