railties 5.0.0.beta3 → 5.0.0.beta4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +50 -19
  3. data/lib/rails/all.rb +2 -2
  4. data/lib/rails/app_loader.rb +1 -1
  5. data/lib/rails/application.rb +8 -6
  6. data/lib/rails/application/bootstrap.rb +4 -3
  7. data/lib/rails/application/configuration.rb +5 -5
  8. data/lib/rails/application/default_middleware_stack.rb +3 -19
  9. data/lib/rails/application/finisher.rb +73 -13
  10. data/lib/rails/code_statistics.rb +1 -0
  11. data/lib/rails/commands.rb +2 -2
  12. data/lib/rails/commands/runner.rb +4 -3
  13. data/lib/rails/commands/server.rb +10 -18
  14. data/lib/rails/console/app.rb +1 -2
  15. data/lib/rails/dev_caching.rb +43 -0
  16. data/lib/rails/gem_version.rb +1 -1
  17. data/lib/rails/generators/actions.rb +21 -8
  18. data/lib/rails/generators/actions/create_migration.rb +1 -0
  19. data/lib/rails/generators/app_base.rb +2 -1
  20. data/lib/rails/generators/erb/mailer/mailer_generator.rb +1 -1
  21. data/lib/rails/generators/rails/app/app_generator.rb +20 -2
  22. data/lib/rails/generators/rails/app/templates/Gemfile +3 -3
  23. data/lib/rails/generators/rails/app/templates/README.md +1 -1
  24. data/lib/rails/generators/rails/app/templates/Rakefile +1 -1
  25. data/lib/rails/generators/rails/app/templates/app/assets/javascripts/cable.js +13 -0
  26. data/lib/rails/generators/rails/app/templates/app/views/layouts/application.html.erb.tt +2 -5
  27. data/lib/rails/generators/rails/app/templates/bin/rails +1 -1
  28. data/lib/rails/generators/rails/app/templates/bin/setup +1 -1
  29. data/lib/rails/generators/rails/app/templates/bin/update +1 -1
  30. data/lib/rails/generators/rails/app/templates/config.ru +5 -0
  31. data/lib/rails/generators/rails/app/templates/config/application.rb +1 -1
  32. data/lib/rails/generators/rails/app/templates/config/boot.rb +1 -1
  33. data/lib/rails/generators/rails/app/templates/config/environment.rb +1 -1
  34. data/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt +2 -17
  35. data/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +13 -12
  36. data/lib/rails/generators/rails/app/templates/config/initializers/ssl_options.rb +4 -0
  37. data/lib/rails/generators/rails/app/templates/config/initializers/to_time_preserves_timezone.rb +10 -0
  38. data/lib/rails/generators/rails/app/templates/config/routes.rb +0 -3
  39. data/lib/rails/generators/rails/app/templates/config/spring.rb +6 -0
  40. data/lib/rails/generators/rails/plugin/templates/Rakefile +1 -1
  41. data/lib/rails/generators/rails/plugin/templates/bin/rails.tt +2 -1
  42. data/lib/rails/generators/rails/plugin/templates/rails/application.rb +5 -3
  43. data/lib/rails/generators/rails/plugin/templates/rails/boot.rb +2 -2
  44. data/lib/rails/generators/test_unit/mailer/mailer_generator.rb +1 -1
  45. data/lib/rails/railtie.rb +37 -38
  46. data/lib/rails/tasks/dev.rake +3 -9
  47. data/lib/rails/tasks/framework.rake +20 -5
  48. data/lib/rails/tasks/misc.rake +23 -6
  49. data/lib/rails/tasks/restart.rake +6 -3
  50. data/lib/rails/tasks/routes.rake +3 -0
  51. data/lib/rails/tasks/statistics.rake +1 -0
  52. data/lib/rails/tasks/tmp.rake +4 -6
  53. data/lib/rails/test_unit/minitest_plugin.rb +10 -9
  54. metadata +16 -13
  55. data/lib/rails/command.rb +0 -70
  56. data/lib/rails/generators/rails/app/templates/app/assets/javascripts/cable.coffee +0 -11
  57. data/lib/rails/generators/rails/app/templates/config.ru.tt +0 -10
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b4fea73157abd641e818793971d61f9ba1c982cb
4
- data.tar.gz: 9356d423706a1cb8c934ca166661c0bd9a018f5d
3
+ metadata.gz: 849b9b39dee2cd29bc2506bcdb4810e271cb8503
4
+ data.tar.gz: 2218346e1e9603f0401f7fb0b0bff4d7bcd664eb
5
5
  SHA512:
6
- metadata.gz: 93728268e600949966dcb493db8738e8b601d973d09bff191808f473e5015862a8a533268e0354136e42b27e4ed73cfe70e8cbe6e34556ff39eeb292acddaea7
7
- data.tar.gz: 941025bde174d4fc8645f143148dc26addbd7eb60df50d31c500fa9258105aa5d363b4270b7223ac3f90a280e35d4aa8e5c58a6ebab2c46716751e2b365c646b
6
+ metadata.gz: 0e3cca869fce3881223643ae25a0eaa8db48d917235f89293969256a6b8fcbd29020ac7cbec44e9435f39cf6cd861815625f4e8222cf89cf4fb1a75eab7880d8
7
+ data.tar.gz: 4579abdacba1336783561695db94b0bdc13b4b3b309c526cb1beedadb985a19da58f9c4d75a9ec0051d741cd677e9811926890f39869f6333328414a28791a43
@@ -1,3 +1,32 @@
1
+ ## Rails 5.0.0.beta4 (April 27, 2016) ##
2
+
3
+ * Add `config/initializers/to_time_preserves_timezone.rb`, which tells
4
+ Active Support to preserve the receiver's timezone when calling `to_time`.
5
+ This matches the new behavior that will be part of Ruby 2.4.
6
+
7
+ Fixes #24617.
8
+
9
+ *Andrew White*
10
+
11
+ * Make `rails restart` command work with Puma by passing the restart command
12
+ which Puma can use to restart rails server.
13
+
14
+ *Prathamesh Sonpatki*
15
+
16
+ * The application generator writes a new file `config/spring.rb`, which tells
17
+ Spring to watch additional common files.
18
+
19
+ *Xavier Noria*
20
+
21
+ * The tasks in the rails task namespace is deprecated in favor of app namespace.
22
+ (e.g. `rails:update` and `rails:template` tasks is renamed to `app:update` and `app:template`.)
23
+
24
+ *Ryo Hashimoto*
25
+
26
+ * Enable HSTS with IncludeSudomains header for new applications.
27
+
28
+ *Egor Homakov*, *Prathamesh Sonpatki*
29
+
1
30
  ## Rails 5.0.0.beta3 (February 24, 2016) ##
2
31
 
3
32
  * Alias `rake` with `rails_command` in the Rails Application Templates API
@@ -19,7 +48,7 @@
19
48
  system monitor and the async plugin for spring.
20
49
 
21
50
  * The Gemfiles of new applications include spring-watcher-listen on Linux and
22
- Mac OS X (unless --skip-spring).
51
+ Mac OS X (unless `--skip-spring`).
23
52
 
24
53
  *Xavier Noria*
25
54
 
@@ -28,7 +57,9 @@
28
57
 
29
58
  *Xavier Noria*
30
59
 
31
- * Add dummy files for apple-touch-icon.png and apple-touch-icon.png. GH#23427
60
+ * Add dummy files for apple-touch-icon.png and apple-touch-icon.png.
61
+
62
+ See #23427.
32
63
 
33
64
  *Alexey Zabelin*
34
65
 
@@ -92,7 +123,7 @@
92
123
 
93
124
  *Chuck Callebs*
94
125
 
95
- * Allow use of minitest-rails gem with Rails test runner.
126
+ * Allow use of `minitest-rails` gem with Rails test runner.
96
127
 
97
128
  Fixes #22455.
98
129
 
@@ -105,13 +136,13 @@
105
136
  *Yuji Yaginuma*
106
137
 
107
138
  * Make `static_index` part of the `config.public_file_server` config and
