Skip to content

Commit a628975

Browse files
authored
Merge pull request rails#53311 from Shopify/ruby-head-silence-object-id-warning
Silence `object_id` redefinition warnings in the test suite
2 parents 422ce1b + 4588e6a commit a628975

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

activerecord/test/cases/transaction_callbacks_test.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,9 @@ def test_saving_a_record_with_a_belongs_to_that_specifies_touching_the_parent_sh
503503

504504
def test_saving_two_records_that_override_object_id_should_run_after_commit_callbacks_for_both
505505
klass = Class.new(TopicWithCallbacks) do
506-
define_method(:object_id) { 42 }
506+
silence_warnings do
507+
define_method(:object_id) { 42 }
508+
end
507509
end
508510

509511
records = [klass.new, klass.new]
@@ -521,7 +523,9 @@ def test_saving_two_records_that_override_object_id_should_run_after_commit_call
521523

522524
def test_saving_two_records_that_override_object_id_should_run_after_rollback_callbacks_for_both
523525
klass = Class.new(TopicWithCallbacks) do
524-
define_method(:object_id) { 42 }
526+
silence_warnings do
527+
define_method(:object_id) { 42 }
528+
end
525529
end
526530

527531
records = [klass.new, klass.new]

activesupport/lib/active_support/testing/strict_warnings.rb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ class WarningError < StandardError; end
1717

1818
# TODO: We need to decide what to do with this.
1919
/Status code :unprocessable_entity is deprecated/,
20-
21-
# Allow this warning only in the `TransactionCallbacksTest`.
22-
%r{.*/rails/activerecord/test/cases/transaction_callbacks_test\.rb:\d+: warning: redefining 'object_id' may cause serious problems}
2320
)
2421

2522
SUPPRESSED_WARNINGS = Regexp.union(

0 commit comments

Comments
 (0)