diff options
Diffstat (limited to 'spec/lib')
-rw-r--r-- | spec/lib/feature/gitaly_spec.rb | 18 | ||||
-rw-r--r-- | spec/lib/gitlab/metrics/dashboard/url_spec.rb | 42 |
2 files changed, 10 insertions, 50 deletions
diff --git a/spec/lib/feature/gitaly_spec.rb b/spec/lib/feature/gitaly_spec.rb index 4e07acf9c1a..afb522d05e1 100644 --- a/spec/lib/feature/gitaly_spec.rb +++ b/spec/lib/feature/gitaly_spec.rb @@ -5,10 +5,6 @@ require 'spec_helper' describe Feature::Gitaly do let(:feature_flag) { "mep_mep" } - before do - stub_const("#{described_class}::SERVER_FEATURE_FLAGS", [feature_flag]) - end - describe ".enabled?" do context 'when the gate is closed' do before do @@ -28,15 +24,13 @@ describe Feature::Gitaly do end describe ".server_feature_flags" do - context 'when one flag is disabled' do - before do - stub_feature_flags(gitaly_mep_mep: false) - end + before do + allow(Feature).to receive(:persisted_names).and_return(%w[gitaly_mep_mep foo]) + end - subject { described_class.server_feature_flags } + subject { described_class.server_feature_flags } - it { is_expected.to be_a(Hash) } - it { is_expected.to eq("gitaly-feature-mep-mep" => "false") } - end + it { is_expected.to be_a(Hash) } + it { is_expected.to eq("gitaly-feature-mep-mep" => "true") } end end diff --git a/spec/lib/gitlab/metrics/dashboard/url_spec.rb b/spec/lib/gitlab/metrics/dashboard/url_spec.rb index daaf66cba46..d98aa5e3697 100644 --- a/spec/lib/gitlab/metrics/dashboard/url_spec.rb +++ b/spec/lib/gitlab/metrics/dashboard/url_spec.rb @@ -3,38 +3,6 @@ require 'spec_helper' describe Gitlab::Metrics::Dashboard::Url do - shared_examples_for 'a regex which matches the expected url' 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 - end - - shared_examples_for 'does not match non-matching urls' do - 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 - describe '#regex' do let(:url) do Gitlab::Routing.url_helpers.metrics_namespace_project_environment_url( @@ -59,10 +27,9 @@ describe Gitlab::Metrics::Dashboard::Url do } end - subject { described_class.regex } + subject { described_class.metrics_regex } - it_behaves_like 'a regex which matches the expected url' - it_behaves_like 'does not match non-matching urls' + it_behaves_like 'regex which matches url when expected' end describe '#grafana_regex' do @@ -89,15 +56,14 @@ describe Gitlab::Metrics::Dashboard::Url do subject { described_class.grafana_regex } - it_behaves_like 'a regex which matches the expected url' - it_behaves_like 'does not match non-matching urls' + it_behaves_like 'regex which matches url when expected' end describe '#build_dashboard_url' do it 'builds the url for the dashboard endpoint' do url = described_class.build_dashboard_url('foo', 'bar', 1) - expect(url).to match described_class.regex + expect(url).to match described_class.metrics_regex end end end |