Skip to content

Commit

Permalink
Remove #children fron BaseEvent
Browse files Browse the repository at this point in the history
`#children` has been deprecated as of Rails 7.2.

rails/rails#43390

Unlike Rails, I decided to remove `#children` from `BaseEvent`
since it'd be a techdebt to keep this method in the future,
and I guess this method would not be used very well.

By the way, I found this deprecation on Rails when I'm about to
add the support for `deprecation.rails` on #89. I hope this won't cause
problems for users who use this gem.
  • Loading branch information
yykamei committed Apr 4, 2022
1 parent a72587a commit eaa2c7f
Show file tree
Hide file tree
Showing 53 changed files with 54 additions and 328 deletions.
5 changes: 2 additions & 3 deletions lib/rails_band/base_event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module RailsBand
# The base class of each Event class.
class BaseEvent
attr_reader :name, :time, :end, :transaction_id, :children,
attr_reader :name, :time, :end, :transaction_id,
:cpu_time, :idle_time, :allocations, :duration

# @param event [ActiveSupport::Notifications::Event]
Expand All @@ -13,7 +13,6 @@ def initialize(event)
@time = event.time
@end = event.end
@transaction_id = event.transaction_id
@children = event.children
@cpu_time = event.cpu_time
@idle_time = event.idle_time
@allocations = event.allocations
Expand All @@ -22,7 +21,7 @@ def initialize(event)

