diff --git a/.rubocop.yml b/.rubocop.yml index bcb8e00..3cebf67 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -15,6 +15,7 @@ Style/DotPosition: {EnforcedStyle: trailing} Style/FirstParameterIndentation: {EnforcedStyle: consistent} Style/IfUnlessModifier: {Enabled: false} Style/ModuleFunction: {Enabled: false} +Style/MultilineMethodCallIndentation: {EnforcedStyle: indented} Style/MultilineOperationIndentation: {EnforcedStyle: indented} Style/NestedParenthesizedCalls: {Enabled: false} Style/PredicateName: {Enabled: false} diff --git a/CHANGELOG.md b/CHANGELOG.md index b9fa267..2e9f525 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ +# 0.11.2 + +- Rails 5.1 deep symbolized secrets support. + # 0.11.1 -# Fixed poller for typed response. +- Fixed poller for typed response. # 0.11.0 diff --git a/lib/telegram/bot/config_methods.rb b/lib/telegram/bot/config_methods.rb index 5712410..d2f1f73 100644 --- a/lib/telegram/bot/config_methods.rb +++ b/lib/telegram/bot/config_methods.rb @@ -1,5 +1,6 @@ require 'active_support/core_ext/hash/keys' require 'active_support/core_ext/hash/transform_values' +require 'active_support/core_ext/hash/indifferent_access' module Telegram module Bot @@ -48,9 +49,10 @@ module Telegram def bots_config @bots_config ||= if defined?(Rails.application) - telegram_config = Rails.application.secrets[:telegram] || {} - (telegram_config['bots'] || {}).symbolize_keys.tap do |config| - default = telegram_config['bot'] + secrets = Rails.application.secrets. + fetch(:telegram, {}).with_indifferent_access + secrets.fetch(:bots, {}).symbolize_keys.tap do |config| + default = secrets[:bot] config[:default] = default if default end else diff --git a/lib/telegram/bot/version.rb b/lib/telegram/bot/version.rb index 3a177f5..29b49fa 100644 --- a/lib/telegram/bot/version.rb +++ b/lib/telegram/bot/version.rb @@ -1,6 +1,6 @@ module Telegram module Bot - VERSION = '0.11.1'.freeze + VERSION = '0.11.2'.freeze def self.gem_version Gem::Version.new VERSION diff --git a/spec/telegram/bot/config_methods_spec.rb b/spec/telegram/bot/config_methods_spec.rb index f806896..2657750 100644 --- a/spec/telegram/bot/config_methods_spec.rb +++ b/spec/telegram/bot/config_methods_spec.rb @@ -87,6 +87,12 @@ RSpec.describe Telegram::Bot::ConfigMethods do end it { should include default: config[:bot] } it { should include config[:bots] } + + context 'on rails >5.1 (deep symbolized keys)' do + let(:secrets) { {telegram: config.deep_symbolize_keys} } + it { should include default: config[:bot] } + it { should include config[:bots] } + end end end end