summaryrefslogtreecommitdiff
path: root/spec/lib
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-02-07 15:09:52 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-02-07 15:09:52 +0000
commite43077ab4742ba5083a01a1e5341db1a1b7a1701 (patch)
treec33a00fb176caff735243c484bbd594a3b08bb6e /spec/lib
parent211a8c3361ccf4eb92f36edbdcf15c98fcdcc8b7 (diff)
downloadgitlab-ce-e43077ab4742ba5083a01a1e5341db1a1b7a1701.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib')
-rw-r--r--spec/lib/gitlab/background_migration/activate_prometheus_services_for_shared_cluster_applications_spec.rb75
-rw-r--r--spec/lib/gitlab/error_tracking_spec.rb11
-rw-r--r--spec/lib/gitlab/user_access_spec.rb2
3 files changed, 12 insertions, 76 deletions
diff --git a/spec/lib/gitlab/background_migration/activate_prometheus_services_for_shared_cluster_applications_spec.rb b/spec/lib/gitlab/background_migration/activate_prometheus_services_for_shared_cluster_applications_spec.rb
deleted file mode 100644
index 0edf87e1354..00000000000
--- a/spec/lib/gitlab/background_migration/activate_prometheus_services_for_shared_cluster_applications_spec.rb
+++ /dev/null
@@ -1,75 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-describe Gitlab::BackgroundMigration::ActivatePrometheusServicesForSharedClusterApplications, :migration, schema: 2020_01_14_113341 do
- include MigrationHelpers::PrometheusServiceHelpers
-
- let(:namespaces) { table(:namespaces) }
- let(:projects) { table(:projects) }
- let(:services) { table(:services) }
- let(:namespace) { namespaces.create(name: 'user', path: 'user') }
- let(:project) { projects.create(namespace_id: namespace.id) }
-
- let(:columns) do
- %w(project_id active properties type template push_events
- issues_events merge_requests_events tag_push_events
- note_events category default wiki_page_events pipeline_events
- confidential_issues_events commit_events job_events
- confidential_note_events deployment_events)
- end
-
- describe '#perform' do
- it 'is idempotent' do
- expect { subject.perform(project.id) }.to change { services.order(:id).map { |row| row.attributes } }
-
- expect { subject.perform(project.id) }.not_to change { services.order(:id).map { |row| row.attributes } }
- end
-
- context 'non prometheus services' do
- it 'does not change them' do
- other_type = 'SomeOtherService'
- services.create(service_params_for(project.id, active: true, type: other_type))
-
- expect { subject.perform(project.id) }.not_to change { services.where(type: other_type).order(:id).map { |row| row.attributes } }
- end
- end
-
- context 'prometheus services are configured manually ' do
- it 'does not change them' do
- properties = '{"api_url":"http://test.dev","manual_configuration":"1"}'
- services.create(service_params_for(project.id, properties: properties, active: false))
-
- expect { subject.perform(project.id) }.not_to change { services.order(:id).map { |row| row.attributes } }
- end
- end
-
- context 'prometheus integration services do not exist' do
- it 'creates missing services entries' do
- subject.perform(project.id)
-
- rows = services.order(:id).map { |row| row.attributes.slice(*columns).symbolize_keys }
-
- expect([service_params_for(project.id, active: true)]).to eq rows
- end
- end
-
- context 'prometheus integration services exist' do
- context 'in active state' do
- it 'does not change them' do
- services.create(service_params_for(project.id, active: true))
-
- expect { subject.perform(project.id) }.not_to change { services.order(:id).map { |row| row.attributes } }
- end
- end
-
- context 'not in active state' do
- it 'sets active attribute to true' do
- service = services.create(service_params_for(project.id))
-
- expect { subject.perform(project.id) }.to change { service.reload.active? }.from(false).to(true)
- end
- end
- end
- end
-end
diff --git a/spec/lib/gitlab/error_tracking_spec.rb b/spec/lib/gitlab/error_tracking_spec.rb
index 08718bc92a1..6764d48d14b 100644
--- a/spec/lib/gitlab/error_tracking_spec.rb
+++ b/spec/lib/gitlab/error_tracking_spec.rb
@@ -145,6 +145,17 @@ describe Gitlab::ErrorTracking do
)
end
+ context 'with filterable parameters' do
+ let(:extra) { { test: 1, my_token: 'test' } }
+
+ it 'filters parameters' do
+ expect(Gitlab::ErrorTracking::Logger).to receive(:error).with(
+ hash_including({ 'extra.test' => 1, 'extra.my_token' => '[FILTERED]' }))
+
+ described_class.track_exception(exception, extra)
+ end
+ end
+
context 'the exception implements :sentry_extra_data' do
let(:extra_info) { { event: 'explosion', size: :massive } }
let(:exception) { double(message: 'bang!', sentry_extra_data: extra_info, backtrace: caller) }
diff --git a/spec/lib/gitlab/user_access_spec.rb b/spec/lib/gitlab/user_access_spec.rb
index 4e7c43a6856..2f4ab2e71db 100644
--- a/spec/lib/gitlab/user_access_spec.rb
+++ b/spec/lib/gitlab/user_access_spec.rb
@@ -160,7 +160,7 @@ describe Gitlab::UserAccess do
expect(access.can_push_to_branch?('master')).to be_falsey
end
- it 'does not allow the user to push if he does not have push access to the canonical project' do
+ it 'does not allow the user to push if they do not have push access to the canonical project' do
canonical_project.add_guest(user)
expect(access.can_push_to_branch?('awesome-feature')).to be_falsey