diff options
Diffstat (limited to 'railties')
-rw-r--r-- | railties/RDOC_MAIN.rdoc | 6 | ||||
-rw-r--r-- | railties/README.rdoc | 2 | ||||
-rw-r--r-- | railties/lib/rails/autoloaders.rb | 12 | ||||
-rw-r--r-- | railties/lib/rails/engine.rb | 4 | ||||
-rw-r--r-- | railties/lib/rails/generators/app_base.rb | 2 | ||||
-rw-r--r-- | railties/lib/rails/generators/rails/db/system/change/change_generator.rb | 14 | ||||
-rw-r--r-- | railties/lib/rails/generators/test_unit/model/templates/fixtures.yml.tt | 2 | ||||
-rw-r--r-- | railties/railties.gemspec | 2 | ||||
-rw-r--r-- | railties/test/application/configuration_test.rb | 4 | ||||
-rw-r--r-- | railties/test/application/rake/dbs_test.rb | 4 | ||||
-rw-r--r-- | railties/test/application/test_test.rb | 2 | ||||
-rw-r--r-- | railties/test/backtrace_cleaner_test.rb | 2 | ||||
-rw-r--r-- | railties/test/generators/db_system_change_generator_test.rb | 21 | ||||
-rw-r--r-- | railties/test/isolation/abstract_unit.rb | 7 |
14 files changed, 64 insertions, 20 deletions
diff --git a/railties/RDOC_MAIN.rdoc b/railties/RDOC_MAIN.rdoc index 1c4252edd0..f1783a4737 100644 --- a/railties/RDOC_MAIN.rdoc +++ b/railties/RDOC_MAIN.rdoc @@ -4,7 +4,7 @@ \Rails is a web-application framework that includes everything needed to create database-backed web applications according to the -{Model-View-Controller (MVC)}[http://en.wikipedia.org/wiki/Model-view-controller] +{Model-View-Controller (MVC)}[https://en.wikipedia.org/wiki/Model-view-controller] pattern. Understanding the MVC pattern is key to understanding \Rails. MVC divides your @@ -79,7 +79,7 @@ and may also be used independently outside \Rails. * The \README file created within your application. * {Getting Started with \Rails}[https://guides.rubyonrails.org/getting_started.html]. * {Ruby on \Rails Guides}[https://guides.rubyonrails.org]. - * {The API Documentation}[http://api.rubyonrails.org]. + * {The API Documentation}[https://api.rubyonrails.org]. * {Ruby on \Rails Tutorial}[https://www.railstutorial.org/book]. == Contributing @@ -88,7 +88,7 @@ We encourage you to contribute to Ruby on \Rails! Please check out the {Contributing to Ruby on \Rails guide}[https://guides.rubyonrails.org/contributing_to_ruby_on_rails.html] for guidelines about how to proceed. {Join us!}[http://contributors.rubyonrails.org] Trying to report a possible security vulnerability in \Rails? Please -check out our {security policy}[http://rubyonrails.org/security/] for +check out our {security policy}[https://rubyonrails.org/security/] for guidelines about how to proceed. Everyone interacting in \Rails and its sub-projects' codebases, issue trackers, chat rooms, and mailing lists is expected to follow the \Rails {code of conduct}[http://rubyonrails.org/conduct/]. diff --git a/railties/README.rdoc b/railties/README.rdoc index 2715ccac3f..51437e3147 100644 --- a/railties/README.rdoc +++ b/railties/README.rdoc @@ -29,7 +29,7 @@ Railties is released under the MIT license: API documentation is at -* http://api.rubyonrails.org +* https://api.rubyonrails.org Bug reports can be filed for the Ruby on Rails project here: diff --git a/railties/lib/rails/autoloaders.rb b/railties/lib/rails/autoloaders.rb index a6974cc207..1bd3f18a74 100644 --- a/railties/lib/rails/autoloaders.rb +++ b/railties/lib/rails/autoloaders.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true +require "active_support/dependencies/zeitwerk_integration" + module Rails module Autoloaders # :nodoc: class << self @@ -7,13 +9,19 @@ module Rails def main if zeitwerk_enabled? - @main ||= Zeitwerk::Loader.new.tap { |loader| loader.tag = "rails.main" } + @main ||= Zeitwerk::Loader.new.tap do |loader| + loader.tag = "rails.main" + loader.inflector = ActiveSupport::Dependencies::ZeitwerkIntegration::Inflector + end end end def once if zeitwerk_enabled? - @once ||= Zeitwerk::Loader.new.tap { |loader| loader.tag = "rails.once" } + @once ||= Zeitwerk::Loader.new.tap do |loader| + loader.tag = "rails.once" + loader.inflector = ActiveSupport::Dependencies::ZeitwerkIntegration::Inflector + end end end diff --git a/railties/lib/rails/engine.rb b/railties/lib/rails/engine.rb index 76be6a8ac7..07bd56c978 100644 --- a/railties/lib/rails/engine.rb +++ b/railties/lib/rails/engine.rb @@ -530,9 +530,9 @@ module Rails # Defines the routes for this engine. If a block is given to # routes, it is appended to the engine. - def routes + def routes(&block) @routes ||= ActionDispatch::Routing::RouteSet.new_with_config(config) - @routes.append(&Proc.new) if block_given? + @routes.append(&block) if block_given? @routes end diff --git a/railties/lib/rails/generators/app_base.rb b/railties/lib/rails/generators/app_base.rb index 0eed552042..66f6b57379 100644 --- a/railties/lib/rails/generators/app_base.rb +++ b/railties/lib/rails/generators/app_base.rb @@ -316,7 +316,7 @@ module Rails if options.dev? || options.edge? GemfileEntry.github "webpacker", "rails/webpacker", nil, "Use development version of Webpacker" else - GemfileEntry.version "webpacker", ">= 4.0.0.rc.3", "Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker" + GemfileEntry.version "webpacker", "~> 4.0", "Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker" end end diff --git a/railties/lib/rails/generators/rails/db/system/change/change_generator.rb b/railties/lib/rails/generators/rails/db/system/change/change_generator.rb index 63849eb18d..24db92fad7 100644 --- a/railties/lib/rails/generators/rails/db/system/change/change_generator.rb +++ b/railties/lib/rails/generators/rails/db/system/change/change_generator.rb @@ -35,8 +35,9 @@ module Rails end def edit_gemfile - database_gem_name, _ = gem_for_database - gsub_file("Gemfile", all_database_gems_regex, database_gem_name) + name, version = gem_for_database + gsub_file("Gemfile", all_database_gems_regex, name) + gsub_file("Gemfile", gem_entry_regex_for(name), gem_entry_for(name, *version)) end private @@ -48,6 +49,15 @@ module Rails all_database_gem_names = all_database_gems.map(&:first) /(\b#{all_database_gem_names.join('\b|\b')}\b)/ end + + def gem_entry_regex_for(gem_name) + /^gem.*\b#{gem_name}\b.*/ + end + + def gem_entry_for(*gem_name_and_version) + gem_name_and_version.map! { |segment| "'#{segment}'" } + "gem #{gem_name_and_version.join(", ")}" + end end end end diff --git a/railties/lib/rails/generators/test_unit/model/templates/fixtures.yml.tt b/railties/lib/rails/generators/test_unit/model/templates/fixtures.yml.tt index 0681780c97..ee4ae47727 100644 --- a/railties/lib/rails/generators/test_unit/model/templates/fixtures.yml.tt +++ b/railties/lib/rails/generators/test_unit/model/templates/fixtures.yml.tt @@ -1,4 +1,4 @@ -# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html +# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html <% unless attributes.empty? -%> <% %w(one two).each do |name| %> <%= name %>: diff --git a/railties/railties.gemspec b/railties/railties.gemspec index 1bfb0dfe48..519b08746a 100644 --- a/railties/railties.gemspec +++ b/railties/railties.gemspec @@ -15,7 +15,7 @@ Gem::Specification.new do |s| s.author = "David Heinemeier Hansson" s.email = "david@loudthinking.com" - s.homepage = "http://rubyonrails.org" + s.homepage = "https://rubyonrails.org" s.files = Dir["CHANGELOG.md", "README.rdoc", "MIT-LICENSE", "RDOC_MAIN.rdoc", "exe/**/*", "lib/**/{*,.[a-z]*}"] s.require_path = "lib" diff --git a/railties/test/application/configuration_test.rb b/railties/test/application/configuration_test.rb index 73773602a3..9ba5517afd 100644 --- a/railties/test/application/configuration_test.rb +++ b/railties/test/application/configuration_test.rb @@ -1167,6 +1167,8 @@ module ApplicationTests assert_instance_of Zeitwerk::Loader, Rails.autoloaders.once assert_equal "rails.once", Rails.autoloaders.once.tag assert_equal [Rails.autoloaders.main, Rails.autoloaders.once], Rails.autoloaders.to_a + assert_equal ActiveSupport::Dependencies::ZeitwerkIntegration::Inflector, Rails.autoloaders.main.inflector + assert_equal ActiveSupport::Dependencies::ZeitwerkIntegration::Inflector, Rails.autoloaders.once.inflector config.autoloader = :classic assert_not Rails.autoloaders.zeitwerk_enabled? @@ -1181,6 +1183,8 @@ module ApplicationTests assert_instance_of Zeitwerk::Loader, Rails.autoloaders.once assert_equal "rails.once", Rails.autoloaders.once.tag assert_equal [Rails.autoloaders.main, Rails.autoloaders.once], Rails.autoloaders.to_a + assert_equal ActiveSupport::Dependencies::ZeitwerkIntegration::Inflector, Rails.autoloaders.main.inflector + assert_equal ActiveSupport::Dependencies::ZeitwerkIntegration::Inflector, Rails.autoloaders.once.inflector assert_raises(ArgumentError) { config.autoloader = :unknown } end diff --git a/railties/test/application/rake/dbs_test.rb b/railties/test/application/rake/dbs_test.rb index 07d57dea8a..4f689bcb78 100644 --- a/railties/test/application/rake/dbs_test.rb +++ b/railties/test/application/rake/dbs_test.rb @@ -131,7 +131,7 @@ module ApplicationTests end end - test "db:truncate_all truncates all not internal tables" do + test "db:truncate_all truncates all non-internal tables" do Dir.chdir(app_path) do rails "generate", "model", "book", "title:string" rails "db:migrate" @@ -433,7 +433,7 @@ module ApplicationTests assert_equal "test", test_environment.call end - test "db:seed:replant truncates all not internal tables and loads the seeds" do + test "db:seed:replant truncates all non-internal tables and loads the seeds" do Dir.chdir(app_path) do rails "generate", "model", "book", "title:string" rails "db:migrate" diff --git a/railties/test/application/test_test.rb b/railties/test/application/test_test.rb index fb43bebfbe..83e63718df 100644 --- a/railties/test/application/test_test.rb +++ b/railties/test/application/test_test.rb @@ -234,7 +234,7 @@ module ApplicationTests # TODO: would be nice if we could detect the schema change automatically. # For now, the user has to synchronize the schema manually. - # This test-case serves as a reminder for this use-case. + # This test case serves as a reminder for this use case. test "manually synchronize test schema after rollback" do output = rails("generate", "model", "user", "name:string") version = output.match(/(\d+)_create_users\.rb/)[1] diff --git a/railties/test/backtrace_cleaner_test.rb b/railties/test/backtrace_cleaner_test.rb index 90e084ddca..ec512b6b64 100644 --- a/railties/test/backtrace_cleaner_test.rb +++ b/railties/test/backtrace_cleaner_test.rb @@ -18,7 +18,7 @@ class BacktraceCleanerTest < ActiveSupport::TestCase end test "should omit ActionView template methods names" do - method_name = ActionView::Template.new(nil, "app/views/application/index.html.erb", nil, {}).send :method_name + method_name = ActionView::Template.new(nil, "app/views/application/index.html.erb", nil, locals: []).send :method_name backtrace = [ "app/views/application/index.html.erb:4:in `block in #{method_name}'"] result = @cleaner.clean(backtrace, :all) assert_equal "app/views/application/index.html.erb:4", result[0] diff --git a/railties/test/generators/db_system_change_generator_test.rb b/railties/test/generators/db_system_change_generator_test.rb index d476bfd2dc..d3d27b616a 100644 --- a/railties/test/generators/db_system_change_generator_test.rb +++ b/railties/test/generators/db_system_change_generator_test.rb @@ -40,7 +40,7 @@ module Rails assert_file("Gemfile") do |content| assert_match "# Use pg as the database for Active Record", content - assert_match "gem 'pg'", content + assert_match "gem 'pg', '>= 0.18', '< 2.0'", content end end @@ -54,7 +54,7 @@ module Rails assert_file("Gemfile") do |content| assert_match "# Use mysql2 as the database for Active Record", content - assert_match "gem 'mysql2'", content + assert_match "gem 'mysql2', '>= 0.4.4'", content end end @@ -68,7 +68,22 @@ module Rails assert_file("Gemfile") do |content| assert_match "# Use sqlite3 as the database for Active Record", content - assert_match "gem 'sqlite3'", content + assert_match "gem 'sqlite3', '~> 1.3', '>= 1.3.6'", content + end + end + + test "change from versioned gem to other versioned gem" do + run_generator ["--to", "sqlite3"] + run_generator ["--to", "mysql", "--force"] + + assert_file("config/database.yml") do |content| + assert_match "adapter: mysql2", content + assert_match "database: test_app", content + end + + assert_file("Gemfile") do |content| + assert_match "# Use mysql2 as the database for Active Record", content + assert_match "gem 'mysql2', '>= 0.4.4'", content end end end diff --git a/railties/test/isolation/abstract_unit.rb b/railties/test/isolation/abstract_unit.rb index 3f1638a516..b0662e0159 100644 --- a/railties/test/isolation/abstract_unit.rb +++ b/railties/test/isolation/abstract_unit.rb @@ -488,7 +488,14 @@ Module.new do f.puts "require 'rails/all'" end + unless File.exist?("#{RAILS_FRAMEWORK_ROOT}/actionview/lib/assets/compiled/rails-ujs.js") + Dir.chdir("#{RAILS_FRAMEWORK_ROOT}/actionview") { `yarn build` } + end + assets_path = "#{RAILS_FRAMEWORK_ROOT}/railties/test/isolation/assets" + unless Dir.exist?("#{assets_path}/node_modules") + Dir.chdir(assets_path) { `yarn install` } + end FileUtils.cp("#{assets_path}/package.json", "#{app_template_path}/package.json") FileUtils.cp("#{assets_path}/config/webpacker.yml", "#{app_template_path}/config/webpacker.yml") FileUtils.cp_r("#{assets_path}/config/webpack", "#{app_template_path}/config/webpack") |