108
- call it `public_file_server.index_name`.
139
+ call it `config.public_file_server.index_name`.
109
140
 
110
141
  *Yuki Nishijima*
111
142
 
112
- * Deprecate `serve_static_files` in favor of `public_file_server.enabled`.
143
+ * Deprecate `config.serve_static_files` in favor of `config.public_file_server.enabled`.
113
144
 
114
- Unifies the static asset options under `public_file_server`.
145
+ Unifies the static asset options under `config.public_file_server`.
115
146
 
116
147
  To upgrade, replace occurrences of:
117
148
 
@@ -149,8 +180,8 @@
149
180
 
150
181
  *Yuki Nishijima*
151
182
 
152
- * Route generator should be idempotent
153
- running generators several times no longer require you to cleanup routes.rb
183
+ * Route generators are now idempotent.
184
+ Running generators several times no longer require you to cleanup routes.rb.
154
185
 
155
186
  *Thiago Pinto*
156
187
 
@@ -158,7 +189,7 @@
158
189
 
159
190
  *Simon Eskildsen*
160
191
 
161
- * Allow rake:stats to account for rake tasks in lib/tasks
192
+ * Allow `rake stats` to account for rake tasks in lib/tasks.
162
193
 
163
194
  *Kevin Deisz*
164
195
 
@@ -168,7 +199,7 @@
168
199
 
169
200
  *James Kerr*
170
201
 
171
- * Add fail fast to `bin/rails test`
202
+ * Add fail fast to `bin/rails test`.
172
203
 
173
204
  Adding `--fail-fast` or `-f` when running tests will interrupt the run on
174
205
  the first failure:
@@ -200,7 +231,7 @@
200
231
 
201
232
  *Kasper Timm Hansen*
202
233
 
203
- * Add inline output to `bin/rails test`
234
+ * Add inline output to `bin/rails test`.
204
235
 
205
236
  Any failures or errors (and skips if running in verbose mode) are output
206
237
  during a test run:
@@ -231,7 +262,7 @@
231
262
  *Kasper Timm Hansen*
232
263
 
233
264
  * Fix displaying mailer previews on non local requests when config
234
- `action_mailer.show_previews` is set
265
+ `config.action_mailer.show_previews` is set.
235
266
 
236
267
  *Wojciech Wnętrzak*
237
268
 
@@ -262,14 +293,14 @@
262
293
  *Ersin Akinci*
263
294
 
264
295
  * Make enabling or disabling caching in development mode possible with
265
- rake dev:cache.
296
+ `rake dev:cache`.
266
297
 
267
- Running rake dev:cache will create or remove tmp/caching-dev.txt. When this
268
- file exists config.action_controller.perform_caching will be set to true in
298
+ Running `rake dev:cache` will create or remove tmp/caching-dev.txt. When this
299
+ file exists `config.action_controller.perform_caching` will be set to true in
269
300
  config/environments/development.rb.
270
301
 
271
- Additionally, a server can be started with either --dev-caching or
272
- --no-dev-caching included to toggle caching on startup.
302
+ Additionally, a server can be started with either `--dev-caching` or
303
+ `--no-dev-caching` included to toggle caching on startup.
273
304
 
274
305
  *Jussi Mertanen*, *Chuck Callebs*
275
306
 
@@ -282,11 +313,11 @@
282
313
 
283
314
  *Yuji Yaginuma*
284
315
 
285
- * Adding support for passing a block to the `add_source` action of a custom generator
316
+ * Adding support for passing a block to the `add_source` action of a custom generator.
286
317
 
287
318
  *Mike Dalton*, *Hirofumi Wakasugi*
288
319
 
289
- * `assert_file` understands paths with special characters
320
+ * `assert_file` now understands paths with special characters
290
321
  (eg. `v0.1.4~alpha+nightly`).
291
322
 
292
323
  *Diego Carrion*
@@ -1,4 +1,4 @@
1
- require "rails"
1
+ require 'rails'
2
2
 
3
3
  %w(
4
4
  active_record/railtie
@@ -11,7 +11,7 @@ require "rails"
11
11
  sprockets/railtie
12
12
  ).each do |railtie|
13
13
  begin
14
- require "#{railtie}"
14
+ require railtie
15
15
  rescue LoadError
16
16
  end
17
17
  end
@@ -16,7 +16,7 @@ like any other source code, rather than stubs that are generated on demand.
16
16
  Here's how to upgrade:
17
17
 
18
18
  bundle config --delete bin # Turn off Bundler's stub generator
19
- rake rails:update:bin # Use the new Rails 4 executables
19
+ rails app:update:bin # Use the new Rails 5 executables
20
20
  git add bin # Add bin/ to source control
21
21
 
22
22
  You may need to remove bin/ from your .gitignore as well.
@@ -1,4 +1,3 @@
1
- require 'fileutils'
2
1
  require 'yaml'
3
2
  require 'active_support/core_ext/hash/keys'
4
3
  require 'active_support/core_ext/object/blank'
@@ -74,8 +73,7 @@ module Rails
74
73
  # the configuration.
75
74
  #
76
75
  # If you decide to define rake tasks, runners, or initializers in an
77
- # application other than +Rails.application+, then you must run those
78
- # these manually.
76
+ # application other than +Rails.application+, then you must run them manually.
79
77
  class Application < Engine
80
78
  autoload :Bootstrap, 'rails/application/bootstrap'
81
79
  autoload :Configuration, 'rails/application/configuration'
@@ -113,7 +111,7 @@ module Rails
113
111
 
114
112
  attr_accessor :assets, :sandbox
115
113
  alias_method :sandbox?, :sandbox
116
- attr_reader :reloaders
114
+ attr_reader :reloaders, :reloader, :executor
117
115
 
118
116
  delegate :default_url_options, :default_url_options=, to: :routes
119
117
 
@@ -131,6 +129,10 @@ module Rails
131
129
  @message_verifiers = {}
132
130
  @ran_load_hooks = false
133
131
 
132
+ @executor = Class.new(ActiveSupport::Executor)
133
+ @reloader = Class.new(ActiveSupport::Reloader)
134
+ @reloader.executor = @executor
135
+
134
136
  # are these actually used?
135
137
  @initial_variable_values = initial_variable_values
136
138
  @block = block
@@ -243,7 +245,7 @@ module Rails
243
245
  @app_env_config ||= begin
244
246
  validate_secret_key_config!
245
247
 
246
- super.merge({
248
+ super.merge(
247
249
  "action_dispatch.parameter_filter" => config.filter_parameters,
248
250
  "action_dispatch.redirect_filter" => config.filter_redirect,
249
251
  "action_dispatch.secret_token" => secrets.secret_token,
@@ -259,7 +261,7 @@ module Rails
259
261
  "action_dispatch.encrypted_signed_cookie_salt" => config.action_dispatch.encrypted_signed_cookie_salt,
260
262
  "action_dispatch.cookies_serializer" => config.action_dispatch.cookies_serializer,
261
263
  "action_dispatch.cookies_digest" => config.action_dispatch.cookies_digest
262
- })
264
+ )
263
265
  end
264
266
  end
265
267
 
@@ -1,6 +1,7 @@
1
- require "active_support/notifications"
2
- require "active_support/dependencies"
3
- require "active_support/descendants_tracker"
1
+ require 'fileutils'
2
+ require 'active_support/notifications'
3
+ require 'active_support/dependencies'
4
+ require 'active_support/descendants_tracker'
4
5
 
5
6
  module Rails
6
7
  class Application
@@ -58,7 +58,7 @@ module Rails
58
58
 
59
59
  def static_cache_control=(value)
60
60
  ActiveSupport::Deprecation.warn <<-eow.strip_heredoc
61
- `static_cache_control` is deprecated and will be removed in Rails 5.1.
61
+ `config.static_cache_control` is deprecated and will be removed in Rails 5.1.
62
62
  Please use
63
63
  `config.public_file_server.headers = { 'Cache-Control' => '#{value}' }`
64
64
  instead.
@@ -69,8 +69,8 @@ module Rails
69
69
 
70
70
  def serve_static_files
71
71
  ActiveSupport::Deprecation.warn <<-eow.strip_heredoc
