diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c0b09a..5d6f40a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html) +## [0.8.1] +### Changes +- Updated Log subscriber mixin to utilize Rails 7.1's contract for "color" +- Removed old backward compat path for Rails < 6.1 + ## [0.8.0] ### Changed - dropped support for Ruby < 3.0 diff --git a/lib/multidb/model_extensions.rb b/lib/multidb/model_extensions.rb index b2ab5b7..b91c51b 100644 --- a/lib/multidb/model_extensions.rb +++ b/lib/multidb/model_extensions.rb @@ -6,11 +6,7 @@ module Multidb module Connection def establish_connection(spec = nil) super(spec) - config = if connection_pool.respond_to?(:db_config) - connection_pool.db_config.configuration_hash - else - connection_pool.spec.config - end + config = connection_pool.db_config.configuration_hash Multidb.init(config) end diff --git a/lib/multidb/version.rb b/lib/multidb/version.rb index b56e653..4dde8aa 100644 --- a/lib/multidb/version.rb +++ b/lib/multidb/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Multidb - VERSION = '0.8.0' + VERSION = '0.8.1' end diff --git a/spec/lib/multidb/log_subscriber_extension_spec.rb b/spec/lib/multidb/log_subscriber_extension_spec.rb index de91c35..29a59b7 100644 --- a/spec/lib/multidb/log_subscriber_extension_spec.rb +++ b/spec/lib/multidb/log_subscriber_extension_spec.rb @@ -17,8 +17,12 @@ def debug(msg) msg end - def color(text, _color, _bold) - text + def color(text, color, options = {}) + if options[:bold] + "Bold: Color #{color}: #{text}" + else + "Color #{color}: #{text}" + end end end @@ -65,13 +69,13 @@ def color(text, _color, _bold) subject { instance.debug('message') } it 'prepends the db name to the message' do - is_expected.to include('[DB: default]') + is_expected.to start_with "Bold: Color \e[32m: [DB: default]" end context 'when a replica is active' do it 'prepends the replica dbname to the message' do Multidb.use(:replica1) { - is_expected.to include('[DB: replica1') + is_expected.to start_with "Bold: Color \e[32m: [DB: replica1" } end end