aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
Diffstat (limited to 'railties')
-rw-r--r--railties/CHANGELOG.md20
-rw-r--r--railties/lib/rails/application.rb6
-rw-r--r--railties/lib/rails/engine.rb16
-rw-r--r--railties/lib/rails/engine/configuration.rb24
-rw-r--r--railties/lib/rails/engine/railties.rb29
-rw-r--r--railties/lib/rails/generators/rails/app/app_generator.rb2
-rw-r--r--railties/lib/rails/generators/rails/app/templates/bin/bundle1
-rw-r--r--railties/lib/rails/generators/rails/app/templates/config/application.rb8
-rw-r--r--railties/lib/rails/generators/rails/app/templates/config/initializers/locale.rb9
-rw-r--r--railties/lib/rails/info.rb2
-rw-r--r--railties/lib/rails/paths.rb44
-rw-r--r--railties/railties.gemspec2
-rw-r--r--railties/test/application/configuration_test.rb60
-rw-r--r--railties/test/application/initializers/load_path_test.rb2
-rw-r--r--railties/test/application/paths_test.rb10
-rw-r--r--railties/test/application/runner_test.rb12
-rw-r--r--railties/test/generators/app_generator_test.rb5
-rw-r--r--railties/test/paths_test.rb56
-rw-r--r--railties/test/railties/engine_test.rb6
-rw-r--r--railties/test/railties/mounted_engine_test.rb9
20 files changed, 222 insertions, 101 deletions
diff --git a/railties/CHANGELOG.md b/railties/CHANGELOG.md
index 5dbca2e9b4..c6ffe30ad3 100644
--- a/railties/CHANGELOG.md
+++ b/railties/CHANGELOG.md
@@ -1,5 +1,25 @@
## Rails 4.0.0 (unreleased) ##
+* Fixes database.yml when creating a new rails application with '.'
+ Fix #8304
+
+ *Jeremy W. Rowe*
+
+* Deprecate the `eager_load_paths` configuration and alias it to `autoload_paths`.
+ Since the default in Rails 4.0 is to run in 'threadsafe' mode we need to eager
+ load all of the paths in `autoload_paths`. This may have unintended consequences
+ if you have added 'lib' to `autoload_paths` such as loading unneeded code or
+ code intended only for development and/or test environments. If this applies to
+ your application you should thoroughly check what is being eager loaded.
+
+ *Andrew White*
+
+* Restore Rails::Engine::Railties#engines with deprecation to ensure
+ compatibility with gems such as Thinking Sphinx
+ Fix #8551
+
+ *Tim Raymond*
+
* Specify which logs to clear when using the `rake log:clear` task.
(e.g. rake log:clear LOGS=test,staging)
diff --git a/railties/lib/rails/application.rb b/railties/lib/rails/application.rb
index cff75872b2..05cc49d40a 100644
--- a/railties/lib/rails/application.rb
+++ b/railties/lib/rails/application.rb
@@ -55,6 +55,7 @@ module Rails
autoload :Bootstrap, 'rails/application/bootstrap'
autoload :Configuration, 'rails/application/configuration'
autoload :Finisher, 'rails/application/finisher'
+ autoload :Railties, 'rails/engine/railties'
autoload :RoutesReloader, 'rails/application/routes_reloader'
class << self
@@ -232,11 +233,6 @@ module Rails
config.helpers_paths
end
- def railties #:nodoc:
- @railties ||= Rails::Railtie.subclasses.map(&:instance) +
- Rails::Engine.subclasses.map(&:instance)
- end
-
protected
alias :build_middleware_stack :app
diff --git a/railties/lib/rails/engine.rb b/railties/lib/rails/engine.rb
index 0ae2f16aba..8a6d1f34aa 100644
--- a/railties/lib/rails/engine.rb
+++ b/railties/lib/rails/engine.rb
@@ -34,9 +34,8 @@ module Rails
# == Configuration
#
# Besides the +Railtie+ configuration which is shared across the application, in a
- # <tt>Rails::Engine</tt> you can access <tt>autoload_paths</tt>, <tt>eager_load_paths</tt>
- # and <tt>autoload_once_paths</tt>, which, differently from a <tt>Railtie</tt>, are scoped to
- # the current engine.
+ # <tt>Rails::Engine</tt> you can access <tt>autoload_paths</tt> and <tt>autoload_once_paths</tt>,
+ # which, differently from a <tt>Railtie</tt>, are scoped to the current engine.
#
# class MyEngine < Rails::Engine
# # Add a load path for this specific Engine
@@ -456,9 +455,9 @@ module Rails
end
# Eager load the application by loading all ruby
- # files inside eager_load paths.
+ # files inside autoload_paths.
def eager_load!
- config.eager_load_paths.each do |load_path|
+ config.autoload_paths.each do |load_path|
matcher = /\A#{Regexp.escape(load_path)}\/(.*)\.rb\Z/
Dir.glob("#{load_path}/**/*.rb").sort.each do |file|
require_dependency file.sub(matcher, '\1')
@@ -466,6 +465,10 @@ module Rails
end
end
+ def railties
+ @railties ||= self.class::Railties.new
+ end
+
# Returns a module with all the helpers defined for the engine.
def helpers
@helpers ||= begin
@@ -554,7 +557,6 @@ module Rails
# Freeze so future modifications will fail rather than do nothing mysteriously
config.autoload_paths.freeze
- config.eager_load_paths.freeze
config.autoload_once_paths.freeze
end
@@ -667,7 +669,7 @@ module Rails
end
def _all_autoload_paths #:nodoc:
- @_all_autoload_paths ||= (config.autoload_paths + config.eager_load_paths + config.autoload_once_paths).uniq
+ @_all_autoload_paths ||= (config.autoload_paths + config.autoload_once_paths).uniq
end
def _all_load_paths #:nodoc:
diff --git a/railties/lib/rails/engine/configuration.rb b/railties/lib/rails/engine/configuration.rb
index 10d1821709..2b23d8be38 100644
--- a/railties/lib/rails/engine/configuration.rb
+++ b/railties/lib/rails/engine/configuration.rb
@@ -4,7 +4,7 @@ module Rails
class Engine
class Configuration < ::Rails::Railtie::Configuration
attr_reader :root
- attr_writer :middleware, :eager_load_paths, :autoload_once_paths, :autoload_paths
+ attr_writer :middleware, :autoload_once_paths, :autoload_paths
def initialize(root=nil)
super()
@@ -39,16 +39,16 @@ module Rails
@paths ||= begin
paths = Rails::Paths::Root.new(@root)
- paths.add "app", eager_load: true, glob: "*"
+ paths.add "app", autoload: true, glob: "*"
paths.add "app/assets", glob: "*"
- paths.add "app/controllers", eager_load: true
- paths.add "app/helpers", eager_load: true
- paths.add "app/models", eager_load: true
- paths.add "app/mailers", eager_load: true
+ paths.add "app/controllers", autoload: true
+ paths.add "app/helpers", autoload: true
+ paths.add "app/models", autoload: true
+ paths.add "app/mailers", autoload: true
paths.add "app/views"
- paths.add "app/controllers/concerns", eager_load: true
- paths.add "app/models/concerns", eager_load: true
+ paths.add "app/controllers/concerns", autoload: true
+ paths.add "app/models/concerns", autoload: true
paths.add "lib", load_path: true
paths.add "lib/assets", glob: "*"
@@ -76,7 +76,13 @@ module Rails
end
def eager_load_paths
- @eager_load_paths ||= paths.eager_load
+ ActiveSupport::Deprecation.warn "eager_load_paths is deprecated and all autoload_paths are now eagerly loaded."
+ autoload_paths
+ end
+
+ def eager_load_paths=(paths)
+ ActiveSupport::Deprecation.warn "eager_load_paths is deprecated and all autoload_paths are now eagerly loaded."
+ self.autoload_paths = paths
end
def autoload_once_paths
diff --git a/railties/lib/rails/engine/railties.rb b/railties/lib/rails/engine/railties.rb
new file mode 100644
index 0000000000..1081700cd0
--- /dev/null
+++ b/railties/lib/rails/engine/railties.rb
@@ -0,0 +1,29 @@
+module Rails
+ class Engine < Railtie
+ class Railties
+ include Enumerable
+ attr_reader :_all
+
+ def initialize
+ @_all ||= ::Rails::Railtie.subclasses.map(&:instance) +
+ ::Rails::Engine.subclasses.map(&:instance)
+ end
+
+ def self.engines
+ @engines ||= ::Rails::Engine.subclasses.map(&:instance)
+ end
+
+ def each(*args, &block)
+ _all.each(*args, &block)
+ end
+
+ def -(others)
+ _all - others
+ end
+
+ delegate :engines, to: "self.class"
+ end
+ end
+end
+
+ActiveSupport::Deprecation.deprecate_methods(Rails::Engine::Railties, :engines)
diff --git a/railties/lib/rails/generators/rails/app/app_generator.rb b/railties/lib/rails/generators/rails/app/app_generator.rb
index e22be40381..b2d1be9b51 100644
--- a/railties/lib/rails/generators/rails/app/app_generator.rb
+++ b/railties/lib/rails/generators/rails/app/app_generator.rb
@@ -236,7 +236,7 @@ module Rails
end
def app_name
- @app_name ||= defined_app_const_base? ? defined_app_name : File.basename(destination_root)
+ @app_name ||= (defined_app_const_base? ? defined_app_name : File.basename(destination_root)).tr(".", "_")
end
def defined_app_name
diff --git a/railties/lib/rails/generators/rails/app/templates/bin/bundle b/railties/lib/rails/generators/rails/app/templates/bin/bundle
index e0df7f4440..1123dcf501 100644
--- a/railties/lib/rails/generators/rails/app/templates/bin/bundle
+++ b/railties/lib/rails/generators/rails/app/templates/bin/bundle
@@ -1,3 +1,2 @@
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
-require 'rubygems'
load Gem.bin_path('bundler', 'bundle')
diff --git a/railties/lib/rails/generators/rails/app/templates/config/application.rb b/railties/lib/rails/generators/rails/app/templates/config/application.rb
index f5d7d698a3..d149413e2e 100644
--- a/railties/lib/rails/generators/rails/app/templates/config/application.rb
+++ b/railties/lib/rails/generators/rails/app/templates/config/application.rb
@@ -22,6 +22,14 @@ module <%= app_const_base %>
# Custom directories with classes and modules you want to be autoloadable.
# config.autoload_paths += %W(#{config.root}/extras)
+
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
+ # config.time_zone = 'Central Time (US & Canada)'
+
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
+ # config.i18n.default_locale = :de
<% if options.skip_sprockets? -%>
# Disable the asset pipeline.
diff --git a/railties/lib/rails/generators/rails/app/templates/config/initializers/locale.rb b/railties/lib/rails/generators/rails/app/templates/config/initializers/locale.rb
deleted file mode 100644
index d89dac7c6a..0000000000
--- a/railties/lib/rails/generators/rails/app/templates/config/initializers/locale.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-# Be sure to restart your server when you modify this file.
-
-# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
-# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
-# Rails.application.config.time_zone = 'Central Time (US & Canada)'
-
-# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
-# Rails.application.config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
-# Rails.application.config.i18n.default_locale = :de
diff --git a/railties/lib/rails/info.rb b/railties/lib/rails/info.rb
index aacc1be2fc..592e74726e 100644
--- a/railties/lib/rails/info.rb
+++ b/railties/lib/rails/info.rb
@@ -46,7 +46,7 @@ module Rails
alias inspect to_s
def to_html
- (table = '<table>').tap do
+ '<table>'.tap do |table|
properties.each do |(name, value)|
table << %(<tr><td class="name">#{CGI.escapeHTML(name.to_s)}</td>)
formatted_value = if value.kind_of?(Array)
diff --git a/railties/lib/rails/paths.rb b/railties/lib/rails/paths.rb
index de6795eda2..80ba144441 100644
--- a/railties/lib/rails/paths.rb
+++ b/railties/lib/rails/paths.rb
@@ -5,13 +5,13 @@ module Rails
# paths by a Hash like API. It requires you to give a physical path on initialization.
#
# root = Root.new "/rails"
- # root.add "app/controllers", eager_load: true
+ # root.add "app/controllers", autoload: true
#
# The command above creates a new root object and add "app/controllers" as a path.
# This means we can get a <tt>Rails::Paths::Path</tt> object back like below:
#
# path = root["app/controllers"]
- # path.eager_load? # => true
+ # path.autoload? # => true
# path.is_a?(Rails::Paths::Path) # => true
#
# The +Path+ object is simply an enumerable and allows you to easily add extra paths:
@@ -30,7 +30,7 @@ module Rails
# root["config/routes"].inspect # => ["config/routes.rb"]
#
# The +add+ method accepts the following options as arguments:
- # eager_load, autoload, autoload_once and glob.
+ # autoload, autoload_once and glob.
#
# Finally, the +Path+ object also provides a few helpers:
#
@@ -85,7 +85,8 @@ module Rails
end
def eager_load
- filter_by(:eager_load?)
+ ActiveSupport::Deprecation.warn "eager_load is deprecated and all autoload_paths are now eagerly loaded."
+ filter_by(:autoload?)
end
def autoload_paths
@@ -124,9 +125,13 @@ module Rails
@glob = options[:glob]
options[:autoload_once] ? autoload_once! : skip_autoload_once!
- options[:eager_load] ? eager_load! : skip_eager_load!
options[:autoload] ? autoload! : skip_autoload!
options[:load_path] ? load_path! : skip_load_path!
+
+ if !options.key?(:autoload) && options.key?(:eager_load)
+ ActiveSupport::Deprecation.warn "the :eager_load option is deprecated and all :autoload paths are now eagerly loaded."
+ options[:eager_load] ? autoload! : skip_autoload!
+ end
end
def children
@@ -143,22 +148,37 @@ module Rails
expanded.last
end
- %w(autoload_once eager_load autoload load_path).each do |m|
+ %w(autoload_once autoload load_path).each do |m|
class_eval <<-RUBY, __FILE__, __LINE__ + 1
- def #{m}! # def eager_load!
- @#{m} = true # @eager_load = true
+ def #{m}! # def autoload!
+ @#{m} = true # @autoload = true
end # end
#
- def skip_#{m}! # def skip_eager_load!
- @#{m} = false # @eager_load = false
+ def skip_#{m}! # def skip_autoload!
+ @#{m} = false # @autoload = false
end # end
#
- def #{m}? # def eager_load?
- @#{m} # @eager_load
+ def #{m}? # def autoload?
+ @#{m} # @autoload
end # end
RUBY
end
+ def eager_load!
+ ActiveSupport::Deprecation.warn "eager_load paths are deprecated and all autoload paths are now eagerly loaded."
+ autoload!
+ end
+
+ def skip_eager_load!
+ ActiveSupport::Deprecation.warn "eager_load paths are deprecated and all autoload paths are now eagerly loaded."
+ skip_autoload!
+ end
+
+ def eager_load?
+ ActiveSupport::Deprecation.warn "eager_load paths are deprecated and all autoload paths are now eagerly loaded."
+ autoload?
+ end
+
def each(&block)
@paths.each(&block)
end
diff --git a/railties/railties.gemspec b/railties/railties.gemspec
index e39430560f..a55bf012da 100644
--- a/railties/railties.gemspec
+++ b/railties/railties.gemspec
@@ -27,6 +27,6 @@ Gem::Specification.new do |s|
s.add_dependency 'actionpack', version
s.add_dependency 'rake', '>= 0.8.7'
- s.add_dependency 'thor', '>= 0.15.4', '< 2.0'
+ s.add_dependency 'thor', '>= 0.17.0', '< 2.0'
s.add_dependency 'rdoc', '~> 3.4'
end
diff --git a/railties/test/application/configuration_test.rb b/railties/test/application/configuration_test.rb
index f9108ed7b9..7b45623f6c 100644
--- a/railties/test/application/configuration_test.rb
+++ b/railties/test/application/configuration_test.rb
@@ -417,17 +417,7 @@ module ApplicationTests
require "#{app_path}/config/environment"
- assert_equal Time.find_zone!("Wellington"), Time.zone_default
- end
-
- test "timezone can be set on initializers" do
- app_file "config/initializers/locale.rb", <<-RUBY
- Rails.application.config.time_zone = "Central Time (US & Canada)"
- RUBY
-
- require "#{app_path}/config/environment"
-
- assert_equal Time.find_zone!("Central Time (US & Canada)"), Time.zone_default
+ assert_equal "Wellington", Rails.application.config.time_zone
end
test "raises when an invalid timezone is defined in the config" do
@@ -577,6 +567,54 @@ module ApplicationTests
assert_equal 'permitted', last_response.body
end
+ test "config.action_controller.action_on_unpermitted_parameters = :raise" do
+ app_file 'app/controllers/posts_controller.rb', <<-RUBY
+ class PostsController < ActionController::Base
+ def create
+ render text: params.require(:post).permit(:name)
+ end
+ end
+ RUBY
+
+ add_to_config <<-RUBY
+ routes.prepend do
+ resources :posts
+ end
+ config.action_controller.action_on_unpermitted_parameters = :raise
+ RUBY
+
+ require "#{app_path}/config/environment"
+
+ assert_equal :raise, ActionController::Parameters.action_on_unpermitted_parameters
+
+ post "/posts", {post: {"title" =>"zomg"}}
+ assert_match "We're sorry, but something went wrong", last_response.body
+ end
+
+ test "config.action_controller.action_on_unpermitted_parameters is :log by default on development" do
+ ENV["RAILS_ENV"] = "development"
+
+ require "#{app_path}/config/environment"
+
+ assert_equal :log, ActionController::Parameters.action_on_unpermitted_parameters
+ end
+
+ test "config.action_controller.action_on_unpermitted_parameters is :log by defaul on test" do
+ ENV["RAILS_ENV"] = "test"
+
+ require "#{app_path}/config/environment"
+
+ assert_equal :log, ActionController::Parameters.action_on_unpermitted_parameters
+ end
+
+ test "config.action_controller.action_on_unpermitted_parameters is false by default on production" do
+ ENV["RAILS_ENV"] = "production"
+
+ require "#{app_path}/config/environment"
+
+ assert_equal false, ActionController::Parameters.action_on_unpermitted_parameters
+ end
+
test "config.action_dispatch.ignore_accept_header" do
make_basic_app do |app|
app.config.action_dispatch.ignore_accept_header = true
diff --git a/railties/test/application/initializers/load_path_test.rb b/railties/test/application/initializers/load_path_test.rb
index 31811e7f92..595f58bd91 100644
--- a/railties/test/application/initializers/load_path_test.rb
+++ b/railties/test/application/initializers/load_path_test.rb
@@ -64,7 +64,7 @@ module ApplicationTests
add_to_config <<-RUBY
config.root = "#{app_path}"
- config.eager_load_paths << "#{app_path}/lib"
+ config.autoload_paths << "#{app_path}/lib"
RUBY
require "#{app_path}/config/environment"
diff --git a/railties/test/application/paths_test.rb b/railties/test/application/paths_test.rb
index 4029984ce9..f6a77a0d17 100644
--- a/railties/test/application/paths_test.rb
+++ b/railties/test/application/paths_test.rb
@@ -54,11 +54,11 @@ module ApplicationTests
assert_equal root("app", "controllers"), @paths["app/controllers"].expanded.first
end
- test "booting up Rails yields a list of paths that are eager" do
- eager_load = @paths.eager_load
- assert eager_load.include?(root("app/controllers"))
- assert eager_load.include?(root("app/helpers"))
- assert eager_load.include?(root("app/models"))
+ test "booting up Rails yields a list of paths that will be eager loaded" do
+ autoload_paths = @paths.autoload_paths
+ assert autoload_paths.include?(root("app/controllers"))
+ assert autoload_paths.include?(root("app/helpers"))
+ assert autoload_paths.include?(root("app/models"))
end
test "environments has a glob equal to the current environment" do
diff --git a/railties/test/application/runner_test.rb b/railties/test/application/runner_test.rb
index f65b5e2f2d..6595c40f8b 100644
--- a/railties/test/application/runner_test.rb
+++ b/railties/test/application/runner_test.rb
@@ -37,27 +37,27 @@ module ApplicationTests
end
def test_should_run_file
- app_file "script/count_users.rb", <<-SCRIPT
+ app_file "bin/count_users.rb", <<-SCRIPT
puts User.count
SCRIPT
- assert_match "42", Dir.chdir(app_path) { `bundle exec rails runner "script/count_users.rb"` }
+ assert_match "42", Dir.chdir(app_path) { `bundle exec rails runner "bin/count_users.rb"` }
end
def test_should_set_dollar_0_to_file
- app_file "script/dollar0.rb", <<-SCRIPT
+ app_file "bin/dollar0.rb", <<-SCRIPT
puts $0
SCRIPT
- assert_match "script/dollar0.rb", Dir.chdir(app_path) { `bundle exec rails runner "script/dollar0.rb"` }
+ assert_match "bin/dollar0.rb", Dir.chdir(app_path) { `bundle exec rails runner "bin/dollar0.rb"` }
end
def test_should_set_dollar_program_name_to_file
- app_file "script/program_name.rb", <<-SCRIPT
+ app_file "bin/program_name.rb", <<-SCRIPT
puts $PROGRAM_NAME
SCRIPT
- assert_match "script/program_name.rb", Dir.chdir(app_path) { `bundle exec rails runner "script/program_name.rb"` }
+ assert_match "bin/program_name.rb", Dir.chdir(app_path) { `bundle exec rails runner "bin/program_name.rb"` }
end
def test_with_hook
diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb
index ee93dc49cd..b2deeb011d 100644
--- a/railties/test/generators/app_generator_test.rb
+++ b/railties/test/generators/app_generator_test.rb
@@ -164,6 +164,11 @@ class AppGeneratorTest < Rails::Generators::TestCase
end
end
+ def test_config_database_app_name_with_period
+ run_generator [File.join(destination_root, "common.usage.com"), "-d", "postgresql"]
+ assert_file "common.usage.com/config/database.yml", /common_usage_com/
+ end
+
def test_config_postgresql_database
run_generator([destination_root, "-d", "postgresql"])
assert_file "config/database.yml", /postgresql/
diff --git a/railties/test/paths_test.rb b/railties/test/paths_test.rb
index 12f18b9dbf..6f860469fd 100644
--- a/railties/test/paths_test.rb
+++ b/railties/test/paths_test.rb
@@ -135,56 +135,48 @@ class PathsTest < ActiveSupport::TestCase
assert_equal 2, @root.autoload_once.size
end
- test "it is possible to mark a path as eager loaded" do
+ test "marking a path as eager loaded is deprecated" do
@root["app"] = "/app"
- @root["app"].eager_load!
- assert @root["app"].eager_load?
- assert @root.eager_load.include?(@root["app"].to_a.first)
+ assert_deprecated{ @root["app"].eager_load! }
+ assert_deprecated{ assert @root["app"].eager_load? }
+ assert_deprecated{ assert @root.eager_load.include?(@root["app"].to_a.first) }
end
- test "it is possible to skip a path from eager loading" do
+ test "skipping a path from eager loading is deprecated" do
@root["app"] = "/app"
- @root["app"].eager_load!
- assert @root["app"].eager_load?
+ assert_deprecated{ @root["app"].eager_load! }
+ assert_deprecated{ assert @root["app"].eager_load? }
- @root["app"].skip_eager_load!
- assert !@root["app"].eager_load?
- assert !@root.eager_load.include?(@root["app"].to_a.first)
+ assert_deprecated{ @root["app"].skip_eager_load! }
+ assert_deprecated{ assert !@root["app"].eager_load? }
+ assert_deprecated{ assert !@root.eager_load.include?(@root["app"].to_a.first) }
end
- test "it is possible to add a path without assignment and mark it as eager" do
- @root.add "app", with: "/app", eager_load: true
- assert @root["app"].eager_load?
- assert @root.eager_load.include?("/app")
+ test "adding a path with eager_load option is deprecated" do
+ assert_deprecated{ @root.add "app", with: "/app", eager_load: true }
+ assert_deprecated{ assert @root["app"].eager_load? }
+ assert_deprecated{ assert @root.eager_load.include?("/app") }
end
- test "it is possible to add multiple paths without assignment and mark them as eager" do
- @root.add "app", with: ["/app", "/app2"], eager_load: true
- assert @root["app"].eager_load?
- assert @root.eager_load.include?("/app")
- assert @root.eager_load.include?("/app2")
- end
-
- test "it is possible to create a path without assignment and mark it both as eager and load once" do
- @root.add "app", with: "/app", eager_load: true, autoload_once: true
- assert @root["app"].eager_load?
- assert @root["app"].autoload_once?
- assert @root.eager_load.include?("/app")
- assert @root.autoload_once.include?("/app")
+ test "adding multiple paths with eager_load option is deprecated" do
+ assert_deprecated{ @root.add "app", with: ["/app", "/app2"], eager_load: true }
+ assert_deprecated{ assert @root["app"].eager_load? }
+ assert_deprecated{ assert @root.eager_load.include?("/app") }
+ assert_deprecated{ assert @root.eager_load.include?("/app2") }
end
test "making a path eager more than once only includes it once in @root.eager_paths" do
@root["app"] = "/app"
- @root["app"].eager_load!
- @root["app"].eager_load!
- assert_equal 1, @root.eager_load.select {|p| p == @root["app"].expanded.first }.size
+ assert_deprecated{ @root["app"].eager_load! }
+ assert_deprecated{ @root["app"].eager_load! }
+ assert_deprecated{ assert_equal 1, @root.eager_load.select {|p| p == @root["app"].expanded.first }.size }
end
test "paths added to a eager_load path should be added to the eager_load collection" do
@root["app"] = "/app"
- @root["app"].eager_load!
+ assert_deprecated{ @root["app"].eager_load! }
@root["app"] << "/app2"
- assert_equal 2, @root.eager_load.size
+ assert_deprecated{ assert_equal 2, @root.eager_load.size }
end
test "it should be possible to add a path's default glob" do
diff --git a/railties/test/railties/engine_test.rb b/railties/test/railties/engine_test.rb
index a4a75fe459..37d0be107c 100644
--- a/railties/test/railties/engine_test.rb
+++ b/railties/test/railties/engine_test.rb
@@ -1241,6 +1241,12 @@ YAML
assert_equal '/foo/bukkits/bukkit', last_response.body
end
+ test "engines method is properly deprecated" do
+ boot_rails
+
+ assert_deprecated { app.railties.engines }
+ end
+
private
def app
Rails.application
diff --git a/railties/test/railties/mounted_engine_test.rb b/railties/test/railties/mounted_engine_test.rb
index a1c52f01dc..80559a6e36 100644
--- a/railties/test/railties/mounted_engine_test.rb
+++ b/railties/test/railties/mounted_engine_test.rb
@@ -89,6 +89,7 @@ module ApplicationTests
get '/generate_application_route', to: 'posts#generate_application_route'
get '/application_route_in_view', to: 'posts#application_route_in_view'
get '/engine_polymorphic_path', to: 'posts#engine_polymorphic_path'
+ get '/engine_asset_path', to: 'posts#engine_asset_path'
end
RUBY
@@ -113,6 +114,10 @@ module ApplicationTests
def engine_polymorphic_path
render text: polymorphic_path(Post.new)
end
+
+ def engine_asset_path
+ render inline: "<%= asset_path 'images/foo.png' %>"
+ end
end
end
RUBY
@@ -211,6 +216,10 @@ module ApplicationTests
# and in an application
get "/application_polymorphic_path"
assert_equal "/posts/44", last_response.body
+
+ # test that asset path will not get script_name when generated in the engine
+ get "/someone/blog/engine_asset_path"
+ assert_equal "/images/foo.png", last_response.body
end
test "route path for controller action when engine is mounted at root" do