Commit e21f171d authored by Grzegorz Bizon's avatar Grzegorz Bizon

Merge branch '51333-use-rails-root-for-common-metrics-importer' into 'master'

Use Rails.root for CommonMetricsImporter

Closes #51333

See merge request gitlab-org/gitlab-ce!21664
parents e68ebdfb fe8b842a
......@@ -35,8 +35,8 @@ module Importers
attr_reader :content
def initialize(file = 'config/prometheus/common_metrics.yml')
@content = YAML.load_file(file)
def initialize(filename = 'common_metrics.yml')
@content = YAML.load_file(Rails.root.join('config', 'prometheus', filename))
end
def execute
......
......@@ -47,6 +47,16 @@ describe Importers::CommonMetricsImporter do
end
end
context "does import common_metrics.yml" do
it "when executed from outside of the Rails.root" do
Dir.chdir(Dir.tmpdir) do
expect { subject.execute }.not_to raise_error
end
expect(PrometheusMetric.common).not_to be_empty
end
end
context 'does import properly all fields' do
let(:query_identifier) { 'response-metric' }
let(:group) do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment