diff options
Diffstat (limited to 'spec/lib/gitlab/metrics/dashboard/processor_spec.rb')
-rw-r--r-- | spec/lib/gitlab/metrics/dashboard/processor_spec.rb | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/spec/lib/gitlab/metrics/dashboard/processor_spec.rb b/spec/lib/gitlab/metrics/dashboard/processor_spec.rb index b2fca0b5954..7250cefb9ff 100644 --- a/spec/lib/gitlab/metrics/dashboard/processor_spec.rb +++ b/spec/lib/gitlab/metrics/dashboard/processor_spec.rb @@ -16,7 +16,8 @@ describe Gitlab::Metrics::Dashboard::Processor do Gitlab::Metrics::Dashboard::Stages::EndpointInserter, Gitlab::Metrics::Dashboard::Stages::Sorter, Gitlab::Metrics::Dashboard::Stages::AlertsInserter, - Gitlab::Metrics::Dashboard::Stages::PanelIdsInserter + Gitlab::Metrics::Dashboard::Stages::PanelIdsInserter, + Gitlab::Metrics::Dashboard::Stages::UrlValidator ] end @@ -201,6 +202,27 @@ describe Gitlab::Metrics::Dashboard::Processor do it_behaves_like 'errors with message', 'Each "metric" must define one of :query or :query_range' end + + describe 'validating links' do + context 'when the links contain a blocked url' do + let(:dashboard_yml_links) do + [{ 'url' => 'http://1.1.1.1.1' }, { 'url' => 'https://gitlab.com' }] + end + + let(:expected) do + [{ url: '' }, { url: 'https://gitlab.com' }] + end + + before do + stub_env('RSPEC_ALLOW_INVALID_URLS', 'false') + dashboard_yml['links'] = dashboard_yml_links + end + + it 'replaces the blocked url with an empty string' do + expect(dashboard[:links]).to eq(expected) + end + end + end end private |