From 51f153ddfecd7e9defa93e6c653de7d2dc93b8d9 Mon Sep 17 00:00:00 2001 From: Edward Rudd Date: Fri, 13 Jun 2025 09:30:39 -0400 Subject: [PATCH 1/3] fix: Correct LogSubscriber stub to ensure we are sending "options" as the last parameter --- CHANGELOG.md | 4 ++++ spec/lib/multidb/log_subscriber_extension_spec.rb | 12 ++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c0b09a..dbbc125 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ 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" + ## [0.8.0] ### Changed - dropped support for Ruby < 3.0 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 From 8c9d9d47b13d6a96ec976228bbfee955ec57351e Mon Sep 17 00:00:00 2001 From: Edward Rudd Date: Fri, 13 Jun 2025 09:56:02 -0400 Subject: [PATCH 2/3] feat: remove no longer needed code-path for old (<6.1) rails versions --- CHANGELOG.md | 1 + lib/multidb/model_extensions.rb | 6 +----- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dbbc125..5d6f40a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [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 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 From 411930acfc70a859d44758ff9d1221c176f2039f Mon Sep 17 00:00:00 2001 From: Edward Rudd Date: Fri, 13 Jun 2025 09:36:04 -0400 Subject: [PATCH 3/3] release: version 0.8.1 --- lib/multidb/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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