2020-02-24 19:09:12 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module MetricsDashboardUrlHelpers
|
|
|
|
# Using the url_helpers available in the test suite uses
|
|
|
|
# the sample host, but the urls generated may need to
|
|
|
|
# point to the configured host in the :js trait
|
|
|
|
def urls
|
|
|
|
::Gitlab::Routing.url_helpers
|
|
|
|
end
|
|
|
|
|
|
|
|
def clear_host_from_memoized_variables
|
2020-02-25 01:09:07 -05:00
|
|
|
[:metrics_regex, :grafana_regex, :clusters_regex, :alert_regex].each do |method_name|
|
2020-02-24 19:09:12 -05:00
|
|
|
Gitlab::Metrics::Dashboard::Url.clear_memoization(method_name)
|
|
|
|
end
|
|
|
|
end
|
2020-07-31 20:09:45 -04:00
|
|
|
|
|
|
|
def stub_gitlab_domain
|
|
|
|
allow_any_instance_of(Banzai::Filter::InlineEmbedsFilter)
|
|
|
|
.to receive(:gitlab_domain)
|
|
|
|
.and_return(urls.root_url.chomp('/'))
|
|
|
|
|
|
|
|
allow(Gitlab::Metrics::Dashboard::Url)
|
|
|
|
.to receive(:gitlab_domain)
|
|
|
|
.and_return(urls.root_url.chomp('/'))
|
|
|
|
end
|
2020-02-24 19:09:12 -05:00
|
|
|
end
|