72
- `serve_static_files` is deprecated and will be removed in Rails 5.1.
73
- Please use `public_file_server.enabled` instead.
72
+ `config.serve_static_files` is deprecated and will be removed in Rails 5.1.
73
+ Please use `config.public_file_server.enabled` instead.
74
74
  eow
75
75
 
76
76
  @public_file_server.enabled
@@ -78,8 +78,8 @@ module Rails
78
78
 
79
79
  def serve_static_files=(value)
80
80
  ActiveSupport::Deprecation.warn <<-eow.strip_heredoc
81
- `serve_static_files` is deprecated and will be removed in Rails 5.1.
82
- Please use `public_file_server.enabled = #{value}` instead.
81
+ `config.serve_static_files` is deprecated and will be removed in Rails 5.1.
82
+ Please use `config.public_file_server.enabled = #{value}` instead.
83
83
  eow
84
84
 
85
85
  @public_file_server.enabled = value
@@ -34,22 +34,10 @@ module Rails
34
34
  # handling: presumably their code is not threadsafe
35
35
 
36
36
  middleware.use ::Rack::Lock
37
-
38
- elsif config.allow_concurrency == :unsafe
39
- # Do nothing, even if we know this is dangerous. This is the
40
- # historical behaviour for true.
41
-
42
- else
43
- # Default concurrency setting: enabled, but safe
44
-
45
- unless config.cache_classes && config.eager_load
46
- # Without cache_classes + eager_load, the load interlock
47
- # is required for proper operation
48
-
49
- middleware.use ::ActionDispatch::LoadInterlock
50
- end
51
37
  end
52
38
 
39
+ middleware.use ::ActionDispatch::Executor, app.executor
40
+
53
41
  middleware.use ::Rack::Runtime
54
42
  middleware.use ::Rack::MethodOverride unless config.api_only
55
43
  middleware.use ::ActionDispatch::RequestId
@@ -61,7 +49,7 @@ module Rails
61
49
  middleware.use ::ActionDispatch::RemoteIp, config.action_dispatch.ip_spoofing_check, config.action_dispatch.trusted_proxies
62
50
 
63
51
  unless config.cache_classes
64
- middleware.use ::ActionDispatch::Reloader, lambda { reload_dependencies? }
52
+ middleware.use ::ActionDispatch::Reloader, app.reloader
65
53
  end
66
54
 
67
55
  middleware.use ::ActionDispatch::Callbacks
@@ -83,10 +71,6 @@ module Rails
83
71
 
84
72
  private
85
73
 
86
- def reload_dependencies?
87
- config.reload_classes_only_on_change != true || app.reloaders.map(&:updated?).any?
88
- end
89
-
90
74
  def load_rack_cache
91
75
  rack_cache = config.action_dispatch.rack_cache
92
76
  return unless rack_cache
@@ -38,16 +38,16 @@ module Rails
38
38
  app.routes.define_mounted_helper(:main_app)
39
39
  end
40
40
 
41
- initializer :add_to_prepare_blocks do
41
+ initializer :add_to_prepare_blocks do |app|
42
42
  config.to_prepare_blocks.each do |block|
43
- ActionDispatch::Reloader.to_prepare(&block)
43
+ app.reloader.to_prepare(&block)
44
44
  end
45
45
  end
46
46
 
47
47
  # This needs to happen before eager load so it happens
48
48
  # in exactly the same point regardless of config.cache_classes
49
- initializer :run_prepare_callbacks do
50
- ActionDispatch::Reloader.prepare!
49
+ initializer :run_prepare_callbacks do |app|
50
+ app.reloader.prepare!
51
51
  end
52
52
 
53
53
  initializer :eager_load! do
@@ -62,13 +62,60 @@ module Rails
62
62
  ActiveSupport.run_load_hooks(:after_initialize, self)
63
63
  end
64
64
 
