Skip to content

Commit

Permalink
Merge pull request #1268 from senid231/fix-pgc-config-yaml-ruby3
Browse files Browse the repository at this point in the history
fix PgqConfig
  • Loading branch information
dmitry-sinina authored Apr 12, 2023
2 parents 138f681 + 2a61f59 commit bf8b3e1
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pgq-processors/pgq_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def initialize(config_file, section)
end

def config
@config ||= YAML.safe_load(File.read(config_file), [Symbol])[section]
@config ||= YAML.safe_load(File.read(config_file), permitted_classes: [Symbol])[section]
if @config.blank?
raise "Invalid configuration file #{config_file} or section #{section} is not exists."
end
Expand Down
6 changes: 6 additions & 0 deletions pgq-processors/spec/fixtures/yaml/test_config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
some:
mode: production
:foo: bar
another:
qwe: 1
bar: baz
20 changes: 20 additions & 0 deletions pgq-processors/spec/pgq_config_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# frozen_string_literal: true

require_relative '../pgq_config'

RSpec.describe PgqConfig do
subject do
described_class.new(config_file, section)
end

let(:config_file) { File.expand_path('fixtures/yaml/test_config.yml', __dir__) }
let(:section) { 'some' }

it 'does not raise error' do
expect { subject }.not_to raise_error
end

it 'has correct config' do
expect(subject.config).to be_kind_of(Hash)
end
end

0 comments on commit bf8b3e1

Please sign in to comment.