diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-12 15:09:01 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-12 15:09:01 +0300 |
commit | bd497e352ebd279536ae11855871162e82a3f88c (patch) | |
tree | 2241444d4be33e199d7011b872713071a8f8cd41 /spec/support | |
parent | 0388886f9439fa93efea29a159522aec5643f7c8 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/support')
-rw-r--r-- | spec/support/shared_examples/metrics/url_shared_examples.rb | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/spec/support/shared_examples/metrics/url_shared_examples.rb b/spec/support/shared_examples/metrics/url_shared_examples.rb new file mode 100644 index 00000000000..67742aecb87 --- /dev/null +++ b/spec/support/shared_examples/metrics/url_shared_examples.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +RSpec.shared_examples 'regex which matches url when expected' do + it { is_expected.to be_a Regexp } + + it 'matches a metrics dashboard link with named params' do + expect(subject).to match url + + subject.match(url) do |m| + expect(m.named_captures).to eq expected_params + end + end + + it 'does not match other gitlab urls that contain the term metrics' do + url = Gitlab::Routing.url_helpers.active_common_namespace_project_prometheus_metrics_url('foo', 'bar', :json) + + expect(subject).not_to match url + end + + it 'does not match other gitlab urls' do + url = Gitlab.config.gitlab.url + + expect(subject).not_to match url + end + + it 'does not match non-gitlab urls' do + url = 'https://www.super_awesome_site.com/' + + expect(subject).not_to match url + end +end |