actionpack 4.2.0.beta3 → 4.2.0.beta4

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of actionpack might be problematic. Click here for more details.

Files changed (31) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +20 -0
  3. data/lib/abstract_controller/helpers.rb +11 -1
  4. data/lib/action_controller.rb +0 -1
  5. data/lib/action_controller/metal.rb +3 -3
  6. data/lib/action_controller/metal/conditional_get.rb +6 -6
  7. data/lib/action_controller/metal/exceptions.rb +1 -1
  8. data/lib/action_controller/metal/mime_responds.rb +2 -2
  9. data/lib/action_controller/metal/params_wrapper.rb +2 -2
  10. data/lib/action_controller/metal/rack_delegation.rb +1 -1
  11. data/lib/action_controller/metal/request_forgery_protection.rb +2 -2
  12. data/lib/action_controller/metal/strong_parameters.rb +7 -4
  13. data/lib/action_controller/test_case.rb +1 -1
  14. data/lib/action_dispatch/http/parameters.rb +1 -1
  15. data/lib/action_dispatch/http/request.rb +2 -2
  16. data/lib/action_dispatch/http/response.rb +7 -4
  17. data/lib/action_dispatch/journey/formatter.rb +1 -1
  18. data/lib/action_dispatch/journey/gtg/transition_table.rb +2 -2
  19. data/lib/action_dispatch/journey/scanner.rb +5 -5
  20. data/lib/action_dispatch/middleware/debug_exceptions.rb +33 -23
  21. data/lib/action_dispatch/middleware/exception_wrapper.rb +11 -10
  22. data/lib/action_dispatch/middleware/templates/rescues/_source.erb +2 -2
  23. data/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb +1 -1
  24. data/lib/action_dispatch/routing/inspector.rb +1 -1
  25. data/lib/action_dispatch/routing/mapper.rb +12 -3
  26. data/lib/action_dispatch/routing/route_set.rb +33 -3
  27. data/lib/action_dispatch/testing/assertions.rb +1 -1
  28. data/lib/action_dispatch/testing/assertions/tag.rb +1 -1
  29. data/lib/action_dispatch/testing/integration.rb +1 -1
  30. data/lib/action_pack/gem_version.rb +1 -1
  31. metadata +25 -25
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a79b09bb3d78ade720a2fc62868146f0474b2cf4
4
- data.tar.gz: 842fbe3e5fadad64c8a7246f60dbd43f6bc65867
3
+ metadata.gz: b8c12cbc4e46b97d11ea9ce74be1c06d0a00e8e1
4
+ data.tar.gz: 8a833f77dae6369f9bf22b9d86fcecabf0913331
5
5
  SHA512:
6
- metadata.gz: bb82822f77f37f135b5110ac9038715a8d485d27f561c99a5b7d19c9b9a011fc38e994e5bd096808a6cab014d1f7ad11a08ec68bc1b239ccf066b7d81fbf24e0
7
- data.tar.gz: 72354eda73aa8a73c38b0f34d47e1e0f79417ca76ce2936607ec34189598e2022e0cf3691e077dc9dd68bb1522c0c500660234c707166d36d180950fffb1f203
6
+ metadata.gz: 71758cad3d40ee807499e94ebcba2be3ff1135cafdab036b10a80cb32abe0e5e091dc800430ed79bd2207bd335e29d07ebba7c7800f59cb3ad7307025e50beb8
7
+ data.tar.gz: 61d99f0ddebe675d48f4911655f5ceb6396b1116d769225df16ab9b6e6046539a9b461aea67ff7e74d8254cd5bdfcf3edbb9ef59b8d6b024d90e4fc8c4981c80
@@ -1,3 +1,23 @@
1
+ * Deprecate the `only_path` option on `*_path` helpers.
2
+
3
+ In cases where this option is set to `true`, the option is redundant and can
4
+ be safely removed; otherwise, the corresponding `*_url` helper should be
5
+ used instead.
6
+
7
+ Fixes #17294.
8
+
9
+ *Dan Olson*, *Godfrey Chan*
10
+
11
+ * Improve Journey compliance to RFC 3986.
12
+
13
+ The scanner in Journey failed to recognize routes that use literals
14
+ from the sub-delims section of RFC 3986. It's now able to parse those
15
+ authorized delimiters and route as expected.
16
+
17
+ Fixes #17212.
18
+
19
+ *Nicolas Cavigneaux*
20
+
1
21
  * Deprecate implicit Array conversion for Response objects. It was added
2
22
  (using `#to_ary`) so we could conveniently use implicit splatting:
3
23
 
@@ -150,7 +150,17 @@ module AbstractController
150
150
  rescue LoadError => e
151
151
  raise AbstractController::Helpers::MissingHelperError.new(e, file_name)
152
152
  end
153
- file_name.camelize.constantize
153
+
154
+ mod_name = file_name.camelize
155
+ begin
156
+ mod_name.constantize
157
+ rescue LoadError
158
+ # dependencies.rb gives a similar error message but its wording is
159
+ # not as clear because it mentions autoloading. To the user all it
160
+ # matters is that a helper module couldn't be loaded, autoloading
161
+ # is an internal mechanism that should not leak.
162
+ raise NameError, "Couldn't find #{mod_name}, expected it to be defined in helpers/#{file_name}.rb"
163
+ end
154
164
  when Module
155
165
  arg
156
166
  else
@@ -34,7 +34,6 @@ module ActionController
34
34
  autoload :Rendering
35
35
  autoload :RequestForgeryProtection
36
36
  autoload :Rescue
37
- autoload :Responder
38
37
  autoload :Streaming
39
38
  autoload :StrongParameters
40
39
  autoload :Testing
@@ -165,7 +165,7 @@ module ActionController
165
165
  headers["Location"] = url
166
166
  end
167
167
 
168
- # basic url_for that can be overridden for more robust functionality
168
+ # Basic url_for that can be overridden for more robust functionality
169
169
  def url_for(string)
170
170
  string
171
171
  end
@@ -182,7 +182,7 @@ module ActionController
182
182
  body = [body] unless body.nil? || body.respond_to?(:each)
183
183
  super
184
184
  end
185
-
185
+
186
186
  # Tests if render or redirect has already happened.
187
187
  def performed?
188
188
  response_body || (response && response.committed?)
@@ -237,7 +237,7 @@ module ActionController
237
237
  end
238
238
  end
239
239
 
240
- def _status_code
240
+ def _status_code #:nodoc:
241
241
  @_status
242
242
  end
243
243
  end
@@ -13,9 +13,9 @@ module ActionController
13
13
  end
14
14
 
15
15
  module ClassMethods
16
- # Allows you to consider additional controller-wide information when generating an etag.
16
+ # Allows you to consider additional controller-wide information when generating an ETag.
17
17
  # For example, if you serve pages tailored depending on who's logged in at the moment, you
18
- # may want to add the current user id to be part of the etag to prevent authorized displaying
18
+ # may want to add the current user id to be part of the ETag to prevent authorized displaying
19
19
  # of cached pages.
20
20
  #
21
21
  # class InvoicesController < ApplicationController
@@ -32,7 +32,7 @@ module ActionController
32
32
  end
33
33
  end
34
34
 
35
- # Sets the etag, +last_modified+, or both on the response and renders a
35
+ # Sets the +etag+, +last_modified+, or both on the response and renders a
36
36
  # <tt>304 Not Modified</tt> response if the request is already fresh.
37
37
  #
38
38
  # === Parameters:
@@ -54,11 +54,11 @@ module ActionController
54
54
  # fresh_when(etag: @article, last_modified: @article.created_at, public: true)
55
55
  # end
56
56
  #
57
- # This will render the show template if the request isn't sending a matching etag or
57
+ # This will render the show template if the request isn't sending a matching ETag or
58
58
  # If-Modified-Since header and just a <tt>304 Not Modified</tt> response if there's a match.
59
59
  #
60
60
  # You can also just pass a record where +last_modified+ will be set by calling
61
- # +updated_at+ and the etag by passing the object itself.
61
+ # +updated_at+ and the +etag+ by passing the object itself.
62
62
  #
63
63
  # def show
64
64
  # @article = Article.find(params[:id])
@@ -124,7 +124,7 @@ module ActionController
124
124
  # end
125
125
  #
126
126
  # You can also just pass a record where +last_modified+ will be set by calling
127
- # updated_at and the etag by passing the object itself.
127
+ # +updated_at+ and the +etag+ by passing the object itself.
128
128
  #
129
129
  # def show
130
130
  # @article = Article.find(params[:id])
@@ -25,7 +25,7 @@ module ActionController
25
25
  end
26
26
  end
27
27
 
28
- class ActionController::UrlGenerationError < RoutingError #:nodoc:
28
+ class ActionController::UrlGenerationError < ActionControllerError #:nodoc:
29
29
  end
30
30
 
31
31
  class MethodNotAllowed < ActionControllerError #:nodoc:
@@ -216,11 +216,11 @@ module ActionController #:nodoc:
216
216
  #
217
217
  # Be sure to check the documentation of +respond_with+ and
218
218
  # <tt>ActionController::MimeResponds.respond_to</tt> for more examples.
219
- def respond_to(*mimes, &block)
219
+ def respond_to(*mimes)
220
220
  raise ArgumentError, "respond_to takes either types or a block, never both" if mimes.any? && block_given?
221
221
 
222
222
  collector = Collector.new(mimes, request.variant)
223
- block.call(collector) if block_given?
223
+ yield collector if block_given?
224
224
 
225
225
  if format = collector.negotiate_format(request)
226
226
  _process_format(format)
@@ -244,7 +244,7 @@ module ActionController
244
244
  request.parameters.merge! wrapped_hash
245
245
  request.request_parameters.merge! wrapped_hash
246
246
 
247
- # This will make the wrapped hash displayed in the log file
247
+ # This will display the wrapped hash in the log file
248
248
  request.filtered_parameters.merge! wrapped_filtered_hash
249
249
  end
250
250
  super
@@ -252,7 +252,7 @@ module ActionController
252
252
 
253
253
  private
254
254
 
255
- # Returns the wrapper key which will use to stored wrapped parameters.
255
+ # Returns the wrapper key which will be used to stored wrapped parameters.
256
256
  def _wrapper_key
257
257
  _wrapper_options.name
258
258
  end
@@ -6,7 +6,7 @@ module ActionController
6
6
  extend ActiveSupport::Concern
7
7
 
8
8
  delegate :headers, :status=, :location=, :content_type=,
9
- :status, :location, :content_type, :_status_code, :to => "@_response"
9
+ :status, :location, :content_type, :response_code, :to => "@_response"
10
10
 
11
11
  def dispatch(action, request)
12
12
  set_response!(request)
@@ -1,5 +1,6 @@
1
1
  require 'rack/session/abstract/id'
2
2
  require 'action_controller/metal/exceptions'
3
+ require 'active_support/security_utils'
3
4
 
4
5
  module ActionController #:nodoc:
5
6
  class InvalidAuthenticityToken < ActionControllerError #:nodoc:
@@ -305,8 +306,7 @@ module ActionController #:nodoc:
305
306
  end
306
307
 
307
308
  def compare_with_real_token(token, session)
308
- # Borrow a constant-time comparison from Rack
309
- Rack::Utils.secure_compare(token, real_csrf_token(session))
309
+ ActiveSupport::SecurityUtils.secure_compare(token, real_csrf_token(session))
310
310
  end
311
311
 
312
312
  def real_csrf_token(session)
@@ -1,5 +1,6 @@
1
1
  require 'active_support/core_ext/hash/indifferent_access'
2
2
  require 'active_support/core_ext/array/wrap'
3
+ require 'active_support/core_ext/string/filters'
3
4
  require 'active_support/deprecation'
4
5
  require 'active_support/rescuable'
5
6
  require 'action_dispatch/http/upload'
@@ -114,10 +115,12 @@ module ActionController
114
115
 
115
116
  def self.const_missing(const_name)
116
117
  super unless const_name == :NEVER_UNPERMITTED_PARAMS
117
- ActiveSupport::Deprecation.warn "`ActionController::Parameters::NEVER_UNPERMITTED_PARAMS`"\
118
- " has been deprecated. Use "\
119
- "`ActionController::Parameters.always_permitted_parameters` instead."
120
- self.always_permitted_parameters
118
+ ActiveSupport::Deprecation.warn(<<-MSG.squish)
119
+ `ActionController::Parameters::NEVER_UNPERMITTED_PARAMS` has been deprecated.
120
+ Use `ActionController::Parameters.always_permitted_parameters` instead.
121
+ MSG
122
+
123
+ always_permitted_parameters
121
124
  end
122
125
 
123
126
  # Returns a new instance of <tt>ActionController::Parameters</tt>.
@@ -689,7 +689,7 @@ module ActionController
689
689
  private
690
690
 
691
691
  def document_root_element
692
- html_document.root
692
+ html_document
693
693
  end
694
694
 
695
695
  def check_required_ivars
@@ -27,7 +27,7 @@ module ActionDispatch
27
27
 
28
28
  def symbolized_path_parameters
29
29
  ActiveSupport::Deprecation.warn(
30
- "`symbolized_path_parameters` is deprecated. Please use `path_parameters`"
30
+ '`symbolized_path_parameters` is deprecated. Please use `path_parameters`.'
31
31
  )
32
32
  path_parameters
33
33
  end
@@ -328,7 +328,7 @@ module ActionDispatch
328
328
  # Extracted into ActionDispatch::Request::Utils.deep_munge, but kept here for backwards compatibility.
329
329
  def deep_munge(hash)
330
330
  ActiveSupport::Deprecation.warn(
331
- "This method has been extracted into ActionDispatch::Request::Utils.deep_munge. Please start using that instead."
331
+ 'This method has been extracted into `ActionDispatch::Request::Utils.deep_munge`. Please start using that instead.'
332
332
  )
333
333
 
334
334
  Utils.deep_munge(hash)
@@ -341,7 +341,7 @@ module ActionDispatch
341
341
 
342
342
  private
343
343
  def check_method(name)
344
- HTTP_METHOD_LOOKUP[name] || raise(ActionController::UnknownHttpMethod, "#{name}, accepted HTTP methods are #{HTTP_METHODS.to_sentence(:locale => :en)}")
344
+ HTTP_METHOD_LOOKUP[name] || raise(ActionController::UnknownHttpMethod, "#{name}, accepted HTTP methods are #{HTTP_METHODS[0...-1].join(', ')}, and #{HTTP_METHODS[-1]}")
345
345
  name
346
346
  end
347
347
  end
@@ -1,4 +1,5 @@
1
1
  require 'active_support/core_ext/module/attribute_accessors'
2
+ require 'active_support/core_ext/string/filters'
2
3
  require 'active_support/deprecation'
3
4
  require 'action_dispatch/http/filter_redirect'
4
5
  require 'monitor'
@@ -288,7 +289,12 @@ module ActionDispatch # :nodoc:
288
289
  # as arrays work, and "flattening" responses, cascading to the rack body!
289
290
  # Not sensible behavior.
290
291
  def to_ary
291
- ActiveSupport::Deprecation.warn 'ActionDispatch::Response#to_ary no longer performs implicit conversion to an Array. Please use response.to_a instead, or a splat like `status, headers, body = *response`'
292
+ ActiveSupport::Deprecation.warn(<<-MSG.squish)
293
+ `ActionDispatch::Response#to_ary` no longer performs implicit conversion
294
+ to an array. Please use `response.to_a` instead, or a splat like `status,
295
+ headers, body = *response`.
296
+ MSG
297
+
292
298
  to_a
293
299
  end
294
300
 
@@ -309,9 +315,6 @@ module ActionDispatch # :nodoc:
309
315
  cookies
310
316
  end
311
317
 
312
- def _status_code
313
- @status
314
- end
315
318
  private
316
319
 
317
320
  def before_committed
@@ -40,7 +40,7 @@ module ActionDispatch
40
40
  end
41
41
 
42
42
  message = "No route matches #{Hash[constraints.sort].inspect}"
43
- message << " missing required keys: #{missing_keys.sort.inspect}" if name
43
+ message << " missing required keys: #{missing_keys.sort.inspect}" unless missing_keys.empty?
44
44
 
45
45
  raise ActionController::UrlGenerationError, message
46
46
  end
@@ -88,13 +88,13 @@ module ActionDispatch
88
88
  erb = File.read File.join(viz_dir, 'index.html.erb')
89
89
  states = "function tt() { return #{to_json}; }"
90
90
 