65
+ class MutexHook
66
+ def initialize(mutex = Mutex.new)
67
+ @mutex = mutex
68
+ end
69
+
70
+ def run
71
+ @mutex.lock
72
+ end
73
+
74
+ def complete(_state)
75
+ @mutex.unlock
76
+ end
77
+ end
78
+
79
+ module InterlockHook
80
+ def self.run
81
+ ActiveSupport::Dependencies.interlock.start_running
82
+ end
83
+
84
+ def self.complete(_state)
85
+ ActiveSupport::Dependencies.interlock.done_running
86
+ end
87
+ end
88
+
89
+ initializer :configure_executor_for_concurrency do |app|
90
+ if config.allow_concurrency == false
91
+ # User has explicitly opted out of concurrent request
92
+ # handling: presumably their code is not threadsafe
93
+
94
+ app.executor.register_hook(MutexHook.new, outer: true)
95
+
96
+ elsif config.allow_concurrency == :unsafe
97
+ # Do nothing, even if we know this is dangerous. This is the
98
+ # historical behaviour for true.
99
+
100
+ else
101
+ # Default concurrency setting: enabled, but safe
102
+
103
+ unless config.cache_classes && config.eager_load
104
+ # Without cache_classes + eager_load, the load interlock
105
+ # is required for proper operation
106
+
107
+ app.executor.register_hook(InterlockHook, outer: true)
108
+ end
109
+ end
110
+ end
111
+
65
112
  # Set routes reload after the finisher hook to ensure routes added in
66
113
  # the hook are taken into account.
67
- initializer :set_routes_reloader_hook do
114
+ initializer :set_routes_reloader_hook do |app|
68
115
  reloader = routes_reloader
69
116
  reloader.execute_if_updated
70
117
  self.reloaders << reloader
71
- ActionDispatch::Reloader.to_prepare do
118
+ app.reloader.to_run do
72
119
  # We configure #execute rather than #execute_if_updated because if
73
120
  # autoloaded constants are cleared we need to reload routes also in
74
121
  # case any was used there, as in
@@ -78,18 +125,27 @@ module Rails
78
125
  # This means routes are also reloaded if i18n is updated, which
79
126
  # might not be necessary, but in order to be more precise we need
80
127
  # some sort of reloaders dependency support, to be added.
128
+ require_unload_lock!
81
129
  reloader.execute
82
130
  end
83
131
  end
84
132
 
85
133
  # Set clearing dependencies after the finisher hook to ensure paths
86
134
  # added in the hook are taken into account.
87
- initializer :set_clear_dependencies_hook, group: :all do
135
+ initializer :set_clear_dependencies_hook, group: :all do |app|
88
136
  callback = lambda do
89
- ActiveSupport::Dependencies.interlock.unloading do
90
- ActiveSupport::DescendantsTracker.clear
91
- ActiveSupport::Dependencies.clear
137
+ ActiveSupport::DescendantsTracker.clear
138
+ ActiveSupport::Dependencies.clear
139
+ end
140
+
141
+ if config.cache_classes
142
+ app.reloader.check = lambda { false }
143
+ elsif config.reload_classes_only_on_change
144
+ app.reloader.check = lambda do
145
+ app.reloaders.map(&:updated?).any?
92
146
  end
147
+ else
148
+ app.reloader.check = lambda { true }
93
149
  end
94
150
 
95
151
  if config.reload_classes_only_on_change
@@ -99,15 +155,19 @@ module Rails
99
155
  # Prepend this callback to have autoloaded constants cleared before
100
156
  # any other possible reloading, in case they need to autoload fresh
101
157
  # constants.
102
- ActionDispatch::Reloader.to_prepare(prepend: true) do
158
+ app.reloader.to_run(prepend: true) do
103
159
  # In addition to changes detected by the file watcher, if routes
104
160
  # or i18n have been updated we also need to clear constants,
105
161
  # that's why we run #execute rather than #execute_if_updated, this
106
162
  # callback has to clear autoloaded constants after any update.
107
- reloader.execute
163
+ class_unload! do
164
+ reloader.execute
165
+ end
108
166
  end
109
167
  else
110
- ActionDispatch::Reloader.to_cleanup(&callback)
168
+ app.reloader.to_complete do
169
+ class_unload!(&callback)
170
+ end
111
171
  end
112
172
  end
113
173