def to_h
@to_h ||= {
name: @name, time: @time, end: @end, transaction_id: @transaction_id, children: @children,
name: @name, time: @time, end: @end, transaction_id: @transaction_id,
cpu_time: @cpu_time, idle_time: @idle_time, allocations: @allocations, duration: @duration
}.merge!(
public_methods(false).reject { |meth| non_hash_keys.include?(meth) }.each_with_object({}) do |meth, h|
Expand Down
8 changes: 1 addition & 7 deletions test/rails_band/action_cable/event/broadcast_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,6 @@ class BroadcastTest < ::ActionCable::Channel::TestCase
assert_instance_of String, @event.transaction_id
end

test 'returns children' do
subscribe number: '2'
perform :hello, { name: 'J' }
assert_instance_of Array, @event.children
end

test 'returns cpu_time' do
subscribe number: '2'
perform :hello, { name: 'J' }
Expand Down Expand Up @@ -69,7 +63,7 @@ class BroadcastTest < ::ActionCable::Channel::TestCase
test 'calls #to_h' do
subscribe number: '2'
perform :hello, { name: 'J' }
%i[name time end transaction_id children cpu_time idle_time allocations duration broadcasting message
%i[name time end transaction_id cpu_time idle_time allocations duration broadcasting message
coder].each do |key|
assert_includes @event.to_h, key
end
Expand Down
8 changes: 1 addition & 7 deletions test/rails_band/action_cable/event/perform_action_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,6 @@ class PerformActionTest < ::ActionCable::Channel::TestCase
assert_instance_of String, @event.transaction_id
end

test 'returns children' do
subscribe number: '2'
perform :hello, { name: 'J' }
assert_instance_of Array, @event.children
end

test 'returns cpu_time' do
subscribe number: '2'
perform :hello, { name: 'J' }
Expand Down Expand Up @@ -69,7 +63,7 @@ class PerformActionTest < ::ActionCable::Channel::TestCase
test 'calls #to_h' do
subscribe number: '2'
perform :hello, { name: 'J' }
%i[name time end transaction_id children cpu_time idle_time allocations duration
%i[name time end transaction_id cpu_time idle_time allocations duration
channel_class action data].each do |key|
assert_includes @event.to_h, key
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,6 @@ class TransmitSubscriptionConfirmationTest < ::ActionCable::Channel::TestCase
assert_instance_of String, @event.transaction_id
end

test 'returns children' do
subscribe number: '2'
perform :call_transmit, { name: 'J' }
assert_instance_of Array, @event.children
end

test 'returns cpu_time' do
subscribe number: '2'
perform :call_transmit, { name: 'J' }
Expand Down Expand Up @@ -69,7 +63,7 @@ class TransmitSubscriptionConfirmationTest < ::ActionCable::Channel::TestCase
test 'calls #to_h' do
subscribe number: '2'
perform :call_transmit, { name: 'J' }
%i[name time end transaction_id children cpu_time idle_time allocations duration channel_class].each do |key|
%i[name time end transaction_id cpu_time idle_time allocations duration channel_class].each do |key|
assert_includes @event.to_h, key
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@ class TransmitSubscriptionRejectionTest < ::ActionCable::Channel::TestCase
assert_instance_of String, @event.transaction_id
end

test 'returns children' do
subscribe number: '-3'
assert_instance_of Array, @event.children
end

test 'returns cpu_time' do
subscribe number: '-3'
assert_instance_of Float, @event.cpu_time
Expand All @@ -59,7 +54,7 @@ class TransmitSubscriptionRejectionTest < ::ActionCable::Channel::TestCase

test 'calls #to_h' do
subscribe number: '-3'
%i[name time end transaction_id children cpu_time idle_time allocations duration channel_class].each do |key|
%i[name time end transaction_id cpu_time idle_time allocations duration channel_class].each do |key|
assert_includes @event.to_h, key
end
end
Expand Down
9 changes: 1 addition & 8 deletions test/rails_band/action_cable/event/transmit_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,6 @@ class TransmitTest < ::ActionCable::Channel::TestCase
assert_instance_of String, @event.transaction_id
end

test 'returns children' do
subscribe number: '2'
perform :call_transmit, { name: 'J' }
assert_instance_of Array, @event.children
end

test 'returns cpu_time' do
subscribe number: '2'
perform :call_transmit, { name: 'J' }
Expand Down Expand Up @@ -69,8 +63,7 @@ class TransmitTest < ::ActionCable::Channel::TestCase
test 'calls #to_h' do
subscribe number: '2'
perform :call_transmit, { name: 'J' }
%i[name time end transaction_id children cpu_time idle_time allocations duration
channel_class data via].each do |key|
%i[name time end transaction_id cpu_time idle_time allocations duration channel_class data via].each do |key|
assert_includes @event.to_h, key
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@ class ExistFragmentTest < ActionDispatch::IntegrationTest
assert_instance_of String, @event.transaction_id
end

test 'returns children' do
get '/users'
assert_instance_of Array, @event.children
end

test 'returns cpu_time' do
get '/users'
assert_instance_of Float, @event.cpu_time
Expand All @@ -58,7 +53,7 @@ class ExistFragmentTest < ActionDispatch::IntegrationTest

test 'calls #to_h' do
get '/users'
%i[name time end transaction_id children cpu_time idle_time allocations duration key].each do |key|
%i[name time end transaction_id cpu_time idle_time allocations duration key].each do |key|
assert_includes @event.to_h, key
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@ class ExpireFragmentTest < ActionDispatch::IntegrationTest
assert_instance_of String, @event.transaction_id
end

test 'returns children' do
get '/users'
assert_instance_of Array, @event.children
end

test 'returns cpu_time' do
get '/users'
assert_instance_of Float, @event.cpu_time
Expand All @@ -58,7 +53,7 @@ class ExpireFragmentTest < ActionDispatch::IntegrationTest

test 'calls #to_h' do
get '/users'
%i[name time end transaction_id children cpu_time idle_time allocations duration key].each do |key|
%i[name time end transaction_id cpu_time idle_time allocations duration key].each do |key|
assert_includes @event.to_h, key
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@ class HaltedCallbackTest < ActionDispatch::IntegrationTest
assert_instance_of String, @event.transaction_id
end

test 'returns children' do
get '/users/123/callback'
assert_instance_of Array, @event.children
end

test 'returns cpu_time' do
get '/users/123/callback'
assert_instance_of Float, @event.cpu_time
Expand All @@ -57,7 +52,7 @@ class HaltedCallbackTest < ActionDispatch::IntegrationTest

test 'calls #to_h' do
get '/users/123/callback'
%i[name time end transaction_id children cpu_time idle_time allocations duration filter].each do |key|
%i[name time end transaction_id cpu_time idle_time allocations duration filter].each do |key|
assert_includes @event.to_h, key
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@ class ProcessActionTest < ActionDispatch::IntegrationTest
assert_instance_of String, @event.transaction_id
end

test 'returns children' do
get '/users'
assert_instance_of Array, @event.children
end

test 'returns cpu_time' do
get '/users'
assert_instance_of Float, @event.cpu_time
Expand All @@ -57,7 +52,7 @@ class ProcessActionTest < ActionDispatch::IntegrationTest

test 'calls #to_h' do
get '/users'
%i[name time end transaction_id children cpu_time idle_time allocations duration controller action params headers
%i[name time end transaction_id cpu_time idle_time allocations duration controller action params headers
format method path status view_runtime db_runtime].each do |key|
assert_includes @event.to_h, key
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@ class ReadFragmentTest < ActionDispatch::IntegrationTest
assert_instance_of String, @event.transaction_id
end

test 'returns children' do
get '/users'
assert_instance_of Array, @event.children
end

test 'returns cpu_time' do
get '/users'
assert_instance_of Float, @event.cpu_time
Expand All @@ -58,7 +53,7 @@ class ReadFragmentTest < ActionDispatch::IntegrationTest

test 'calls #to_h' do
get '/users'
%i[name time end transaction_id children cpu_time idle_time allocations duration key].each do |key|
%i[name time end transaction_id cpu_time idle_time allocations duration key].each do |key|
assert_includes @event.to_h, key
end
end
Expand Down
7 changes: 1 addition & 6 deletions test/rails_band/action_controller/event/redirect_to_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@ class RedirectToTest < ActionDispatch::IntegrationTest
assert_instance_of String, @event.transaction_id
end

test 'returns children' do
get '/users/123/redirect'
assert_instance_of Array, @event.children
end

test 'returns cpu_time' do
get '/users/123/redirect'
assert_instance_of Float, @event.cpu_time
Expand All @@ -58,7 +53,7 @@ class RedirectToTest < ActionDispatch::IntegrationTest

test 'calls #to_h' do
get '/users/123/redirect'
%i[name time end transaction_id children cpu_time idle_time allocations duration
%i[name time end transaction_id cpu_time idle_time allocations duration
status location].each do |key|
assert_includes @event.to_h, key
end
Expand Down
7 changes: 1 addition & 6 deletions test/rails_band/action_controller/event/send_data_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@ class SendDataTest < ActionDispatch::IntegrationTest
assert_instance_of String, @event.transaction_id
end

test 'returns children' do
get '/users/123/data'
assert_instance_of Array, @event.children
end

test 'returns cpu_time' do
get '/users/123/data'
assert_instance_of Float, @event.cpu_time
Expand All @@ -58,7 +53,7 @@ class SendDataTest < ActionDispatch::IntegrationTest

test 'calls #to_h' do
get '/users/123/data'
%i[name time end transaction_id children cpu_time idle_time allocations duration
%i[name time end transaction_id cpu_time idle_time allocations duration
filename type disposition status].each do |key|
assert_includes @event.to_h, key
end
Expand Down
7 changes: 1 addition & 6 deletions test/rails_band/action_controller/event/send_file_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@ class SendFileTest < ActionDispatch::IntegrationTest
assert_instance_of String, @event.transaction_id
end

test 'returns children' do
get '/users/123/file'
assert_instance_of Array, @event.children
end

test 'returns cpu_time' do
get '/users/123/file'
assert_instance_of Float, @event.cpu_time
Expand All @@ -58,7 +53,7 @@ class SendFileTest < ActionDispatch::IntegrationTest

test 'calls #to_h' do
get '/users/123/file'
%i[name time end transaction_id children cpu_time idle_time allocations duration
%i[name time end transaction_id cpu_time idle_time allocations duration
path filename type disposition status].each do |key|
assert_includes @event.to_h, key
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@ class StartProcessingTest < ActionDispatch::IntegrationTest
assert_instance_of String, @event.transaction_id
end

test 'returns children' do
get '/users'
assert_instance_of Array, @event.children
end

test 'returns cpu_time' do
get '/users'
assert_instance_of Float, @event.cpu_time
Expand All @@ -57,7 +52,7 @@ class StartProcessingTest < ActionDispatch::IntegrationTest

test 'calls #to_h' do
get '/users'
%i[name time end transaction_id children cpu_time idle_time allocations duration controller action params headers
%i[name time end transaction_id cpu_time idle_time allocations duration controller action params headers
format method path].each do |key|
assert_includes @event.to_h, key
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@ class UnpermittedParametersTest < ActionDispatch::IntegrationTest
assert_instance_of String, @event.transaction_id
end

test 'returns children' do
patch "/users/#{@user.id}", params: { name: 'foo!', nickname: 'F', login_shell: 'zsh' }
assert_instance_of Array, @event.children
end

test 'returns cpu_time' do
patch "/users/#{@user.id}", params: { name: 'foo!', nickname: 'F', login_shell: 'zsh' }
assert_instance_of Float, @event.cpu_time
Expand All @@ -58,7 +53,7 @@ class UnpermittedParametersTest < ActionDispatch::IntegrationTest

test 'calls #to_h' do
patch "/users/#{@user.id}", params: { name: 'foo!', nickname: 'F', login_shell: 'zsh' }
%i[name time end transaction_id children cpu_time idle_time allocations duration keys].each do |key|
%i[name time end transaction_id cpu_time idle_time allocations duration keys].each do |key|
assert_includes @event.to_h, key
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@ class WriteFragmentTest < ActionDispatch::IntegrationTest
assert_instance_of String, @event.transaction_id
end

test 'returns children' do
get '/users'
assert_instance_of Array, @event.children
end

test 'returns cpu_time' do
get '/users'
assert_instance_of Float, @event.cpu_time
Expand All @@ -58,7 +53,7 @@ class WriteFragmentTest < ActionDispatch::IntegrationTest

test 'calls #to_h' do
get '/users'
%i[name time end transaction_id children cpu_time idle_time allocations duration key].each do |key|
%i[name time end transaction_id cpu_time idle_time allocations duration key].each do |key|
assert_includes @event.to_h, key
end
end
Expand Down
7 changes: 1 addition & 6 deletions test/rails_band/action_mailer/event/deliver_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@ class DeliverTest < ActionDispatch::IntegrationTest
assert_instance_of String, @event.transaction_id
end

test 'returns children' do
get "/users/#{@user.id}/welcome_email"
assert_instance_of Array, @event.children
end

test 'returns cpu_time' do
get "/users/#{@user.id}/welcome_email"
assert_instance_of Float, @event.cpu_time
Expand All @@ -58,7 +53,7 @@ class DeliverTest < ActionDispatch::IntegrationTest

test 'calls #to_h' do
get "/users/#{@user.id}/welcome_email"
%i[name time end transaction_id children cpu_time idle_time allocations duration mailer message_id
%i[name time end transaction_id cpu_time idle_time allocations duration mailer message_id
subject to from bcc cc date mail perform_deliveries].each do |key|
assert_includes @event.to_h, key
end
Expand Down
Loading

0 comments on commit eaa2c7f

Please sign in to comment.