diff options
Diffstat (limited to 'railties')
-rw-r--r-- | railties/CHANGELOG.md | 10 | ||||
-rw-r--r-- | railties/lib/rails/all.rb | 4 | ||||
-rw-r--r-- | railties/lib/rails/gem_version.rb | 2 | ||||
-rw-r--r-- | railties/lib/rails/generators/rails/app/app_generator.rb | 5 | ||||
-rw-r--r-- | railties/lib/rails/generators/rails/app/templates/config/initializers/to_time_preserves_timezone.rb | 10 | ||||
-rw-r--r-- | railties/lib/rails/generators/rails/plugin/templates/Rakefile | 2 | ||||
-rw-r--r-- | railties/lib/rails/tasks/routes.rake | 3 | ||||
-rw-r--r-- | railties/lib/rails/tasks/statistics.rake | 1 | ||||
-rw-r--r-- | railties/lib/rails/test_unit/minitest_plugin.rb | 7 | ||||
-rw-r--r-- | railties/test/application/configuration_test.rb | 2 | ||||
-rw-r--r-- | railties/test/application/rake/dev_test.rb | 2 | ||||
-rw-r--r-- | railties/test/application/rake_test.rb | 15 | ||||
-rw-r--r-- | railties/test/application/test_runner_test.rb | 8 | ||||
-rw-r--r-- | railties/test/generators/app_generator_test.rb | 28 |
14 files changed, 86 insertions, 13 deletions
diff --git a/railties/CHANGELOG.md b/railties/CHANGELOG.md index 32bfdf272b..ed3a3e8527 100644 --- a/railties/CHANGELOG.md +++ b/railties/CHANGELOG.md @@ -1,3 +1,13 @@ +## Rails 5.0.0.beta4 (April 27, 2016) ## + +* Add `config/initializers/to_time_preserves_timezone.rb`, which tells + Active Support to preserve the receiver's timezone when calling `to_time`. + This matches the new behavior that will be part of Ruby 2.4. + + Fixes #24617. + + *Andrew White* + * Make `rails restart` command work with Puma by passing the restart command which Puma can use to restart rails server. diff --git a/railties/lib/rails/all.rb b/railties/lib/rails/all.rb index 11f4d5c4bc..1a7f7855f1 100644 --- a/railties/lib/rails/all.rb +++ b/railties/lib/rails/all.rb @@ -1,4 +1,4 @@ -require "rails" +require 'rails' %w( active_record/railtie @@ -11,7 +11,7 @@ require "rails" sprockets/railtie ).each do |railtie| begin - require "#{railtie}" + require railtie rescue LoadError end end diff --git a/railties/lib/rails/gem_version.rb b/railties/lib/rails/gem_version.rb index 081222425c..08a331bff2 100644 --- a/railties/lib/rails/gem_version.rb +++ b/railties/lib/rails/gem_version.rb @@ -8,7 +8,7 @@ module Rails MAJOR = 5 MINOR = 0 TINY = 0 - PRE = "beta3" + PRE = "beta4" STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".") end diff --git a/railties/lib/rails/generators/rails/app/app_generator.rb b/railties/lib/rails/generators/rails/app/app_generator.rb index f58e6ba653..4d5bb364b2 100644 --- a/railties/lib/rails/generators/rails/app/app_generator.rb +++ b/railties/lib/rails/generators/rails/app/app_generator.rb @@ -92,6 +92,7 @@ module Rails cookie_serializer_config_exist = File.exist?('config/initializers/cookies_serializer.rb') callback_terminator_config_exist = File.exist?('config/initializers/callback_terminator.rb') active_record_belongs_to_required_by_default_config_exist = File.exist?('config/initializers/active_record_belongs_to_required_by_default.rb') + to_time_preserves_timezone_config_exist = File.exist?('config/initializers/to_time_preserves_timezone.rb') action_cable_config_exist = File.exist?('config/cable.yml') ssl_options_exist = File.exist?('config/initializers/ssl_options.rb') rack_cors_config_exist = File.exist?('config/initializers/cors.rb') @@ -112,6 +113,10 @@ module Rails remove_file 'config/initializers/active_record_belongs_to_required_by_default.rb' end + unless to_time_preserves_timezone_config_exist + remove_file 'config/initializers/to_time_preserves_timezone.rb' + end + unless action_cable_config_exist template 'config/cable.yml' end diff --git a/railties/lib/rails/generators/rails/app/templates/config/initializers/to_time_preserves_timezone.rb b/railties/lib/rails/generators/rails/app/templates/config/initializers/to_time_preserves_timezone.rb new file mode 100644 index 0000000000..8674be3227 --- /dev/null +++ b/railties/lib/rails/generators/rails/app/templates/config/initializers/to_time_preserves_timezone.rb @@ -0,0 +1,10 @@ +# Be sure to restart your server when you modify this file. + +# Preserve the timezone of the receiver when calling to `to_time`. +# Ruby 2.4 will change the behavior of `to_time` to preserve the timezone +# when converting to an instance of `Time` instead of the previous behavior +# of converting to the local system timezone. +# +# Rails 5.0 introduced this config option so that apps made with earlier +# versions of Rails are not affected when upgrading. +ActiveSupport.to_time_preserves_timezone = true diff --git a/railties/lib/rails/generators/rails/plugin/templates/Rakefile b/railties/lib/rails/generators/rails/plugin/templates/Rakefile index f1943644e4..383d2fb2d1 100644 --- a/railties/lib/rails/generators/rails/plugin/templates/Rakefile +++ b/railties/lib/rails/generators/rails/plugin/templates/Rakefile @@ -25,5 +25,5 @@ load 'rails/tasks/statistics.rake' <% unless options[:skip_gemspec] -%> -Bundler::GemHelper.install_tasks +require 'bundler/gem_tasks' <% end %> diff --git a/railties/lib/rails/tasks/routes.rake b/railties/lib/rails/tasks/routes.rake index 69103aa5d9..ff7233cae9 100644 --- a/railties/lib/rails/tasks/routes.rake +++ b/railties/lib/rails/tasks/routes.rake @@ -19,6 +19,9 @@ task routes: :environment do OptionParser.new do |opts| opts.banner = "Usage: rails routes [options]" + + Rake.application.standard_rake_options.each { |args| opts.on(*args) } + opts.on("-c CONTROLLER") do |controller| routes_filter = { controller: controller } end diff --git a/railties/lib/rails/tasks/statistics.rake b/railties/lib/rails/tasks/statistics.rake index a919d36939..3e40d3b037 100644 --- a/railties/lib/rails/tasks/statistics.rake +++ b/railties/lib/rails/tasks/statistics.rake @@ -7,6 +7,7 @@ STATS_DIRECTORIES = [ %w(Jobs app/jobs), %w(Models app/models), %w(Mailers app/mailers), + %w(Channels app/channels), %w(Javascripts app/assets/javascripts), %w(Libraries lib/), %w(Tasks lib/tasks), diff --git a/railties/lib/rails/test_unit/minitest_plugin.rb b/railties/lib/rails/test_unit/minitest_plugin.rb index e9195d5b4e..076ab536be 100644 --- a/railties/lib/rails/test_unit/minitest_plugin.rb +++ b/railties/lib/rails/test_unit/minitest_plugin.rb @@ -54,7 +54,7 @@ module Minitest options[:color] = true options[:output_inline] = true - options[:patterns] = opts.order! + options[:patterns] = defined?(@rake_patterns) ? @rake_patterns : opts.order! end # Running several Rake tasks in a single command would trip up the runner, @@ -73,10 +73,7 @@ module Minitest ENV["RAILS_ENV"] = options[:environment] || "test" - unless run_with_autorun - patterns = defined?(@rake_patterns) ? @rake_patterns : options[:patterns] - ::Rails::TestRequirer.require_files(patterns) - end + ::Rails::TestRequirer.require_files(options[:patterns]) unless run_with_autorun unless options[:full_backtrace] || ENV["BACKTRACE"] # Plugin can run without Rails loaded, check before filtering. diff --git a/railties/test/application/configuration_test.rb b/railties/test/application/configuration_test.rb index decc4d138d..1ca6bbcecf 100644 --- a/railties/test/application/configuration_test.rb +++ b/railties/test/application/configuration_test.rb @@ -1464,7 +1464,7 @@ module ApplicationTests assert_equal :api, Rails.configuration.debug_exception_response_format end - test "debug_exception_response_format can be overriden" do + test "debug_exception_response_format can be overridden" do add_to_config <<-RUBY config.api_only = true RUBY diff --git a/railties/test/application/rake/dev_test.rb b/railties/test/application/rake/dev_test.rb index deb9bc8dee..2330ad3535 100644 --- a/railties/test/application/rake/dev_test.rb +++ b/railties/test/application/rake/dev_test.rb @@ -34,7 +34,7 @@ module ApplicationTests Dir.chdir(app_path) do FileUtils.mkdir_p("tmp/pids") FileUtils.touch("tmp/pids/server.pid") - `rake dev:cache` + `rails dev:cache` assert_not File.exist?("tmp/pids/server.pid") end end diff --git a/railties/test/application/rake_test.rb b/railties/test/application/rake_test.rb index 1a786a3fd3..acdb4e7d79 100644 --- a/railties/test/application/rake_test.rb +++ b/railties/test/application/rake_test.rb @@ -118,8 +118,8 @@ module ApplicationTests end def test_code_statistics_sanity - assert_match "Code LOC: 18 Test LOC: 0 Code to Test Ratio: 1:0.0", - Dir.chdir(app_path){ `bin/rails stats` } + assert_match "Code LOC: 26 Test LOC: 0 Code to Test Ratio: 1:0.0", + Dir.chdir(app_path) { `bin/rails stats` } end def test_rails_routes_calls_the_route_inspector @@ -228,6 +228,17 @@ module ApplicationTests MESSAGE end + def test_rake_routes_with_rake_options + app_file "config/routes.rb", <<-RUBY + Rails.application.routes.draw do + get '/cart', to: 'cart#show' + end + RUBY + + output = Dir.chdir(app_path){ `bin/rake --rakefile Rakefile routes` } + assert_equal "Prefix Verb URI Pattern Controller#Action\n cart GET /cart(.:format) cart#show\n", output + end + def test_logger_is_flushed_when_exiting_production_rake_tasks add_to_config <<-RUBY rake_tasks do diff --git a/railties/test/application/test_runner_test.rb b/railties/test/application/test_runner_test.rb index a1735db5b3..08759ab5a4 100644 --- a/railties/test/application/test_runner_test.rb +++ b/railties/test/application/test_runner_test.rb @@ -502,6 +502,14 @@ module ApplicationTests assert_match '1 runs, 1 assertions', output end + def test_pass_rake_options + create_test_file :models, 'account' + output = Dir.chdir(app_path) { `bin/rake --rakefile Rakefile --trace=stdout test` } + + assert_match '1 runs, 1 assertions', output + assert_match 'Execute test', output + end + def test_rails_db_create_all_restores_db_connection create_test_file :models, 'account' output = Dir.chdir(app_path) { `bin/rails db:create:all db:migrate && echo ".tables" | rails dbconsole` } diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb index 2d9867fa9d..25a8635e7d 100644 --- a/railties/test/generators/app_generator_test.rb +++ b/railties/test/generators/app_generator_test.rb @@ -257,6 +257,34 @@ class AppGeneratorTest < Rails::Generators::TestCase end end + def test_rails_update_does_not_create_to_time_preserves_timezone + app_root = File.join(destination_root, 'myapp') + run_generator [app_root] + + FileUtils.rm("#{app_root}/config/initializers/to_time_preserves_timezone.rb") + + stub_rails_application(app_root) do + generator = Rails::Generators::AppGenerator.new ["rails"], [], destination_root: app_root, shell: @shell + generator.send(:app_const) + quietly { generator.send(:update_config_files) } + assert_no_file "#{app_root}/config/initializers/to_time_preserves_timezone.rb" + end + end + + def test_rails_update_does_not_remove_to_time_preserves_timezone_if_already_present + app_root = File.join(destination_root, 'myapp') + run_generator [app_root] + + FileUtils.touch("#{app_root}/config/initializers/to_time_preserves_timezone.rb") + + stub_rails_application(app_root) do + generator = Rails::Generators::AppGenerator.new ["rails"], [], destination_root: app_root, shell: @shell + generator.send(:app_const) + quietly { generator.send(:update_config_files) } + assert_file "#{app_root}/config/initializers/to_time_preserves_timezone.rb" + end + end + def test_rails_update_does_not_create_ssl_options_by_default app_root = File.join(destination_root, 'myapp') run_generator [app_root] |