From 2dafc4be2285bc2cb32983be6f16296319b40e25 Mon Sep 17 00:00:00 2001 From: "yuuji.yaginuma" Date: Thu, 22 Jun 2017 08:08:45 +0900 Subject: [PATCH] Do not use private API in bug report templates `ActiveRecord::Migrator` is private API. https://github.com/rails/rails/blob/bb9d6eb094f29bb94ef1f26aa44f145f17b973fe/activerecord/lib/active_record/migration.rb#L977 Therefore, it is not good to use it in bug report templates. Instead, should use the public API `ActiveRecord::Migration#migrate`. --- guides/bug_report_templates/active_record_migrations_gem.rb | 6 ++---- .../bug_report_templates/active_record_migrations_master.rb | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/guides/bug_report_templates/active_record_migrations_gem.rb b/guides/bug_report_templates/active_record_migrations_gem.rb index 0c398e334a..00ba3c1cd6 100644 --- a/guides/bug_report_templates/active_record_migrations_gem.rb +++ b/guides/bug_report_templates/active_record_migrations_gem.rb @@ -48,16 +48,14 @@ end class BugTest < Minitest::Test def test_migration_up - migrator = ActiveRecord::Migrator.new(:up, [ChangeAmountToAddScale]) - migrator.run + ChangeAmountToAddScale.migrate(:up) Payment.reset_column_information assert_equal "decimal(10,2)", Payment.columns.last.sql_type end def test_migration_down - migrator = ActiveRecord::Migrator.new(:down, [ChangeAmountToAddScale]) - migrator.run + ChangeAmountToAddScale.migrate(:down) Payment.reset_column_information assert_equal "decimal(10,0)", Payment.columns.last.sql_type diff --git a/guides/bug_report_templates/active_record_migrations_master.rb b/guides/bug_report_templates/active_record_migrations_master.rb index 84a4b71909..52c9028b0f 100644 --- a/guides/bug_report_templates/active_record_migrations_master.rb +++ b/guides/bug_report_templates/active_record_migrations_master.rb @@ -48,16 +48,14 @@ end class BugTest < Minitest::Test def test_migration_up - migrator = ActiveRecord::Migrator.new(:up, [ChangeAmountToAddScale]) - migrator.run + ChangeAmountToAddScale.migrate(:up) Payment.reset_column_information assert_equal "decimal(10,2)", Payment.columns.last.sql_type end def test_migration_down - migrator = ActiveRecord::Migrator.new(:down, [ChangeAmountToAddScale]) - migrator.run + ChangeAmountToAddScale.migrate(:down) Payment.reset_column_information assert_equal "decimal(10,0)", Payment.columns.last.sql_type