Use Rails.root for CommonMetricsImporter

This commit is contained in:
Kamil Trzciński 2018-09-11 10:00:05 +02:00
parent b9ea4e35ac
commit fe8b842a75
2 changed files with 12 additions and 2 deletions

View file

@ -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

View file

@ -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