Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support nil logger #39

Merged
merged 6 commits into from
Sep 28, 2024
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
2 changes: 1 addition & 1 deletion lib/action_cable/subscription_adapter/solid_cable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def broadcast_messages
end

def with_polling_volume
navidemad marked this conversation as resolved.
Show resolved Hide resolved
if ::SolidCable.silence_polling?
if ::SolidCable.silence_polling? && ActiveRecord::Base.logger
navidemad marked this conversation as resolved.
Show resolved Hide resolved
ActiveRecord::Base.logger.silence { yield }
else
yield
Expand Down
Binary file added test/dummy/solid_cable_test-shm
Binary file not shown.
Empty file added test/dummy/solid_cable_test-wal
Empty file.
20 changes: 20 additions & 0 deletions test/lib/action_cable/subscription_adapter/solid_cable_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,18 @@ class ActionCable::SubscriptionAdapter::SolidCableTest < ActionCable::TestCase
end
end

test "does not raise error when polling with no Active Record logger" do
with_active_record_logger(nil) do
assert_nothing_raised do
subscribe_as_queue("channel") do |queue|
@tx_adapter.broadcast("channel", "hello world")

assert_equal "hello world", queue.pop
end
end
end
end

private
def cable_config
{ adapter: "solid_cable", message_retention: "1.second",
Expand All @@ -159,4 +171,12 @@ def subscribe_as_queue(channel, adapter = @rx_adapter)
ensure
adapter.unsubscribe(channel, callback) if subscribed.set?
end

def with_active_record_logger(logger)
old_logger = ActiveRecord::Base.logger
ActiveRecord::Base.logger = logger
yield
ensure
ActiveRecord::Base.logger = old_logger
end
end