Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 1 addition & 5 deletions lib/multidb/model_extensions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/multidb/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Multidb
VERSION = '0.8.0'
VERSION = '0.8.1'
end
12 changes: 8 additions & 4 deletions spec/lib/multidb/log_subscriber_extension_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down