Skip to content

Commit 118c41b

Browse files
committed
Implement UntenantedConnectionPool#size
so the mock object can be inspected for that config param.
1 parent 7f1790f commit 118c41b

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## next / unreleased
44

5-
### Changed
5+
### Breaking change: Rake tasks
66

77
Some rake task changes to rename tasks for the database name (like Rails does it):
88

@@ -24,6 +24,11 @@ Some additional changes:
2424
- `ActiveRecord::Tenanted.base_configs` is a new utility method that returns all the tenanted base configs for the current environment.
2525

2626

27+
### Added
28+
29+
- `UntenantedConnectionPool#size` returns the database configuration's `max_connections` value, so that code (like Solid Queue) can inspect config params without a tenant context.
30+
31+
2732
## v0.5.0 / 2025-10-12
2833

2934
### Fixed

lib/active_record/tenanted/untenanted_connection_pool.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ def schema_cache
2828
ActiveRecord::ConnectionAdapters::BoundSchemaReflection.new(schema_reflection, self)
2929
end
3030

31+
def size
32+
db_config.max_connections
33+
end
34+
3135
def lease_connection(...)
3236
raise Tenanted::NoTenantError, "Cannot connect to a tenanted database while untenanted (#{@model})."
3337
end

test/unit/untenanted_connection_pool_test.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,10 @@
1919
assert_equal("Cannot connect to a tenanted database while untenanted (User).", e.message)
2020
end
2121
end
22+
23+
test "size returns max_connections from db_config" do
24+
def config.max_connections; 42; end
25+
assert_equal 42, subject.size
26+
end
2227
end
2328
end

0 commit comments

Comments
 (0)