From a6a4790d950eb44d9bbe39c0cf822892b5c875ff Mon Sep 17 00:00:00 2001 From: Trevor Vallender Date: Thu, 3 Jul 2025 11:46:00 +0100 Subject: [PATCH 01/19] add rename_schema method for postgres --- activerecord/CHANGELOG.md | 4 +++ .../postgresql/schema_statements.rb | 5 ++++ .../cases/adapters/postgresql/schema_test.rb | 27 +++++++++++++++++++ 3 files changed, 36 insertions(+) diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md index 4dad4f8e8f5a4..bc5e6e5e9a0da 100644 --- a/activerecord/CHANGELOG.md +++ b/activerecord/CHANGELOG.md @@ -1,3 +1,7 @@ +* Add `rename_schema` method for PostgreSQL. + + *T S Vallender* + * Implement support for deprecating associations: ```ruby diff --git a/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb b/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb index 3d2bbc40994ca..4a4677782e0bb 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb @@ -279,6 +279,11 @@ def drop_schema(schema_name, **options) execute "DROP SCHEMA#{' IF EXISTS' if options[:if_exists]} #{quote_schema_name(schema_name)} CASCADE" end + # Renames the schema for the given schema name. + def rename_schema(schema_name, new_name) + execute "ALTER SCHEMA #{quote_schema_name(schema_name)} RENAME TO #{quote_schema_name(new_name)}" + end + # Sets the schema search path to a string of comma-separated schema names. # Names beginning with $ have to be quoted (e.g. $user => '$user'). # See: https://www.postgresql.org/docs/current/static/ddl-schemas.html diff --git a/activerecord/test/cases/adapters/postgresql/schema_test.rb b/activerecord/test/cases/adapters/postgresql/schema_test.rb index b04b5a9fe8d2c..1a59e16d1271e 100644 --- a/activerecord/test/cases/adapters/postgresql/schema_test.rb +++ b/activerecord/test/cases/adapters/postgresql/schema_test.rb @@ -201,6 +201,33 @@ def test_drop_schema_with_nonexisting_schema end end + def test_rename_schema + @connection.create_schema("test_schema3") + @connection.rename_schema("test_schema3", "test_schema4") + assert_not_includes @connection.schema_names, "test_schema3" + assert_includes @connection.schema_names, "test_schema4" + ensure + @connection.drop_schema("test_schema3", if_exists: true) + @connection.drop_schema("test_schema4", if_exists: true) + end + + def test_rename_schema_with_nonexisting_schema + assert_raises(ActiveRecord::StatementInvalid) do + @connection.rename_schema("idontexist", "neitherdoi") + end + end + + def test_rename_schema_with_existing_target_name + @connection.create_schema("test_schema3") + @connection.create_schema("test_schema4") + assert_raises(ActiveRecord::StatementInvalid) do + @connection.rename_schema("test_schema3", "test_schema4") + end + ensure + @connection.drop_schema("test_schema3", if_exists: true) + @connection.drop_schema("test_schema4", if_exists: true) + end + def test_raise_wrapped_exception_on_bad_prepare assert_raises(ActiveRecord::StatementInvalid) do @connection.exec_query "select * from developers where id = ?", "sql", [bind_param(1)] From cabcfb2911039d5523ba1bac03d573eced7137aa Mon Sep 17 00:00:00 2001 From: Aidan Haran Date: Tue, 8 Jul 2025 10:16:55 +0100 Subject: [PATCH 02/19] Debug --- .DS_Store | Bin 0 -> 10244 bytes .../cases/associations/deprecation_test.rb | 433 +++++++++--------- .../lib/active_support/backtrace_cleaner.rb | 17 + 3 files changed, 235 insertions(+), 215 deletions(-) create mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..bbd41b101b212022414be5521a06522b8184b7fa GIT binary patch literal 10244 zcmeI1U1%It6vxkGcWcsauqKqYQ0tJF2(8horFrW#q)8|w6e?*!`jP!0UAx;|ve_7+ zl%=I02;xf>#ePH-^+D-NX+#Q^Lfgl@Xxi95_#lE%+6NI@Q9S3)ot<-bK6d*csN4xN zCp-6l?)lA`J9qBA0|3@gEw>H827pf7$*xV~A!MU++5=mMK63!Ah5i6pD8q4>g()Zm z)aHcAfXRT#fXRT#fXTqWAp`i%rmb_0Yt7MQz+}K=ppgOUA8g#oI@;DXj^x!a>Y8`*@LBBEj`7sTz4$DNsiXhw(eTj9W2)!EFIa>GZafj zM?YK1!E#({jwS;p1HlZ?+`StHAP0Gv6Z7}ucxI+Jy=`B%T&lQ^z1QN^rSkA_rdZCP zs&hl{{e|VfZtQC1k$Xaq%27__VD;F848Sz5ILva|-jDnHc^PLL`Sb0`6_>5yTPph` zVdXq-?^V^yJmtlOqfmnkj}9<+2BSAAID@_QoK^fyNupJpNA=JEDdZ`rJ2@p; zzWD@MSSjbo-<))=ByZAv5(=LoTp{Dz=nh>Ne}*yvZ@~*tgep`d$DZHARh;L?S8snY zJ+AT+QXjud@k+r5b>drt>rz=AZ1=KCVzS-TFE)@e}3M(e-ZU^*4Apl zyLvD2b_?E;T2(6|a~b9Zb7JMScs1w#x$lC<9aBGNZ_h*WtLGyf%HQ0pBwl}j^pRT5 zo}RquvB&8BmfMbAaCcGKVYT3{s9(oK#$SGBeUy&#{<5Xf2Zq+kv)oE6ILB1`kaf;t ze?2ezKv;KZFu4hi4D=S=qLsgE9ot2pE6sYWhC>f?7jUMcv}4)OW@4Dpqa zkKWovk;$%i&qpgcXXfnJUM?f*<*cpMg7@ho#Opt!#5;pKeIJ;C94AiHH(rX;Y z|L>0e{vTI`DKi-`8TgN9z)BA98y>=oup%ym*4k~{kKj%l>FTakE_fgbomb28_=A?? ypV#NqphW-gXj^x!az{Vqj@Dhx|HnTDcxx#*D-rKaGyj+KYBT@m>)-#Y`TyU{egawm literal 0 HcmV?d00001 diff --git a/activerecord/test/cases/associations/deprecation_test.rb b/activerecord/test/cases/associations/deprecation_test.rb index 1145d24f8e722..fa449ece24c39 100644 --- a/activerecord/test/cases/associations/deprecation_test.rb +++ b/activerecord/test/cases/associations/deprecation_test.rb @@ -39,150 +39,150 @@ def assert_message(message, line) end end - class OptionsTest < TestCase - test "valid options, mode only" do - ActiveRecord.deprecated_associations_options = { mode: :warn } - assert_equal :warn, ActiveRecord::Associations::Deprecation.mode - assert_equal false, ActiveRecord::Associations::Deprecation.backtrace - end - - test "valid options, backtrace only" do - ActiveRecord.deprecated_associations_options = { backtrace: true } - assert_equal :warn, ActiveRecord::Associations::Deprecation.mode - assert_equal true, ActiveRecord::Associations::Deprecation.backtrace - end - - test "valid options, both" do - ActiveRecord.deprecated_associations_options = { - mode: :notify, - backtrace: true - } - assert_equal :notify, ActiveRecord::Associations::Deprecation.mode - assert_equal true, ActiveRecord::Associations::Deprecation.backtrace - end - - test "not a hash" do - error = assert_raises(ArgumentError) do - ActiveRecord.deprecated_associations_options = :invalid - end - assert_equal "deprecated_associations_options must be a hash", error.message - end - - test "invalid keys" do - error = assert_raises(ArgumentError) do - ActiveRecord.deprecated_associations_options = { invalid: true } - end - assert_equal "invalid deprecated_associations_options key :invalid (valid keys are :mode and :backtrace)", error.message - end - - test "invalid mode" do - error = assert_raises(ArgumentError) do - ActiveRecord.deprecated_associations_options = { mode: :invalid } - end - assert_equal "invalid deprecated associations mode :invalid (valid modes are :warn, :raise, and :notify)", error.message - end - end - - class ModeWriterTest < TestCase - test "valid values" do - [:warn, :raise, :notify].each do |mode| - ActiveRecord::Associations::Deprecation.mode = mode - assert_equal mode, ActiveRecord::Associations::Deprecation.mode - end - end - - test "invalid values" do - error = assert_raises(ArgumentError) do - ActiveRecord::Associations::Deprecation.mode = :invalid - end - assert_equal "invalid deprecated associations mode :invalid (valid modes are :warn, :raise, and :notify)", error.message - end - - test "the backtrace flag becomes a true/false singleton" do - ActiveRecord::Associations::Deprecation.backtrace = 1 - assert_same true, ActiveRecord::Associations::Deprecation.backtrace - - ActiveRecord::Associations::Deprecation.backtrace = nil - assert_same false, ActiveRecord::Associations::Deprecation.backtrace - end - end - - class WarnModeTest < TestCase - def setup - super - ActiveRecord::Associations::Deprecation.mode = :warn - - @original_logger = ActiveRecord::Base.logger - @io = StringIO.new - ActiveRecord::Base.logger = Logger.new(@io) - end - - def teardown - super - ActiveRecord::Base.logger = @original_logger - end - - test "report warns in :warn mode" do - DATS::Car.new.deprecated_tyres - assert_message @io.string, __LINE__ - 1 - end - end - - class WarnBacktraceModeTest < TestCase - def setup - super - ActiveRecord::Associations::Deprecation.mode = :warn - ActiveRecord::Associations::Deprecation.backtrace = true - - @original_logger = ActiveRecord::Base.logger - @io = StringIO.new - ActiveRecord::Base.logger = Logger.new(@io) - end - - def teardown - super - ActiveRecord::Base.logger = @original_logger - end - - test "report warns in :warn mode" do - line = __LINE__ + 1 - DATS::Car.new.deprecated_tyres - - assert_message @io.string, line - assert_includes @io.string, "\t#{__FILE__}:#{line}:in" - end - end - - class WarnModeNoLoggerTest < TestCase - def setup - super - ActiveRecord::Associations::Deprecation.mode = :warn - - @original_logger = ActiveRecord::Base.logger - ActiveRecord::Base.logger = nil - end - - def teardown - super - ActiveRecord::Base.logger = @original_logger - end - - test "report does not assume the logger is present" do - assert_nothing_raised { DATS::Car.new.deprecated_tyres } - end - end - - class RaiseModeTest < TestCase - def setup - super - ActiveRecord::Associations::Deprecation.mode = :raise - end - - test "report raises an error in :raise mode" do - error = assert_raises(ActiveRecord::DeprecatedAssociationError) { DATS::Car.new.deprecated_tyres } - assert_message error.message, __LINE__ - 1 - end - end + # class OptionsTest < TestCase + # test "valid options, mode only" do + # ActiveRecord.deprecated_associations_options = { mode: :warn } + # assert_equal :warn, ActiveRecord::Associations::Deprecation.mode + # assert_equal false, ActiveRecord::Associations::Deprecation.backtrace + # end + # + # test "valid options, backtrace only" do + # ActiveRecord.deprecated_associations_options = { backtrace: true } + # assert_equal :warn, ActiveRecord::Associations::Deprecation.mode + # assert_equal true, ActiveRecord::Associations::Deprecation.backtrace + # end + # + # test "valid options, both" do + # ActiveRecord.deprecated_associations_options = { + # mode: :notify, + # backtrace: true + # } + # assert_equal :notify, ActiveRecord::Associations::Deprecation.mode + # assert_equal true, ActiveRecord::Associations::Deprecation.backtrace + # end + # + # test "not a hash" do + # error = assert_raises(ArgumentError) do + # ActiveRecord.deprecated_associations_options = :invalid + # end + # assert_equal "deprecated_associations_options must be a hash", error.message + # end + # + # test "invalid keys" do + # error = assert_raises(ArgumentError) do + # ActiveRecord.deprecated_associations_options = { invalid: true } + # end + # assert_equal "invalid deprecated_associations_options key :invalid (valid keys are :mode and :backtrace)", error.message + # end + # + # test "invalid mode" do + # error = assert_raises(ArgumentError) do + # ActiveRecord.deprecated_associations_options = { mode: :invalid } + # end + # assert_equal "invalid deprecated associations mode :invalid (valid modes are :warn, :raise, and :notify)", error.message + # end + # end + + # class ModeWriterTest < TestCase + # test "valid values" do + # [:warn, :raise, :notify].each do |mode| + # ActiveRecord::Associations::Deprecation.mode = mode + # assert_equal mode, ActiveRecord::Associations::Deprecation.mode + # end + # end + # + # test "invalid values" do + # error = assert_raises(ArgumentError) do + # ActiveRecord::Associations::Deprecation.mode = :invalid + # end + # assert_equal "invalid deprecated associations mode :invalid (valid modes are :warn, :raise, and :notify)", error.message + # end + # + # test "the backtrace flag becomes a true/false singleton" do + # ActiveRecord::Associations::Deprecation.backtrace = 1 + # assert_same true, ActiveRecord::Associations::Deprecation.backtrace + # + # ActiveRecord::Associations::Deprecation.backtrace = nil + # assert_same false, ActiveRecord::Associations::Deprecation.backtrace + # end + # end + + # class WarnModeTest < TestCase + # def setup + # super + # ActiveRecord::Associations::Deprecation.mode = :warn + # + # @original_logger = ActiveRecord::Base.logger + # @io = StringIO.new + # ActiveRecord::Base.logger = Logger.new(@io) + # end + # + # def teardown + # super + # ActiveRecord::Base.logger = @original_logger + # end + # + # test "report warns in :warn mode" do + # DATS::Car.new.deprecated_tyres + # assert_message @io.string, __LINE__ - 1 + # end + # end + + # class WarnBacktraceModeTest < TestCase + # def setup + # super + # ActiveRecord::Associations::Deprecation.mode = :warn + # ActiveRecord::Associations::Deprecation.backtrace = true + # + # @original_logger = ActiveRecord::Base.logger + # @io = StringIO.new + # ActiveRecord::Base.logger = Logger.new(@io) + # end + # + # def teardown + # super + # ActiveRecord::Base.logger = @original_logger + # end + # + # test "report warns in :warn mode" do + # line = __LINE__ + 1 + # DATS::Car.new.deprecated_tyres + # + # assert_message @io.string, line + # assert_includes @io.string, "\t#{__FILE__}:#{line}:in" + # end + # end + + # class WarnModeNoLoggerTest < TestCase + # def setup + # super + # ActiveRecord::Associations::Deprecation.mode = :warn + # + # @original_logger = ActiveRecord::Base.logger + # ActiveRecord::Base.logger = nil + # end + # + # def teardown + # super + # ActiveRecord::Base.logger = @original_logger + # end + # + # test "report does not assume the logger is present" do + # assert_nothing_raised { DATS::Car.new.deprecated_tyres } + # end + # end + + # class RaiseModeTest < TestCase + # def setup + # super + # ActiveRecord::Associations::Deprecation.mode = :raise + # end + # + # test "report raises an error in :raise mode" do + # error = assert_raises(ActiveRecord::DeprecatedAssociationError) { DATS::Car.new.deprecated_tyres } + # assert_message error.message, __LINE__ - 1 + # end + # end class RaiseBacktraceModeTest < TestCase def setup @@ -192,6 +192,9 @@ def setup end test "report raises an error in :raise mode" do + + $AIDO = true + line = __LINE__ + 1 error = assert_raises(ActiveRecord::DeprecatedAssociationError) { DATS::Car.new.deprecated_tyres } @@ -200,75 +203,75 @@ def setup end end - class NotifyModeTest < TestCase - def setup - super - ActiveRecord::Associations::Deprecation.mode = :notify - ActiveRecord::Associations::Deprecation.backtrace = true - end - - def teardown - super - ActiveRecord::LogSubscriber.backtrace_cleaner = @original_backtrace_cleaner - end - - def assert_user_facing_reflection(model, association) - payloads = [] - callback = ->(event) { payloads << event.payload } - - ActiveSupport::Notifications.subscribed(callback, "deprecated_association.active_record") do - model.new.send(association) - end - - assert_equal 1, payloads.size - assert_equal model.reflect_on_association(association), payloads[0][:reflection] - end - - test "report publishes an Active Support notification in :notify mode" do - payloads = [] - callback = ->(event) { payloads << event.payload } - - line = __LINE__ + 2 - ActiveSupport::Notifications.subscribed(callback, "deprecated_association.active_record") do - DATS::Car.new.deprecated_tyres - end - - assert_equal 1, payloads.size - payload = payloads.first - - assert_equal DATS::Car.reflect_on_association(:deprecated_tyres), payload[:reflection] - - assert_message payload[:message], line - - assert_equal __FILE__, payload[:location].path - assert_equal line, payload[:location].lineno - - assert_equal __FILE__, payload[:backtrace][-2].path - assert_equal line, payload[:backtrace][-2].lineno - end - - test "has_many receives the user-facing reflection in the payload" do - assert_user_facing_reflection(DATS::Author, :deprecated_posts) - end - - test "has_one receives the user-facing reflection in the payload" do - assert_user_facing_reflection(DATS::Author, :deprecated_post) - end - - test "belongs_to receives the user-facing reflection in the payload" do - assert_user_facing_reflection(DATS::Bulb, :deprecated_car) - end - - test "has_many :through receives the user-facing reflection in the payload" do - assert_user_facing_reflection(DATS::Author, :deprecated_has_many_through) - end - - test "has_one :through receives the user-facing reflection in the payload" do - assert_user_facing_reflection(DATS::Author, :deprecated_has_one_through) - end - - test "HABTM receives the user-facing reflection in the payload" do - assert_user_facing_reflection(DATS::Category, :deprecated_posts) - end - end + # class NotifyModeTest < TestCase + # def setup + # super + # ActiveRecord::Associations::Deprecation.mode = :notify + # ActiveRecord::Associations::Deprecation.backtrace = true + # end + # + # def teardown + # super + # ActiveRecord::LogSubscriber.backtrace_cleaner = @original_backtrace_cleaner + # end + # + # def assert_user_facing_reflection(model, association) + # payloads = [] + # callback = ->(event) { payloads << event.payload } + # + # ActiveSupport::Notifications.subscribed(callback, "deprecated_association.active_record") do + # model.new.send(association) + # end + # + # assert_equal 1, payloads.size + # assert_equal model.reflect_on_association(association), payloads[0][:reflection] + # end + # + # test "report publishes an Active Support notification in :notify mode" do + # payloads = [] + # callback = ->(event) { payloads << event.payload } + # + # line = __LINE__ + 2 + # ActiveSupport::Notifications.subscribed(callback, "deprecated_association.active_record") do + # DATS::Car.new.deprecated_tyres + # end + # + # assert_equal 1, payloads.size + # payload = payloads.first + # + # assert_equal DATS::Car.reflect_on_association(:deprecated_tyres), payload[:reflection] + # + # assert_message payload[:message], line + # + # assert_equal __FILE__, payload[:location].path + # assert_equal line, payload[:location].lineno + # + # assert_equal __FILE__, payload[:backtrace][-2].path + # assert_equal line, payload[:backtrace][-2].lineno + # end + # + # test "has_many receives the user-facing reflection in the payload" do + # assert_user_facing_reflection(DATS::Author, :deprecated_posts) + # end + # + # test "has_one receives the user-facing reflection in the payload" do + # assert_user_facing_reflection(DATS::Author, :deprecated_post) + # end + # + # test "belongs_to receives the user-facing reflection in the payload" do + # assert_user_facing_reflection(DATS::Bulb, :deprecated_car) + # end + # + # test "has_many :through receives the user-facing reflection in the payload" do + # assert_user_facing_reflection(DATS::Author, :deprecated_has_many_through) + # end + # + # test "has_one :through receives the user-facing reflection in the payload" do + # assert_user_facing_reflection(DATS::Author, :deprecated_has_one_through) + # end + # + # test "HABTM receives the user-facing reflection in the payload" do + # assert_user_facing_reflection(DATS::Category, :deprecated_posts) + # end + # end end diff --git a/activesupport/lib/active_support/backtrace_cleaner.rb b/activesupport/lib/active_support/backtrace_cleaner.rb index a47852947f010..69b3a641044f9 100644 --- a/activesupport/lib/active_support/backtrace_cleaner.rb +++ b/activesupport/lib/active_support/backtrace_cleaner.rb @@ -92,6 +92,8 @@ def clean_frame(frame, kind = :silent) # # Frames are strings. def first_clean_frame(kind = :silent) + puts "1.first_clean_frame" + caller_location_skipped = false Thread.each_caller_location do |location| @@ -119,6 +121,7 @@ def first_clean_location(kind = :silent) next end + return location if clean_frame(location, kind) end end @@ -127,8 +130,20 @@ def first_clean_location(kind = :silent) # # Frames are strings. def first_clean_frame(kind = :silent) + puts "2.first_clean_frame" + Thread.each_caller_location(2) do |location| + + + + frame = clean_frame(location, kind) + + puts "" + puts "location: #{location.inspect}" + puts "frame: #{frame.inspect}" + puts "" + return frame if frame end end @@ -190,6 +205,8 @@ def add_gem_filter gems_paths = (Gem.path | [Gem.default_dir]).map { |p| Regexp.escape(p) } return if gems_paths.empty? + binding.pry if $AIDO + gems_regexp = %r{\A(#{gems_paths.join('|')})/(bundler/)?gems/([^/]+)-([\w.]+)/(.*)} gems_result = '\3 (\4) \5' add_filter { |line| line.sub(gems_regexp, gems_result) } From 5d1c6ea7ad059b075e891048376185679701cad2 Mon Sep 17 00:00:00 2001 From: Aidan Haran Date: Tue, 8 Jul 2025 10:20:48 +0100 Subject: [PATCH 03/19] Update backtrace_cleaner.rb --- .../lib/active_support/backtrace_cleaner.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/activesupport/lib/active_support/backtrace_cleaner.rb b/activesupport/lib/active_support/backtrace_cleaner.rb index 69b3a641044f9..801101d0b1517 100644 --- a/activesupport/lib/active_support/backtrace_cleaner.rb +++ b/activesupport/lib/active_support/backtrace_cleaner.rb @@ -92,7 +92,7 @@ def clean_frame(frame, kind = :silent) # # Frames are strings. def first_clean_frame(kind = :silent) - puts "1.first_clean_frame" + # puts "1.first_clean_frame" caller_location_skipped = false @@ -130,7 +130,7 @@ def first_clean_location(kind = :silent) # # Frames are strings. def first_clean_frame(kind = :silent) - puts "2.first_clean_frame" + # puts "2.first_clean_frame" Thread.each_caller_location(2) do |location| @@ -139,10 +139,10 @@ def first_clean_frame(kind = :silent) frame = clean_frame(location, kind) - puts "" - puts "location: #{location.inspect}" - puts "frame: #{frame.inspect}" - puts "" + # puts "" + # puts "location: #{location.inspect}" + # puts "frame: #{frame.inspect}" + # puts "" return frame if frame end @@ -205,7 +205,7 @@ def add_gem_filter gems_paths = (Gem.path | [Gem.default_dir]).map { |p| Regexp.escape(p) } return if gems_paths.empty? - binding.pry if $AIDO + binding.pry gems_regexp = %r{\A(#{gems_paths.join('|')})/(bundler/)?gems/([^/]+)-([\w.]+)/(.*)} gems_result = '\3 (\4) \5' From e000054e625300d3d097e9d5f2a8ed0ee21a41ca Mon Sep 17 00:00:00 2001 From: Aidan Haran Date: Tue, 8 Jul 2025 10:21:30 +0100 Subject: [PATCH 04/19] Update backtrace_cleaner.rb --- activesupport/lib/active_support/backtrace_cleaner.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/activesupport/lib/active_support/backtrace_cleaner.rb b/activesupport/lib/active_support/backtrace_cleaner.rb index 801101d0b1517..db60fff514b54 100644 --- a/activesupport/lib/active_support/backtrace_cleaner.rb +++ b/activesupport/lib/active_support/backtrace_cleaner.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true +require "pry" module ActiveSupport # = Backtrace Cleaner From 430a3daa30b655657c9b997320b8b1b4bb324d26 Mon Sep 17 00:00:00 2001 From: Aidan Haran Date: Tue, 8 Jul 2025 10:32:39 +0100 Subject: [PATCH 05/19] Update backtrace_cleaner.rb --- activesupport/lib/active_support/backtrace_cleaner.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/activesupport/lib/active_support/backtrace_cleaner.rb b/activesupport/lib/active_support/backtrace_cleaner.rb index db60fff514b54..83f8353e8d808 100644 --- a/activesupport/lib/active_support/backtrace_cleaner.rb +++ b/activesupport/lib/active_support/backtrace_cleaner.rb @@ -218,7 +218,7 @@ def add_core_silencer end def add_gem_silencer - add_silencer { |line| FORMATTED_GEMS_PATTERN.match?(line) } + add_silencer { |line| FORMATTED_GEMS_PATTERN.match?(line) && !/rails/.match?(line) } end def add_stdlib_silencer From 6a0fa6672432e21983eb5a1d0298c1c953a9e327 Mon Sep 17 00:00:00 2001 From: Aidan Haran Date: Tue, 8 Jul 2025 10:33:20 +0100 Subject: [PATCH 06/19] Update backtrace_cleaner.rb --- activesupport/lib/active_support/backtrace_cleaner.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/activesupport/lib/active_support/backtrace_cleaner.rb b/activesupport/lib/active_support/backtrace_cleaner.rb index 83f8353e8d808..b52526c23cc89 100644 --- a/activesupport/lib/active_support/backtrace_cleaner.rb +++ b/activesupport/lib/active_support/backtrace_cleaner.rb @@ -218,7 +218,7 @@ def add_core_silencer end def add_gem_silencer - add_silencer { |line| FORMATTED_GEMS_PATTERN.match?(line) && !/rails/.match?(line) } + add_silencer { |line| FORMATTED_GEMS_PATTERN.match?(line) && !/activerecord/.match?(line) } end def add_stdlib_silencer From 0f849dea310494f0433f28a7cdce78db971584c2 Mon Sep 17 00:00:00 2001 From: Aidan Haran Date: Tue, 8 Jul 2025 10:33:27 +0100 Subject: [PATCH 07/19] Update backtrace_cleaner.rb --- activesupport/lib/active_support/backtrace_cleaner.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/activesupport/lib/active_support/backtrace_cleaner.rb b/activesupport/lib/active_support/backtrace_cleaner.rb index b52526c23cc89..e418feb70067f 100644 --- a/activesupport/lib/active_support/backtrace_cleaner.rb +++ b/activesupport/lib/active_support/backtrace_cleaner.rb @@ -206,7 +206,7 @@ def add_gem_filter gems_paths = (Gem.path | [Gem.default_dir]).map { |p| Regexp.escape(p) } return if gems_paths.empty? - binding.pry + # binding.pry gems_regexp = %r{\A(#{gems_paths.join('|')})/(bundler/)?gems/([^/]+)-([\w.]+)/(.*)} gems_result = '\3 (\4) \5' From 8465b30521d8dc82af9ee2802decaa4d5bd6743c Mon Sep 17 00:00:00 2001 From: Aidan Haran Date: Tue, 8 Jul 2025 10:35:59 +0100 Subject: [PATCH 08/19] Update backtrace_cleaner.rb --- activesupport/lib/active_support/backtrace_cleaner.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/activesupport/lib/active_support/backtrace_cleaner.rb b/activesupport/lib/active_support/backtrace_cleaner.rb index e418feb70067f..56cc780e85857 100644 --- a/activesupport/lib/active_support/backtrace_cleaner.rb +++ b/activesupport/lib/active_support/backtrace_cleaner.rb @@ -210,7 +210,15 @@ def add_gem_filter gems_regexp = %r{\A(#{gems_paths.join('|')})/(bundler/)?gems/([^/]+)-([\w.]+)/(.*)} gems_result = '\3 (\4) \5' - add_filter { |line| line.sub(gems_regexp, gems_result) } + + add_filter do |line| + if line.match?(/activerecord/) + line + else + line.sub(gems_regexp, gems_result) + end + + end end def add_core_silencer From 4909f28d2fface006f25b17437a99671d0d8b219 Mon Sep 17 00:00:00 2001 From: Aidan Haran Date: Tue, 8 Jul 2025 10:39:48 +0100 Subject: [PATCH 09/19] Update backtrace_cleaner.rb --- .../lib/active_support/backtrace_cleaner.rb | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/activesupport/lib/active_support/backtrace_cleaner.rb b/activesupport/lib/active_support/backtrace_cleaner.rb index 56cc780e85857..f435bc968f92d 100644 --- a/activesupport/lib/active_support/backtrace_cleaner.rb +++ b/activesupport/lib/active_support/backtrace_cleaner.rb @@ -138,7 +138,8 @@ def first_clean_frame(kind = :silent) - frame = clean_frame(location, kind) + + frame = clean_frame(location, kind) unless location.match?(/activerecord/) # puts "" # puts "location: #{location.inspect}" @@ -212,11 +213,11 @@ def add_gem_filter gems_result = '\3 (\4) \5' add_filter do |line| - if line.match?(/activerecord/) - line - else + # if line.match?(/activerecord/) + # line + # else line.sub(gems_regexp, gems_result) - end + # end end end @@ -226,7 +227,9 @@ def add_core_silencer end def add_gem_silencer - add_silencer { |line| FORMATTED_GEMS_PATTERN.match?(line) && !/activerecord/.match?(line) } + add_silencer do |line| + FORMATTED_GEMS_PATTERN.match?(line) #&& !/activerecord/.match?(line) + end end def add_stdlib_silencer From 54e489c91a017df0a21e92f42d0f4a79e1cb8871 Mon Sep 17 00:00:00 2001 From: Aidan Haran Date: Tue, 8 Jul 2025 10:40:33 +0100 Subject: [PATCH 10/19] Update backtrace_cleaner.rb --- activesupport/lib/active_support/backtrace_cleaner.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/activesupport/lib/active_support/backtrace_cleaner.rb b/activesupport/lib/active_support/backtrace_cleaner.rb index f435bc968f92d..3502490c2e927 100644 --- a/activesupport/lib/active_support/backtrace_cleaner.rb +++ b/activesupport/lib/active_support/backtrace_cleaner.rb @@ -139,7 +139,7 @@ def first_clean_frame(kind = :silent) - frame = clean_frame(location, kind) unless location.match?(/activerecord/) + frame = clean_frame(location, kind) unless location.to_s.match?(/activerecord/) # puts "" # puts "location: #{location.inspect}" From 1af5d5d88987c959b0fbee2d5f591c9f226b9975 Mon Sep 17 00:00:00 2001 From: Aidan Haran Date: Tue, 8 Jul 2025 10:41:38 +0100 Subject: [PATCH 11/19] Update backtrace_cleaner.rb --- activesupport/lib/active_support/backtrace_cleaner.rb | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/activesupport/lib/active_support/backtrace_cleaner.rb b/activesupport/lib/active_support/backtrace_cleaner.rb index 3502490c2e927..d94e8fcfc69f7 100644 --- a/activesupport/lib/active_support/backtrace_cleaner.rb +++ b/activesupport/lib/active_support/backtrace_cleaner.rb @@ -131,20 +131,21 @@ def first_clean_location(kind = :silent) # # Frames are strings. def first_clean_frame(kind = :silent) - # puts "2.first_clean_frame" + puts "2.first_clean_frame" Thread.each_caller_location(2) do |location| + frame = clean_frame(location, kind) unless location.to_s.match?(/activerecord/) - # puts "" - # puts "location: #{location.inspect}" - # puts "frame: #{frame.inspect}" - # puts "" + puts "" + puts "location: #{location.inspect}" + puts "frame: #{frame.inspect}" + puts "" return frame if frame end From 3199fd2a388145c1a8eafcb4fd99650e0816c35e Mon Sep 17 00:00:00 2001 From: Aidan Haran Date: Tue, 8 Jul 2025 12:12:09 +0100 Subject: [PATCH 12/19] Update backtrace_cleaner.rb --- activesupport/lib/active_support/backtrace_cleaner.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/activesupport/lib/active_support/backtrace_cleaner.rb b/activesupport/lib/active_support/backtrace_cleaner.rb index d94e8fcfc69f7..83243f057fc5c 100644 --- a/activesupport/lib/active_support/backtrace_cleaner.rb +++ b/activesupport/lib/active_support/backtrace_cleaner.rb @@ -137,10 +137,15 @@ def first_clean_frame(kind = :silent) - + + frame = if location.to_s.match?(/activerecord/) + location.to_s + else + clean_frame(location, kind) + end - frame = clean_frame(location, kind) unless location.to_s.match?(/activerecord/) + puts "" puts "location: #{location.inspect}" From 5e552eb41dc9657455bdea3ac6e0008e9051e0d1 Mon Sep 17 00:00:00 2001 From: Aidan Haran Date: Tue, 8 Jul 2025 12:14:17 +0100 Subject: [PATCH 13/19] Update backtrace_cleaner.rb --- activesupport/lib/active_support/backtrace_cleaner.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/activesupport/lib/active_support/backtrace_cleaner.rb b/activesupport/lib/active_support/backtrace_cleaner.rb index 83243f057fc5c..3506e232cd9c9 100644 --- a/activesupport/lib/active_support/backtrace_cleaner.rb +++ b/activesupport/lib/active_support/backtrace_cleaner.rb @@ -139,13 +139,13 @@ def first_clean_frame(kind = :silent) frame = if location.to_s.match?(/activerecord/) - location.to_s + location.to_s.split(" ").first else clean_frame(location, kind) end - + puts "" puts "location: #{location.inspect}" From 1171d6824ef17eab2e0c347ae56ba77f6f1117e0 Mon Sep 17 00:00:00 2001 From: Aidan Haran Date: Tue, 8 Jul 2025 12:16:23 +0100 Subject: [PATCH 14/19] Update backtrace_cleaner.rb --- activesupport/lib/active_support/backtrace_cleaner.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/activesupport/lib/active_support/backtrace_cleaner.rb b/activesupport/lib/active_support/backtrace_cleaner.rb index 3506e232cd9c9..ee0b07cda26a4 100644 --- a/activesupport/lib/active_support/backtrace_cleaner.rb +++ b/activesupport/lib/active_support/backtrace_cleaner.rb @@ -138,7 +138,7 @@ def first_clean_frame(kind = :silent) - frame = if location.to_s.match?(/activerecord/) + frame = if location.to_s.match?(/activerecord\/test/) location.to_s.split(" ").first else clean_frame(location, kind) From 6552854d5aa722966efc25659b53ff6fa617c9c2 Mon Sep 17 00:00:00 2001 From: Aidan Haran Date: Tue, 8 Jul 2025 12:37:00 +0100 Subject: [PATCH 15/19] Dont run actions --- .github/CODEOWNERS | 1 - .github/ISSUE_TEMPLATE/bug_report.md | 28 ------ .github/ISSUE_TEMPLATE/config.yml | 1 - .github/autolabeler.yml | 28 ------ .github/no-response.yml | 12 --- .github/pull_request_template.md | 45 --------- .github/security.md | 12 --- .github/stale.yml | 30 ------ .github/verba-sequentur.yml | 21 ---- .github/workflows/devcontainer-shellcheck.yml | 24 ----- .github/workflows/devcontainer-smoke-test.yml | 99 ------------------- .github/workflows/rail_inspector.yml | 27 ----- .github/workflows/rails-new-docker.yml | 49 --------- .github/workflows/rails_releaser_tests.yml | 29 ------ .github/workflows/release.yml | 40 -------- .github/workflows/scripts/test-container.rb | 29 ------ 16 files changed, 475 deletions(-) delete mode 100644 .github/CODEOWNERS delete mode 100644 .github/ISSUE_TEMPLATE/bug_report.md delete mode 100644 .github/ISSUE_TEMPLATE/config.yml delete mode 100644 .github/autolabeler.yml delete mode 100644 .github/no-response.yml delete mode 100644 .github/pull_request_template.md delete mode 100644 .github/security.md delete mode 100644 .github/stale.yml delete mode 100644 .github/verba-sequentur.yml delete mode 100644 .github/workflows/devcontainer-shellcheck.yml delete mode 100644 .github/workflows/devcontainer-smoke-test.yml delete mode 100644 .github/workflows/rail_inspector.yml delete mode 100644 .github/workflows/rails-new-docker.yml delete mode 100644 .github/workflows/rails_releaser_tests.yml delete mode 100644 .github/workflows/release.yml delete mode 100644 .github/workflows/scripts/test-container.rb diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS deleted file mode 100644 index b5ed405b02670..0000000000000 --- a/.github/CODEOWNERS +++ /dev/null @@ -1 +0,0 @@ -.rubocop.yml @rafaelfranca diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md deleted file mode 100644 index fdefb6a67e9d9..0000000000000 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ /dev/null @@ -1,28 +0,0 @@ ---- -name: Bug report -about: Report an issue with Rails you've discovered ---- - -### Steps to reproduce - - - - -```ruby -# Your reproduction script goes here -``` - -### Expected behavior - - - -### Actual behavior - - - -### System configuration - -**Rails version**: - -**Ruby version**: diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml deleted file mode 100644 index 3ba13e0cec6cb..0000000000000 --- a/.github/ISSUE_TEMPLATE/config.yml +++ /dev/null @@ -1 +0,0 @@ -blank_issues_enabled: false diff --git a/.github/autolabeler.yml b/.github/autolabeler.yml deleted file mode 100644 index 6eb6f354e57bc..0000000000000 --- a/.github/autolabeler.yml +++ /dev/null @@ -1,28 +0,0 @@ -actioncable: - - "actioncable/**/*" -actionmailbox: - - "actionmailbox/**/*" -actionmailer: - - "actionmailer/**/*" -actionpack: - - "actionpack/**/*" -actiontext: - - "actiontext/**/*" -actionview: - - "actionview/**/*" -activejob: - - "activejob/**/*" -activemodel: - - "activemodel/**/*" -activerecord: - - "activerecord/**/*" -activestorage: - - "activestorage/**/*" -activesupport: - - "activesupport/**/*" -rails-ujs: - - "actionview/app/assets/javascripts/rails-ujs*/*" -railties: - - "railties/**/*" -docs: - - "guides/**/*" diff --git a/.github/no-response.yml b/.github/no-response.yml deleted file mode 100644 index 326fa84b7e740..0000000000000 --- a/.github/no-response.yml +++ /dev/null @@ -1,12 +0,0 @@ -# Configuration for probot-no-response - https://github.com/probot/no-response - -# Number of days of inactivity before an Issue is closed for lack of response -daysUntilClose: 14 -# Label requiring a response -responseRequiredLabel: more-information-needed -# Comment to post when closing an Issue for lack of response. Set to `false` to disable -closeComment: > - This issue has been automatically closed because there has been no follow-up - response from the original author. We currently don't have enough - information in order to take action. Please reach out if you have any additional - information that will help us move this issue forward. diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md deleted file mode 100644 index fd53fc45a39de..0000000000000 --- a/.github/pull_request_template.md +++ /dev/null @@ -1,45 +0,0 @@ - - -### Motivation / Background - - - -This Pull Request has been created because [REPLACE ME] - -### Detail - -This Pull Request changes [REPLACE ME] - -### Additional information - - - -### Checklist - -Before submitting the PR make sure the following are checked: - -* [ ] This Pull Request is related to one change. Unrelated changes should be opened in separate PRs. -* [ ] Commit message has a detailed description of what changed and why. If this PR fixes a related issue include it in the commit message. Ex: `[Fix #issue-number]` -* [ ] Tests are added or updated if you fix a bug or add a feature. -* [ ] CHANGELOG files are updated for the changed libraries if there is a behavior change or additional feature. Minor bug fixes and documentation changes should not be included. diff --git a/.github/security.md b/.github/security.md deleted file mode 100644 index dc32fb3a0da2e..0000000000000 --- a/.github/security.md +++ /dev/null @@ -1,12 +0,0 @@ -# Security Policy - -## Reporting a Vulnerability - -**Do not open up a GitHub issue if the bug is a security vulnerability in Rails**. -Instead, refer to our [security policy](https://rubyonrails.org/security). - -## Supported Versions - -Security backports are provided for some previous release series. For details -of which release series are currently receiving security backports see our -[security policy](https://rubyonrails.org/security). diff --git a/.github/stale.yml b/.github/stale.yml deleted file mode 100644 index 2b40308582bee..0000000000000 --- a/.github/stale.yml +++ /dev/null @@ -1,30 +0,0 @@ -# Number of days of inactivity before an issue becomes stale -daysUntilStale: 90 -# Number of days of inactivity before a stale issue is closed -daysUntilClose: 7 -# Issues with these labels will never be considered stale -exemptLabels: - - pinned - - security - - With reproduction steps - - attached PR - - regression - - release blocker -# Issues on a milestone will never be considered stale -exemptMilestones: true -# Label to use when marking an issue as stale -staleLabel: stale -# Comment to post when marking an issue as stale. Set to `false` to disable -markComment: > - This issue has been automatically marked as stale because it has not been commented on for at least three months. - - The resources of the Rails team are limited, and so we are asking for your help. - - If you can still reproduce this error on the `8-0-stable` branch or on `main`, - please reply with all of the information you have about it in order to keep the issue open. - - Thank you for all your contributions. -# Comment to post when closing a stale issue. Set to `false` to disable -closeComment: false -# Limit to only `issues` or `pulls` -only: issues diff --git a/.github/verba-sequentur.yml b/.github/verba-sequentur.yml deleted file mode 100644 index 0fc1a9586a9a4..0000000000000 --- a/.github/verba-sequentur.yml +++ /dev/null @@ -1,21 +0,0 @@ -# Documentation: https://github.com/jonathanhefner/verba-sequentur - -"support request": - comment: > - This appears to be a request for technical support. We reserve the - issue tracker for issues only. For technical support questions, - please use the [rubyonrails-talk](https://discuss.rubyonrails.org/c/rubyonrails-talk/7) - forum or [Stack Overflow](https://stackoverflow.com/questions/tagged/ruby-on-rails), - where a wider community can help you. - close: true - -"feature request": - comment: > - This appears to be a feature request. We generally do not take - feature requests, and we reserve the issue tracker for issues only. - We recommend you [try to implement the feature]( - https://guides.rubyonrails.org/contributing_to_ruby_on_rails.html#contributing-to-the-rails-code), - and send us a pull request instead. If you are unsure if the feature - would be accepted, please ask on the [rubyonrails-core]( - https://discuss.rubyonrails.org/c/rubyonrails-core/5) forum. - close: true diff --git a/.github/workflows/devcontainer-shellcheck.yml b/.github/workflows/devcontainer-shellcheck.yml deleted file mode 100644 index 57eb1c3aa8ca4..0000000000000 --- a/.github/workflows/devcontainer-shellcheck.yml +++ /dev/null @@ -1,24 +0,0 @@ -name: Devcontainer Shellcheck - -on: - pull_request: - paths: - - ".devcontainer/**/*.sh" - push: - paths: - - ".devcontainer/**/*.sh" - -permissions: - contents: read - -jobs: - devcontainer_shellcheck: - name: Devcontainer Shellcheck - runs-on: ubuntu-latest - steps: - - name: Checkout (GitHub) - uses: actions/checkout@v4 - - - name: Lint Devcontainer Scripts - run: | - find .devcontainer/ -name '*.sh' -print0 | xargs -0 shellcheck diff --git a/.github/workflows/devcontainer-smoke-test.yml b/.github/workflows/devcontainer-smoke-test.yml deleted file mode 100644 index ae5c1a2e58b7c..0000000000000 --- a/.github/workflows/devcontainer-smoke-test.yml +++ /dev/null @@ -1,99 +0,0 @@ -name: Devcontainer smoke test - -on: push - -jobs: - build: - name: Devcontainer smoke test - - runs-on: ubuntu-latest - permissions: - contents: read - packages: write - strategy: - fail-fast: false - - steps: - - name: Checkout (GitHub) - uses: actions/checkout@v4 - - - name: Login to GitHub Container Registry - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Set up Ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: 3.4 - bundler-cache: true - - - name: Generate rails app sqlite3 - run: bundle exec railties/exe/rails new myapp_sqlite --database="sqlite3" --dev --devcontainer - - - name: Test devcontainer sqlite3 - uses: devcontainers/ci@v0.3 - with: - subFolder: myapp_sqlite - imageName: ghcr.io/rails/smoke-test-devcontainer - cacheFrom: ghcr.io/rails/smoke-test-devcontainer - imageTag: sqlite3 - push: ${{ github.repository == 'rails/rails' && 'filter' || 'never' }} - refFilterForPush: refs/heads/main - runCmd: bin/rails g scaffold Post && bin/rails db:migrate && bin/rails test - - - name: Stop all containers - run: docker ps -q | xargs docker stop - - - name: Generate rails app postgresql - run: bundle exec railties/exe/rails new myapp_postgresql --database="postgresql" --dev --devcontainer - - - name: Test devcontainer postgresql - uses: devcontainers/ci@v0.3 - with: - subFolder: myapp_postgresql - imageName: ghcr.io/rails/smoke-test-devcontainer - cacheFrom: ghcr.io/rails/smoke-test-devcontainer - imageTag: postgresql - push: ${{ github.repository == 'rails/rails' && 'filter' || 'never' }} - refFilterForPush: refs/heads/main - runCmd: bin/rails g scaffold Post && bin/rails db:migrate && bin/rails test && bin/rails test:system - - - name: Stop all containers - run: docker ps -q | xargs docker stop - - - name: Generate rails app mysql - run: bundle exec railties/exe/rails new myapp_mysql --database="mysql" --dev --devcontainer - - - name: Test devcontainer mysql - uses: devcontainers/ci@v0.3 - with: - subFolder: myapp_mysql - imageName: ghcr.io/rails/smoke-test-devcontainer - cacheFrom: ghcr.io/rails/smoke-test-devcontainer - imageTag: mysql - push: ${{ github.repository == 'rails/rails' && 'filter' || 'never' }} - refFilterForPush: refs/heads/main - runCmd: bin/rails g scaffold Post && bin/rails db:migrate && bin/rails test - - - name: Stop all containers - run: docker ps -q | xargs docker stop - - - name: Generate rails app trilogy - run: bundle exec railties/exe/rails new myapp_trilogy --database="trilogy" --dev --devcontainer - - - name: Test devcontainer trilogy - uses: devcontainers/ci@v0.3 - with: - subFolder: myapp_trilogy - imageName: ghcr.io/rails/smoke-test-devcontainer - cacheFrom: ghcr.io/rails/smoke-test-devcontainer - imageTag: trilogy - push: ${{ github.repository == 'rails/rails' && 'filter' || 'never' }} - refFilterForPush: refs/heads/main - runCmd: bin/rails g scaffold Post && bin/rails db:migrate && bin/rails test - - - name: Stop all containers - run: docker ps -q | xargs docker stop diff --git a/.github/workflows/rail_inspector.yml b/.github/workflows/rail_inspector.yml deleted file mode 100644 index 9bc240995ded5..0000000000000 --- a/.github/workflows/rail_inspector.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: Rail Inspector - -on: - pull_request: - paths: - - "tools/rail_inspector/**" - push: - paths: - - "tools/rail_inspector/**" - -permissions: - contents: read - -jobs: - rail_inspector: - name: rail_inspector tests - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Remove Gemfile.lock - run: rm -f Gemfile.lock - - name: Set up Ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: 3.4 - bundler-cache: true - - run: cd tools/rail_inspector && bundle exec rake diff --git a/.github/workflows/rails-new-docker.yml b/.github/workflows/rails-new-docker.yml deleted file mode 100644 index 8b36f0897085c..0000000000000 --- a/.github/workflows/rails-new-docker.yml +++ /dev/null @@ -1,49 +0,0 @@ -name: rails-new-docker - -on: [push, pull_request] - -permissions: - contents: read - -env: - APP_NAME: devrails - APP_PATH: dev/devrails - BUNDLE_WITHOUT: db:job:cable:storage - -jobs: - rails-new-docker: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Remove Gemfile.lock - run: rm -f Gemfile.lock - - name: Set up Ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: 3.4 - bundler-cache: true - - name: Generate --dev app - run: | - bundle exec railties/exe/rails new $APP_PATH --dev - - name: Build image - run: | - podman build -t $APP_NAME \ - -v $(pwd):$(pwd) \ - -f ./$APP_PATH/Dockerfile \ - ./$APP_PATH - - name: Run container - run: | - podman run --name $APP_NAME \ - -v $(pwd):$(pwd) \ - -e SECRET_KEY_BASE_DUMMY=1 \ - -e DATABASE_URL=sqlite3:storage/production.sqlite3 \ - -p 3000:3000 $APP_NAME & - - name: Test container - run: ruby -r ./.github/workflows/scripts/test-container.rb - - - uses: zzak/action-discord@v8 - continue-on-error: true - if: failure() && github.ref_name == 'main' - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - webhook: ${{ secrets.DISCORD_WEBHOOK }} diff --git a/.github/workflows/rails_releaser_tests.yml b/.github/workflows/rails_releaser_tests.yml deleted file mode 100644 index f3c2a0f13bb47..0000000000000 --- a/.github/workflows/rails_releaser_tests.yml +++ /dev/null @@ -1,29 +0,0 @@ -name: Rails releaser tests - -on: - pull_request: - paths: - - "tools/releaser/**" - push: - paths: - - "tools/releaser/**" - -permissions: - contents: read - -jobs: - releaser_tests: - name: releaser tests - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - name: Set up Ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: ruby - - name: Bundle install - run: bundle install - working-directory: tools/releaser - - run: bundle exec rake - working-directory: tools/releaser diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index e5c84b75eda69..0000000000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,40 +0,0 @@ -name: Release - -on: - release: - types: [published] - -jobs: - release: - permissions: - contents: write - id-token: write - - environment: release - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - name: Set up Ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: ruby - - uses: actions/setup-node@v4 - with: - node-version: lts/* - registry-url: 'https://registry.npmjs.org' - - name: Configure trusted publishing credentials - uses: rubygems/configure-rubygems-credentials@v1.0.0 - - name: Bundle install - run: bundle install - working-directory: tools/releaser - - name: Run release rake task - run: bundle exec rake push - shell: bash - working-directory: tools/releaser - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - - name: Wait for release to propagate - run: gem exec rubygems-await pkg/*.gem - shell: bash diff --git a/.github/workflows/scripts/test-container.rb b/.github/workflows/scripts/test-container.rb deleted file mode 100644 index 1ebecd2aa3c21..0000000000000 --- a/.github/workflows/scripts/test-container.rb +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env ruby -# frozen_string_literal: true - -# Based on Sam Ruby's system test from dockerfile-rails: -# https://github.com/rubys/dockerfile-rails/pull/21 - -require "net/http" -require "socket" - -LOCALHOST = Socket.gethostname -PORT = 3000 - -60.times do |i| - sleep 0.5 - begin - response = Net::HTTP.get_response(LOCALHOST, "/up", PORT) - - if %w(404 500).include? response.code - status = response.code.to_i - end - - puts response.body - exit status || 0 - rescue SystemCallError, IOError - puts "#{i}/60 Connection to #{LOCALHOST}:#{PORT} refused or timed out, retrying..." - end -end - -exit 999 From e2de6dae98607b1896889b547fa5f832f4527adf Mon Sep 17 00:00:00 2001 From: Aidan Haran Date: Tue, 8 Jul 2025 12:37:04 +0100 Subject: [PATCH 16/19] Update deprecation_test.rb --- activerecord/test/cases/associations/deprecation_test.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/activerecord/test/cases/associations/deprecation_test.rb b/activerecord/test/cases/associations/deprecation_test.rb index fa449ece24c39..21ba9901cfded 100644 --- a/activerecord/test/cases/associations/deprecation_test.rb +++ b/activerecord/test/cases/associations/deprecation_test.rb @@ -199,6 +199,9 @@ def setup error = assert_raises(ActiveRecord::DeprecatedAssociationError) { DATS::Car.new.deprecated_tyres } assert_message error.message, line + + binding.pry + assert_includes error.backtrace.last, "#{__FILE__}:#{line}:in" end end From b80592ff65fbd6ff843ace3998c2c72d5923f285 Mon Sep 17 00:00:00 2001 From: Aidan Haran Date: Tue, 8 Jul 2025 12:43:56 +0100 Subject: [PATCH 17/19] Update backtrace_cleaner.rb --- .../lib/active_support/backtrace_cleaner.rb | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/activesupport/lib/active_support/backtrace_cleaner.rb b/activesupport/lib/active_support/backtrace_cleaner.rb index ee0b07cda26a4..197b549395822 100644 --- a/activesupport/lib/active_support/backtrace_cleaner.rb +++ b/activesupport/lib/active_support/backtrace_cleaner.rb @@ -138,19 +138,19 @@ def first_clean_frame(kind = :silent) - frame = if location.to_s.match?(/activerecord\/test/) - location.to_s.split(" ").first - else - clean_frame(location, kind) - end - - + # frame = if location.to_s.match?(/activerecord\/test/) + # location.to_s.split(" ").first + # else + # clean_frame(location, kind) + # end + frame = clean_frame(location, kind) - puts "" - puts "location: #{location.inspect}" - puts "frame: #{frame.inspect}" - puts "" + # + # puts "" + # puts "location: #{location.inspect}" + # puts "frame: #{frame.inspect}" + # puts "" return frame if frame end @@ -219,11 +219,11 @@ def add_gem_filter gems_result = '\3 (\4) \5' add_filter do |line| - # if line.match?(/activerecord/) - # line - # else + if line.match?(/activerecord/) + line + else line.sub(gems_regexp, gems_result) - # end + end end end @@ -234,7 +234,7 @@ def add_core_silencer def add_gem_silencer add_silencer do |line| - FORMATTED_GEMS_PATTERN.match?(line) #&& !/activerecord/.match?(line) + FORMATTED_GEMS_PATTERN.match?(line) && !/activerecord/.match?(line) end end From 2333bb15a2db5922326d6125ec52207f4646a09a Mon Sep 17 00:00:00 2001 From: Aidan Haran Date: Tue, 8 Jul 2025 12:45:22 +0100 Subject: [PATCH 18/19] Update backtrace_cleaner.rb --- activesupport/lib/active_support/backtrace_cleaner.rb | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/activesupport/lib/active_support/backtrace_cleaner.rb b/activesupport/lib/active_support/backtrace_cleaner.rb index 197b549395822..6c812d162cd36 100644 --- a/activesupport/lib/active_support/backtrace_cleaner.rb +++ b/activesupport/lib/active_support/backtrace_cleaner.rb @@ -131,7 +131,7 @@ def first_clean_location(kind = :silent) # # Frames are strings. def first_clean_frame(kind = :silent) - puts "2.first_clean_frame" + # puts "2.first_clean_frame" Thread.each_caller_location(2) do |location| @@ -146,12 +146,6 @@ def first_clean_frame(kind = :silent) frame = clean_frame(location, kind) - # - # puts "" - # puts "location: #{location.inspect}" - # puts "frame: #{frame.inspect}" - # puts "" - return frame if frame end end From 49cf5dcb5f803df133238d0c02bcba4a5009b8f9 Mon Sep 17 00:00:00 2001 From: Aidan Haran Date: Tue, 8 Jul 2025 12:45:43 +0100 Subject: [PATCH 19/19] Update deprecation_test.rb --- .../cases/associations/deprecation_test.rb | 436 +++++++++--------- 1 file changed, 215 insertions(+), 221 deletions(-) diff --git a/activerecord/test/cases/associations/deprecation_test.rb b/activerecord/test/cases/associations/deprecation_test.rb index 21ba9901cfded..1145d24f8e722 100644 --- a/activerecord/test/cases/associations/deprecation_test.rb +++ b/activerecord/test/cases/associations/deprecation_test.rb @@ -39,242 +39,236 @@ def assert_message(message, line) end end - # class OptionsTest < TestCase - # test "valid options, mode only" do - # ActiveRecord.deprecated_associations_options = { mode: :warn } - # assert_equal :warn, ActiveRecord::Associations::Deprecation.mode - # assert_equal false, ActiveRecord::Associations::Deprecation.backtrace - # end - # - # test "valid options, backtrace only" do - # ActiveRecord.deprecated_associations_options = { backtrace: true } - # assert_equal :warn, ActiveRecord::Associations::Deprecation.mode - # assert_equal true, ActiveRecord::Associations::Deprecation.backtrace - # end - # - # test "valid options, both" do - # ActiveRecord.deprecated_associations_options = { - # mode: :notify, - # backtrace: true - # } - # assert_equal :notify, ActiveRecord::Associations::Deprecation.mode - # assert_equal true, ActiveRecord::Associations::Deprecation.backtrace - # end - # - # test "not a hash" do - # error = assert_raises(ArgumentError) do - # ActiveRecord.deprecated_associations_options = :invalid - # end - # assert_equal "deprecated_associations_options must be a hash", error.message - # end - # - # test "invalid keys" do - # error = assert_raises(ArgumentError) do - # ActiveRecord.deprecated_associations_options = { invalid: true } - # end - # assert_equal "invalid deprecated_associations_options key :invalid (valid keys are :mode and :backtrace)", error.message - # end - # - # test "invalid mode" do - # error = assert_raises(ArgumentError) do - # ActiveRecord.deprecated_associations_options = { mode: :invalid } - # end - # assert_equal "invalid deprecated associations mode :invalid (valid modes are :warn, :raise, and :notify)", error.message - # end - # end - - # class ModeWriterTest < TestCase - # test "valid values" do - # [:warn, :raise, :notify].each do |mode| - # ActiveRecord::Associations::Deprecation.mode = mode - # assert_equal mode, ActiveRecord::Associations::Deprecation.mode - # end - # end - # - # test "invalid values" do - # error = assert_raises(ArgumentError) do - # ActiveRecord::Associations::Deprecation.mode = :invalid - # end - # assert_equal "invalid deprecated associations mode :invalid (valid modes are :warn, :raise, and :notify)", error.message - # end - # - # test "the backtrace flag becomes a true/false singleton" do - # ActiveRecord::Associations::Deprecation.backtrace = 1 - # assert_same true, ActiveRecord::Associations::Deprecation.backtrace - # - # ActiveRecord::Associations::Deprecation.backtrace = nil - # assert_same false, ActiveRecord::Associations::Deprecation.backtrace - # end - # end - - # class WarnModeTest < TestCase - # def setup - # super - # ActiveRecord::Associations::Deprecation.mode = :warn - # - # @original_logger = ActiveRecord::Base.logger - # @io = StringIO.new - # ActiveRecord::Base.logger = Logger.new(@io) - # end - # - # def teardown - # super - # ActiveRecord::Base.logger = @original_logger - # end - # - # test "report warns in :warn mode" do - # DATS::Car.new.deprecated_tyres - # assert_message @io.string, __LINE__ - 1 - # end - # end - - # class WarnBacktraceModeTest < TestCase - # def setup - # super - # ActiveRecord::Associations::Deprecation.mode = :warn - # ActiveRecord::Associations::Deprecation.backtrace = true - # - # @original_logger = ActiveRecord::Base.logger - # @io = StringIO.new - # ActiveRecord::Base.logger = Logger.new(@io) - # end - # - # def teardown - # super - # ActiveRecord::Base.logger = @original_logger - # end - # - # test "report warns in :warn mode" do - # line = __LINE__ + 1 - # DATS::Car.new.deprecated_tyres - # - # assert_message @io.string, line - # assert_includes @io.string, "\t#{__FILE__}:#{line}:in" - # end - # end - - # class WarnModeNoLoggerTest < TestCase - # def setup - # super - # ActiveRecord::Associations::Deprecation.mode = :warn - # - # @original_logger = ActiveRecord::Base.logger - # ActiveRecord::Base.logger = nil - # end - # - # def teardown - # super - # ActiveRecord::Base.logger = @original_logger - # end - # - # test "report does not assume the logger is present" do - # assert_nothing_raised { DATS::Car.new.deprecated_tyres } - # end - # end - - # class RaiseModeTest < TestCase - # def setup - # super - # ActiveRecord::Associations::Deprecation.mode = :raise - # end - # - # test "report raises an error in :raise mode" do - # error = assert_raises(ActiveRecord::DeprecatedAssociationError) { DATS::Car.new.deprecated_tyres } - # assert_message error.message, __LINE__ - 1 - # end - # end + class OptionsTest < TestCase + test "valid options, mode only" do + ActiveRecord.deprecated_associations_options = { mode: :warn } + assert_equal :warn, ActiveRecord::Associations::Deprecation.mode + assert_equal false, ActiveRecord::Associations::Deprecation.backtrace + end - class RaiseBacktraceModeTest < TestCase + test "valid options, backtrace only" do + ActiveRecord.deprecated_associations_options = { backtrace: true } + assert_equal :warn, ActiveRecord::Associations::Deprecation.mode + assert_equal true, ActiveRecord::Associations::Deprecation.backtrace + end + + test "valid options, both" do + ActiveRecord.deprecated_associations_options = { + mode: :notify, + backtrace: true + } + assert_equal :notify, ActiveRecord::Associations::Deprecation.mode + assert_equal true, ActiveRecord::Associations::Deprecation.backtrace + end + + test "not a hash" do + error = assert_raises(ArgumentError) do + ActiveRecord.deprecated_associations_options = :invalid + end + assert_equal "deprecated_associations_options must be a hash", error.message + end + + test "invalid keys" do + error = assert_raises(ArgumentError) do + ActiveRecord.deprecated_associations_options = { invalid: true } + end + assert_equal "invalid deprecated_associations_options key :invalid (valid keys are :mode and :backtrace)", error.message + end + + test "invalid mode" do + error = assert_raises(ArgumentError) do + ActiveRecord.deprecated_associations_options = { mode: :invalid } + end + assert_equal "invalid deprecated associations mode :invalid (valid modes are :warn, :raise, and :notify)", error.message + end + end + + class ModeWriterTest < TestCase + test "valid values" do + [:warn, :raise, :notify].each do |mode| + ActiveRecord::Associations::Deprecation.mode = mode + assert_equal mode, ActiveRecord::Associations::Deprecation.mode + end + end + + test "invalid values" do + error = assert_raises(ArgumentError) do + ActiveRecord::Associations::Deprecation.mode = :invalid + end + assert_equal "invalid deprecated associations mode :invalid (valid modes are :warn, :raise, and :notify)", error.message + end + + test "the backtrace flag becomes a true/false singleton" do + ActiveRecord::Associations::Deprecation.backtrace = 1 + assert_same true, ActiveRecord::Associations::Deprecation.backtrace + + ActiveRecord::Associations::Deprecation.backtrace = nil + assert_same false, ActiveRecord::Associations::Deprecation.backtrace + end + end + + class WarnModeTest < TestCase def setup super - ActiveRecord::Associations::Deprecation.mode = :raise + ActiveRecord::Associations::Deprecation.mode = :warn + + @original_logger = ActiveRecord::Base.logger + @io = StringIO.new + ActiveRecord::Base.logger = Logger.new(@io) + end + + def teardown + super + ActiveRecord::Base.logger = @original_logger + end + + test "report warns in :warn mode" do + DATS::Car.new.deprecated_tyres + assert_message @io.string, __LINE__ - 1 + end + end + + class WarnBacktraceModeTest < TestCase + def setup + super + ActiveRecord::Associations::Deprecation.mode = :warn ActiveRecord::Associations::Deprecation.backtrace = true + + @original_logger = ActiveRecord::Base.logger + @io = StringIO.new + ActiveRecord::Base.logger = Logger.new(@io) + end + + def teardown + super + ActiveRecord::Base.logger = @original_logger + end + + test "report warns in :warn mode" do + line = __LINE__ + 1 + DATS::Car.new.deprecated_tyres + + assert_message @io.string, line + assert_includes @io.string, "\t#{__FILE__}:#{line}:in" + end + end + + class WarnModeNoLoggerTest < TestCase + def setup + super + ActiveRecord::Associations::Deprecation.mode = :warn + + @original_logger = ActiveRecord::Base.logger + ActiveRecord::Base.logger = nil + end + + def teardown + super + ActiveRecord::Base.logger = @original_logger + end + + test "report does not assume the logger is present" do + assert_nothing_raised { DATS::Car.new.deprecated_tyres } + end + end + + class RaiseModeTest < TestCase + def setup + super + ActiveRecord::Associations::Deprecation.mode = :raise end test "report raises an error in :raise mode" do + error = assert_raises(ActiveRecord::DeprecatedAssociationError) { DATS::Car.new.deprecated_tyres } + assert_message error.message, __LINE__ - 1 + end + end - $AIDO = true + class RaiseBacktraceModeTest < TestCase + def setup + super + ActiveRecord::Associations::Deprecation.mode = :raise + ActiveRecord::Associations::Deprecation.backtrace = true + end + test "report raises an error in :raise mode" do line = __LINE__ + 1 error = assert_raises(ActiveRecord::DeprecatedAssociationError) { DATS::Car.new.deprecated_tyres } assert_message error.message, line - - binding.pry - assert_includes error.backtrace.last, "#{__FILE__}:#{line}:in" end end - # class NotifyModeTest < TestCase - # def setup - # super - # ActiveRecord::Associations::Deprecation.mode = :notify - # ActiveRecord::Associations::Deprecation.backtrace = true - # end - # - # def teardown - # super - # ActiveRecord::LogSubscriber.backtrace_cleaner = @original_backtrace_cleaner - # end - # - # def assert_user_facing_reflection(model, association) - # payloads = [] - # callback = ->(event) { payloads << event.payload } - # - # ActiveSupport::Notifications.subscribed(callback, "deprecated_association.active_record") do - # model.new.send(association) - # end - # - # assert_equal 1, payloads.size - # assert_equal model.reflect_on_association(association), payloads[0][:reflection] - # end - # - # test "report publishes an Active Support notification in :notify mode" do - # payloads = [] - # callback = ->(event) { payloads << event.payload } - # - # line = __LINE__ + 2 - # ActiveSupport::Notifications.subscribed(callback, "deprecated_association.active_record") do - # DATS::Car.new.deprecated_tyres - # end - # - # assert_equal 1, payloads.size - # payload = payloads.first - # - # assert_equal DATS::Car.reflect_on_association(:deprecated_tyres), payload[:reflection] - # - # assert_message payload[:message], line - # - # assert_equal __FILE__, payload[:location].path - # assert_equal line, payload[:location].lineno - # - # assert_equal __FILE__, payload[:backtrace][-2].path - # assert_equal line, payload[:backtrace][-2].lineno - # end - # - # test "has_many receives the user-facing reflection in the payload" do - # assert_user_facing_reflection(DATS::Author, :deprecated_posts) - # end - # - # test "has_one receives the user-facing reflection in the payload" do - # assert_user_facing_reflection(DATS::Author, :deprecated_post) - # end - # - # test "belongs_to receives the user-facing reflection in the payload" do - # assert_user_facing_reflection(DATS::Bulb, :deprecated_car) - # end - # - # test "has_many :through receives the user-facing reflection in the payload" do - # assert_user_facing_reflection(DATS::Author, :deprecated_has_many_through) - # end - # - # test "has_one :through receives the user-facing reflection in the payload" do - # assert_user_facing_reflection(DATS::Author, :deprecated_has_one_through) - # end - # - # test "HABTM receives the user-facing reflection in the payload" do - # assert_user_facing_reflection(DATS::Category, :deprecated_posts) - # end - # end + class NotifyModeTest < TestCase + def setup + super + ActiveRecord::Associations::Deprecation.mode = :notify + ActiveRecord::Associations::Deprecation.backtrace = true + end + + def teardown + super + ActiveRecord::LogSubscriber.backtrace_cleaner = @original_backtrace_cleaner + end + + def assert_user_facing_reflection(model, association) + payloads = [] + callback = ->(event) { payloads << event.payload } + + ActiveSupport::Notifications.subscribed(callback, "deprecated_association.active_record") do + model.new.send(association) + end + + assert_equal 1, payloads.size + assert_equal model.reflect_on_association(association), payloads[0][:reflection] + end + + test "report publishes an Active Support notification in :notify mode" do + payloads = [] + callback = ->(event) { payloads << event.payload } + + line = __LINE__ + 2 + ActiveSupport::Notifications.subscribed(callback, "deprecated_association.active_record") do + DATS::Car.new.deprecated_tyres + end + + assert_equal 1, payloads.size + payload = payloads.first + + assert_equal DATS::Car.reflect_on_association(:deprecated_tyres), payload[:reflection] + + assert_message payload[:message], line + + assert_equal __FILE__, payload[:location].path + assert_equal line, payload[:location].lineno + + assert_equal __FILE__, payload[:backtrace][-2].path + assert_equal line, payload[:backtrace][-2].lineno + end + + test "has_many receives the user-facing reflection in the payload" do + assert_user_facing_reflection(DATS::Author, :deprecated_posts) + end + + test "has_one receives the user-facing reflection in the payload" do + assert_user_facing_reflection(DATS::Author, :deprecated_post) + end + + test "belongs_to receives the user-facing reflection in the payload" do + assert_user_facing_reflection(DATS::Bulb, :deprecated_car) + end + + test "has_many :through receives the user-facing reflection in the payload" do + assert_user_facing_reflection(DATS::Author, :deprecated_has_many_through) + end + + test "has_one :through receives the user-facing reflection in the payload" do + assert_user_facing_reflection(DATS::Author, :deprecated_has_one_through) + end + + test "HABTM receives the user-facing reflection in the payload" do + assert_user_facing_reflection(DATS::Category, :deprecated_posts) + end + end end