diff options
-rw-r--r-- | db/importers/common_metrics_importer.rb | 4 | ||||
-rw-r--r-- | spec/db/importers/common_metrics_importer_spec.rb | 10 |
2 files changed, 12 insertions, 2 deletions
diff --git a/db/importers/common_metrics_importer.rb b/db/importers/common_metrics_importer.rb index 01fbbd6866b..6302394d7a6 100644 --- a/db/importers/common_metrics_importer.rb +++ b/db/importers/common_metrics_importer.rb @@ -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 diff --git a/spec/db/importers/common_metrics_importer_spec.rb b/spec/db/importers/common_metrics_importer_spec.rb index 16b59e1dfe8..68260820958 100644 --- a/spec/db/importers/common_metrics_importer_spec.rb +++ b/spec/db/importers/common_metrics_importer_spec.rb @@ -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 |