91
- fun_routes = paths.shuffle.first(3).map do |ast|
91
+ fun_routes = paths.sample(3).map do |ast|
92
92
  ast.map { |n|
93
93
  case n
94
94
  when Nodes::Symbol
95
95
  case n.left
96
96
  when ':id' then rand(100).to_s
97
- when ':format' then %w{ xml json }.shuffle.first
97
+ when ':format' then %w{ xml json }.sample
98
98
  else
99
99
  'omg'
100
100
  end
@@ -39,18 +39,18 @@ module ActionDispatch
39
39
  [:SLASH, text]
40
40
  when text = @ss.scan(/\*\w+/)
41
41
  [:STAR, text]
42
- when text = @ss.scan(/\(/)
42
+ when text = @ss.scan(/(?<!\\)\(/)
43
43
  [:LPAREN, text]
44
- when text = @ss.scan(/\)/)
44
+ when text = @ss.scan(/(?<!\\)\)/)
45
45
  [:RPAREN, text]
46
46
  when text = @ss.scan(/\|/)
47
47
  [:OR, text]
48
48
  when text = @ss.scan(/\./)
49
49
  [:DOT, text]
50
- when text = @ss.scan(/:\w+/)
50
+ when text = @ss.scan(/(?<!\\):\w+/)
51
51
  [:SYMBOL, text]
52
- when text = @ss.scan(/[\w%\-~]+/)
53
- [:LITERAL, text]
52
+ when text = @ss.scan(/(?:[\w%\-~!$&'*+,;=@]|\\:|\\\(|\\\))+/)
53
+ [:LITERAL, text.tr('\\', '')]
54
54
  # any char
55
55
  when text = @ss.scan(/./)
56
56
  [:LITERAL, text]
@@ -35,10 +35,23 @@ module ActionDispatch
35
35
 
36
36
  if env['action_dispatch.show_detailed_exceptions']
37
37
  request = Request.new(env)
38
+ traces = traces_from_wrapper(wrapper)
39
+
40
+ trace_to_show = 'Application Trace'
41
+ if traces[trace_to_show].empty?
42
+ trace_to_show = 'Full Trace'
43
+ end
44
+
45
+ if source_to_show = traces[trace_to_show].first
46
+ source_to_show_id = source_to_show[:id]
47
+ end
48
+
38
49
  template = ActionView::Base.new([RESCUES_TEMPLATE_PATH],
39
50
  request: request,
40
51
  exception: wrapper.exception,
41
- traces: traces_from_wrapper(wrapper),
52
+ traces: traces,
53
+ show_source_idx: source_to_show_id,
54
+ trace_to_show: trace_to_show,
42
55
  routes_inspector: routes_inspector(exception),
43
56
  source_extract: wrapper.source_extract,
44
57
  line_number: wrapper.line_number,
@@ -97,31 +110,28 @@ module ActionDispatch
97
110
  # Augment the exception traces by providing ids for all unique stack frame
98
111
  def traces_from_wrapper(wrapper)
99
112
  application_trace = wrapper.application_trace
100
- framework_trace = wrapper.framework_trace
101
- full_trace = wrapper.full_trace
102
-
103
- if application_trace && framework_trace
104
- id_counter = 0
105
-
106
- application_trace = application_trace.map do |trace|
107
- prev = id_counter
108
- id_counter += 1
109
- { id: prev, trace: trace }
110
- end
111
-
112
- framework_trace = framework_trace.map do |trace|
113
- prev = id_counter
114
- id_counter += 1
115
- { id: prev, trace: trace }
113
+ framework_trace = wrapper.framework_trace
114
+ full_trace = wrapper.full_trace
115
+
116
+ appplication_trace_with_ids = []
117
+ framework_trace_with_ids = []
118
+ full_trace_with_ids = []
119
+
120
+ if full_trace
121
+ full_trace.each_with_index do |trace, idx|
122
+ id_trace = {
123
+ id: idx,
124
+ trace: trace
125
+ }
126
+ appplication_trace_with_ids << id_trace if application_trace.include? trace
127
+ framework_trace_with_ids << id_trace if framework_trace.include? trace
128
+ full_trace_with_ids << id_trace
116
129
  end
117
-
118
- full_trace = application_trace + framework_trace
119
130
  end
120
-
121
131
  {
122
- "Application Trace" => application_trace,
123
- "Framework Trace" => framework_trace,
124
- "Full Trace" => full_trace
132
+ "Application Trace" => appplication_trace_with_ids,
133
+ "Framework Trace" => framework_trace_with_ids,
134
+ "Full Trace" => full_trace_with_ids
125
135
  }
126
136
  end
127
137
  end
@@ -6,16 +6,17 @@ module ActionDispatch
6
6
  cattr_accessor :rescue_responses
7
7
  @@rescue_responses = Hash.new(:internal_server_error)
8
8
  @@rescue_responses.merge!(
9
- 'ActionController::RoutingError' => :not_found,
10
- 'AbstractController::ActionNotFound' => :not_found,
11
- 'ActionController::MethodNotAllowed' => :method_not_allowed,
12
- 'ActionController::UnknownHttpMethod' => :method_not_allowed,
13
- 'ActionController::NotImplemented' => :not_implemented,
14
- 'ActionController::UnknownFormat' => :not_acceptable,
15
- 'ActionController::InvalidAuthenticityToken' => :unprocessable_entity,
16
- 'ActionDispatch::ParamsParser::ParseError' => :bad_request,
17
- 'ActionController::BadRequest' => :bad_request,
18
- 'ActionController::ParameterMissing' => :bad_request
9
+ 'ActionController::RoutingError' => :not_found,
10
+ 'AbstractController::ActionNotFound' => :not_found,
11
+ 'ActionController::MethodNotAllowed' => :method_not_allowed,
12
+ 'ActionController::UnknownHttpMethod' => :method_not_allowed,
13
+ 'ActionController::NotImplemented' => :not_implemented,
14
+ 'ActionController::UnknownFormat' => :not_acceptable,
15
+ 'ActionController::InvalidAuthenticityToken' => :unprocessable_entity,
16
+ 'ActionController::InvalidCrossOriginRequest' => :unprocessable_entity,
17
+ 'ActionDispatch::ParamsParser::ParseError' => :bad_request,
18
+ 'ActionController::BadRequest' => :bad_request,
19
+ 'ActionController::ParameterMissing' => :bad_request
19
20
  )
20
21
 
21
22
  cattr_accessor :rescue_templates
@@ -1,7 +1,7 @@
1
1
  <% if @source_extract %>
2
2
  <% @source_extract.each_with_index do |extract_source, index| %>
3
3
  <% if extract_source[:code] %>
4
- <div class="source <%="hidden" if index != 0%>" id="frame-source-<%=index%>">
4
+ <div class="source <%="hidden" if @show_source_idx != index%>" id="frame-source-<%=index%>">
5
5
  <div class="info">
6
6
  Extracted source (around line <strong>#<%= extract_source[:line_number] %></strong>):
7
7
  </div>
@@ -10,7 +10,7 @@
10
10
  <tr>
11
11
  <td>
12
12
  <pre class="line_numbers">
13
- <% extract_source[:code].keys.each do |line_number| %>
13
+ <% extract_source[:code].each_key do |line_number| %>
14
14
  <span><%= line_number -%></span>
15
15
  <% end %>
16
16
  </pre>
@@ -12,7 +12,7 @@
12
12
  <% end %>
13
13
 
14
14
  <% @traces.each do |name, trace| %>
15
- <div id="<%= name.gsub(/\s/, '-') %>" style="display: <%= (name == "Application Trace") ? 'block' : 'none' %>;">
15
+ <div id="<%= name.gsub(/\s/, '-') %>" style="display: <%= (name == @trace_to_show) ? 'block' : 'none' %>;">
16
16
  <pre><code><% trace.each do |frame| %><a class="trace-frames" data-frame-id="<%= frame[:id] %>" href="#"><%= frame[:trace] %></a><br><% end %></code></pre>
17
17
  </div>
18
18
  <% end %>
@@ -48,7 +48,7 @@ module ActionDispatch
48
48
  def reqs
49
49
  @reqs ||= begin
50
50
  reqs = endpoint
51
- reqs += " #{constraints.to_s}" unless constraints.empty?
51
+ reqs += " #{constraints}" unless constraints.empty?
52
52
  reqs
53
53
  end
54
54
  end
@@ -4,6 +4,7 @@ require 'active_support/core_ext/hash/slice'
4
4
  require 'active_support/core_ext/enumerable'
5
5
  require 'active_support/core_ext/array/extract_options'
6
6
  require 'active_support/core_ext/module/remove_method'
7
+ require 'active_support/core_ext/string/filters'
7
8
  require 'active_support/inflector'
8
9
  require 'action_dispatch/routing/redirection'
9
10
  require 'action_dispatch/routing/endpoint'
@@ -282,11 +283,19 @@ module ActionDispatch
282
283
  def split_to(to)
283
284
  case to
284
285
  when Symbol
285
- ActiveSupport::Deprecation.warn "defining a route where `to` is a symbol is deprecated. Please change \"to: :#{to}\" to \"action: :#{to}\""
286
+ ActiveSupport::Deprecation.warn(<<-MSG.squish)
287
+ Defining a route where `to` is a symbol is deprecated.
288
+ Please change `to: :#{to}` to `action: :#{to}`.
289
+ MSG
290
+
286
291
  [nil, to.to_s]
287
292
  when /#/ then to.split('#')
288
293
  when String
289
- ActiveSupport::Deprecation.warn "defining a route where `to` is a controller without an action is deprecated. Please change \"to: :#{to}\" to \"controller: :#{to}\""
294
+ ActiveSupport::Deprecation.warn(<<-MSG.squish)
295
+ Defining a route where `to` is a controller without an action is deprecated.
296
+ Please change `to: :#{to}` to `controller: :#{to}`.
297
+ MSG
298
+
290
299
  [to, nil]
291
300
  else
292
301
  []
@@ -434,7 +443,7 @@ module ActionDispatch
434
443
  #
435
444
  # Because requesting various HTTP verbs with a single action has security
436
445
  # implications, you must either specify the actions in
437
- # the via options or use one of the HtttpHelpers[rdoc-ref:HttpHelpers]
446
+ # the via options or use one of the HttpHelpers[rdoc-ref:HttpHelpers]
438
447
  # instead +match+
439
448
  #
440
449
  # === Options
@@ -6,6 +6,7 @@ require 'active_support/core_ext/object/to_query'
6
6
  require 'active_support/core_ext/hash/slice'
7
7
  require 'active_support/core_ext/module/remove_method'
8
8
  require 'active_support/core_ext/array/extract_options'
9
+ require 'active_support/core_ext/string/filters'
9
10
  require 'action_controller/metal/exceptions'
10
11
  require 'action_dispatch/http/request'
11
12
  require 'action_dispatch/routing/endpoint'
@@ -102,7 +103,10 @@ module ActionDispatch
102
103
  end
103
104
 
104
105
  def helpers
105
- ActiveSupport::Deprecation.warn("`named_routes.helpers` is deprecated, please use `route_defined?(route_name)` to see if a named route was defined.")
106
+ ActiveSupport::Deprecation.warn(<<-MSG.squish)
107
+ `named_routes.helpers` is deprecated, please use `route_defined?(route_name)`
108
+ to see if a named route was defined.
109
+ MSG
106
110
  @path_helpers + @url_helpers
107
111
  end
108
112
 
@@ -134,8 +138,8 @@ module ActionDispatch
134
138
  @url_helpers_module.send :undef_method, url_name
135
139
  end
136
140
  routes[key] = route
137
- define_url_helper @path_helpers_module, route, path_name, route.defaults, name, PATH
138
- define_url_helper @url_helpers_module, route, url_name, route.defaults, name, FULL
141
+ define_url_helper @path_helpers_module, route, path_name, route.defaults, name, LEGACY
142
+ define_url_helper @url_helpers_module, route, url_name, route.defaults, name, UNKNOWN
139
143
 
140
144
  @path_helpers << path_name
141
145
  @url_helpers << url_name
@@ -322,6 +326,32 @@ module ActionDispatch
322
326
  PATH = ->(options) { ActionDispatch::Http::URL.path_for(options) }
323
327
  FULL = ->(options) { ActionDispatch::Http::URL.full_url_for(options) }
324
328
  UNKNOWN = ->(options) { ActionDispatch::Http::URL.url_for(options) }
329
+ LEGACY = ->(options) {
330
+ if options.key?(:only_path)
331
+ if options[:only_path]
332
+ ActiveSupport::Deprecation.warn(<<-MSG.squish)
333
+ You are calling a `*_path` helper with the `only_path` option
334
+ explicitly set to `true`. This option will stop working on
335
+ path helpers in Rails 5. Simply remove the `only_path: true`
336
+ argument from your call as it is redundant when applied to a
337
+ path helper.
338
+ MSG
339
+
340
+ PATH.call(options)
341
+ else
342
+ ActiveSupport::Deprecation.warn(<<-MSG.squish)
343
+ You are calling a `*_path` helper with the `only_path` option
344
+ explicitly set to `false`. This option will stop working on
345
+ path helpers in Rails 5. Use the corresponding `*_url` helper
346
+ instead.
347
+ MSG
348
+
349
+ FULL.call(options)
350
+ end
351
+ else
352
+ PATH.call(options)
353
+ end
354
+ }
325
355
  # :startdoc:
326
356
 
327
357
  attr_accessor :formatter, :set, :named_routes, :default_scope, :router
@@ -15,7 +15,7 @@ module ActionDispatch
15
15
  @html_document ||= if @response.content_type =~ /xml$/
16
16
  Nokogiri::XML::Document.parse(@response.body)
17
17
  else
18
- Nokogiri::HTML::Document.parse(@response.body)
18
+ Nokogiri::HTML::DocumentFragment.parse(@response.body)
19
19
  end
20
20
  end
21
21
  end
@@ -1,3 +1,3 @@
1
1
  require 'active_support/deprecation'
2
2
 
3
- ActiveSupport::Deprecation.warn("ActionDispatch::Assertions::TagAssertions has been extracted to the rails-dom-testing gem.")
3
+ ActiveSupport::Deprecation.warn('`ActionDispatch::Assertions::TagAssertions` has been extracted to the rails-dom-testing gem.')
@@ -497,7 +497,7 @@ module ActionDispatch
497
497
  end
498
498
 
499
499
  def document_root_element
500
- html_document.root
500
+ html_document
501
501
  end
502
502
  end
503
503
  end
@@ -8,7 +8,7 @@ module ActionPack
8
8
  MAJOR = 4
9
9
  MINOR = 2
10
10
  TINY = 0
11
- PRE = "beta3"
11
+ PRE = "beta4"
12
12
 
13
13
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
14
14
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: actionpack
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.2.0.beta3
4
+ version: 4.2.0.beta4
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-29 00:00:00.000000000 Z
11
+ date: 2014-10-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -16,110 +16,110 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 4.2.0.beta3
19
+ version: 4.2.0.beta4
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 4.2.0.beta3
26
+ version: 4.2.0.beta4
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rack
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ~>
32
32
  - !ruby/object:Gem::Version
33
33
  version: 1.6.0.beta
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ~>
39
39
  - !ruby/object:Gem::Version
40
40
  version: 1.6.0.beta
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rack-test
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ~>
46
46
  - !ruby/object:Gem::Version
47
47
  version: 0.6.2
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ~>
53
53
  - !ruby/object:Gem::Version
54
54
  version: 0.6.2
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rails-html-sanitizer
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ~>
60
60
  - !ruby/object:Gem::Version
61
61
  version: '1.0'
62
- - - ">="
62
+ - - '>='
63
63
  - !ruby/object:Gem::Version
64
64
  version: 1.0.1
65
65
  type: :runtime
66
66
  prerelease: false
67
67
  version_requirements: !ruby/object:Gem::Requirement
68
68
  requirements:
69
- - - "~>"
69
+ - - ~>
70
70
  - !ruby/object:Gem::Version
71
71
  version: '1.0'
72
- - - ">="
72
+ - - '>='
73
73
  - !ruby/object:Gem::Version
74
74
  version: 1.0.1
75
75
  - !ruby/object:Gem::Dependency
76
76
  name: rails-dom-testing
77
77
  requirement: !ruby/object:Gem::Requirement
78
78
  requirements:
79
- - - "~>"
79
+ - - ~>
80
80
  - !ruby/object:Gem::Version
81
81
  version: '1.0'
82
- - - ">="
82
+ - - '>='
83
83
  - !ruby/object:Gem::Version
84
- version: 1.0.3
84
+ version: 1.0.4
85
85
  type: :runtime
86
86
  prerelease: false
87
87
  version_requirements: !ruby/object:Gem::Requirement
88
88
  requirements:
89
- - - "~>"
89
+ - - ~>
90
90
  - !ruby/object:Gem::Version
91
91
  version: '1.0'
92
- - - ">="
92
+ - - '>='
93
93
  - !ruby/object:Gem::Version
94
- version: 1.0.3
94
+ version: 1.0.4
95
95
  - !ruby/object:Gem::Dependency
96
96
  name: actionview
97
97
  requirement: !ruby/object:Gem::Requirement
98
98
  requirements:
99
99
  - - '='
100
100
  - !ruby/object:Gem::Version
101
- version: 4.2.0.beta3
101
+ version: 4.2.0.beta4
102
102
  type: :runtime
103
103
  prerelease: false
104
104
  version_requirements: !ruby/object:Gem::Requirement
105
105
  requirements:
106
106
  - - '='
107
107
  - !ruby/object:Gem::Version
108
- version: 4.2.0.beta3
108
+ version: 4.2.0.beta4
109
109
  - !ruby/object:Gem::Dependency
110
110
  name: activemodel
111
111
  requirement: !ruby/object:Gem::Requirement
112
112
  requirements:
113
113
  - - '='
114
114
  - !ruby/object:Gem::Version
115
- version: 4.2.0.beta3
115
+ version: 4.2.0.beta4
116
116
  type: :development
117
117
  prerelease: false
118
118
  version_requirements: !ruby/object:Gem::Requirement
119
119
  requirements:
120
120
  - - '='
121
121
  - !ruby/object:Gem::Version
122
- version: 4.2.0.beta3
122
+ version: 4.2.0.beta4
123
123
  description: Web apps on Rails. Simple, battle-tested conventions for building and
124
124
  testing MVC web applications. Works with any Rack-compatible server.
125
125
  email: david@loudthinking.com
@@ -289,18 +289,18 @@ require_paths:
289
289
  - lib
290
290
  required_ruby_version: !ruby/object:Gem::Requirement
291
291
  requirements:
292
- - - ">="
292
+ - - '>='
293
293
  - !ruby/object:Gem::Version
294
294
  version: 1.9.3
295
295
  required_rubygems_version: !ruby/object:Gem::Requirement
296
296
  requirements:
297
- - - ">"
297
+ - - '>'
298
298
  - !ruby/object:Gem::Version
299
299
  version: 1.3.1
300
300
  requirements:
301
301
  - none
302
302
  rubyforge_project:
303
- rubygems_version: 2.2.2
303
+ rubygems_version: 2.2.1
304
304
  signing_key:
305
305
  specification_version: 4
306
306
  summary: Web-flow and rendering framework putting the VC in MVC (part of Rails).