actionpack 4.2.0.beta4 → 4.2.0.rc1

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 (32) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +14 -0
  3. data/lib/action_controller/base.rb +1 -1
  4. data/lib/action_controller/log_subscriber.rb +0 -1
  5. data/lib/action_controller/metal/etag_with_template_digest.rb +2 -2
  6. data/lib/action_controller/metal/http_authentication.rb +12 -5
  7. data/lib/action_controller/metal/instrumentation.rb +1 -1
  8. data/lib/action_controller/metal/live.rb +1 -1
  9. data/lib/action_controller/metal/mime_responds.rb +4 -16
  10. data/lib/action_controller/metal/renderers.rb +1 -2
  11. data/lib/action_controller/test_case.rb +24 -2
  12. data/lib/action_dispatch/http/url.rb +3 -1
  13. data/lib/action_dispatch/journey/formatter.rb +15 -0
  14. data/lib/action_dispatch/journey/visualizer/fsm.css +0 -4
  15. data/lib/action_dispatch/middleware/callbacks.rb +1 -1
  16. data/lib/action_dispatch/middleware/cookies.rb +7 -5
  17. data/lib/action_dispatch/middleware/debug_exceptions.rb +3 -31
  18. data/lib/action_dispatch/middleware/exception_wrapper.rb +34 -6
  19. data/lib/action_dispatch/middleware/flash.rb +7 -4
  20. data/lib/action_dispatch/middleware/params_parser.rb +1 -1
  21. data/lib/action_dispatch/middleware/templates/rescues/_source.erb +19 -21
  22. data/lib/action_dispatch/middleware/templates/rescues/missing_template.html.erb +4 -0
  23. data/lib/action_dispatch/middleware/templates/rescues/routing_error.html.erb +2 -0
  24. data/lib/action_dispatch/middleware/templates/routes/_table.html.erb +1 -1
  25. data/lib/action_dispatch/routing/mapper.rb +6 -8
  26. data/lib/action_dispatch/routing/route_set.rb +24 -4
  27. data/lib/action_dispatch/routing/url_for.rb +6 -0
  28. data/lib/action_dispatch/testing/assertions.rb +1 -1
  29. data/lib/action_dispatch/testing/assertions/routing.rb +0 -6
  30. data/lib/action_dispatch/testing/integration.rb +12 -4
  31. data/lib/action_pack/gem_version.rb +1 -1
  32. metadata +27 -27
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b8c12cbc4e46b97d11ea9ce74be1c06d0a00e8e1
4
- data.tar.gz: 8a833f77dae6369f9bf22b9d86fcecabf0913331
3
+ metadata.gz: 7e27b68720e44f5d6404e7be9d6959b2f776a5b0
4
+ data.tar.gz: 3bb27803254f54bb258af4818f28d9d0d89d8482
5
5
  SHA512:
6
- metadata.gz: 71758cad3d40ee807499e94ebcba2be3ff1135cafdab036b10a80cb32abe0e5e091dc800430ed79bd2207bd335e29d07ebba7c7800f59cb3ad7307025e50beb8
7
- data.tar.gz: 61d99f0ddebe675d48f4911655f5ceb6396b1116d769225df16ab9b6e6046539a9b461aea67ff7e74d8254cd5bdfcf3edbb9ef59b8d6b024d90e4fc8c4981c80
6
+ metadata.gz: f4dab5c75998ef6b5d48e10c26e3732df63b40e98a38b02236e9f1726c80ad7974aee7ce5cc46335bcb7092e71d8ef2cca9c52e9830cc08e6e2d806420ea463d
7
+ data.tar.gz: 5c7d3930ae896faef79fdb4a5f68840b050e85ee29d079d0f0f9b0bb6ad06cf5caec70baf0b745b0fe4b82f7fdc119c034bd9fae84b3678fcd1144a1642f2b10
@@ -1,3 +1,17 @@
1
+ * Restore handling of a bare `Authorization` header, without `token=`
2
+ prefix.
3
+
4
+ Fixes #17108.
5
+
6
+ *Guo Xiang Tan*
7
+
8
+ * Deprecate use of string keys in URL helpers.
9
+
10
+ Use symbols instead.
11
+ Fixes #16958.
12
+
13
+ *Byron Bischoff*, *Melanie Gilman*
14
+
1
15
  * Deprecate the `only_path` option on `*_path` helpers.
2
16
 
3
17
  In cases where this option is set to `true`, the option is redundant and can
@@ -44,7 +44,7 @@ module ActionController
44
44
  # The full request object is available via the request accessor and is primarily used to query for HTTP headers:
45
45
  #
46
46
  # def server_ip
47
- # location = request.env["SERVER_ADDR"]
47
+ # location = request.env["REMOTE_ADDR"]
48
48
  # render plain: "This server hosted at #{location}"
49
49
  # end
50
50
  #
@@ -1,4 +1,3 @@
1
-
2
1
  module ActionController
3
2
  class LogSubscriber < ActiveSupport::LogSubscriber
4
3
  INTERNAL_PARAMS = %w(controller action format _method only_path)
@@ -7,8 +7,8 @@ module ActionController
7
7
  #
8
8
  # config.action_controller.etag_with_template_digest = false
9
9
  #
10
- # Override the template to digest by passing `:template` to `fresh_when`
11
- # and `stale?` calls. For example:
10
+ # Override the template to digest by passing +:template+ to +fresh_when+
11
+ # and +stale?+ calls. For example:
12
12
  #
13
13
  # # We're going to render widgets/show, not posts/show
14
14
  # fresh_when @post, template: 'widgets/show'
@@ -397,6 +397,7 @@ module ActionController
397
397
  #
398
398
  # RewriteRule ^(.*)$ dispatch.fcgi [E=X-HTTP_AUTHORIZATION:%{HTTP:Authorization},QSA,L]
399
399
  module Token
400
+ TOKEN_KEY = 'token='
400
401
  TOKEN_REGEX = /^Token /
401
402
  AUTHN_PAIR_DELIMITERS = /(?:,|;|\t+)/
402
403
  extend self
@@ -462,16 +463,22 @@ module ActionController
462
463
  raw_params.map { |param| param.split %r/=(.+)?/ }
463
464
  end
464
465
 
465
- # This removes the `"` characters wrapping the value.
466
+ # This removes the <tt>"</tt> characters wrapping the value.
466
467
  def rewrite_param_values(array_params)
467
468
  array_params.each { |param| (param[1] || "").gsub! %r/^"|"$/, '' }
468
469
  end
469
470
 
470
471
  # This method takes an authorization body and splits up the key-value
471
- # pairs by the standardized `:`, `;`, or `\t` delimiters defined in
472
- # `AUTHN_PAIR_DELIMITERS`.
472
+ # pairs by the standardized <tt>:</tt>, <tt>;</tt>, or <tt>\t</tt>
473
+ # delimiters defined in +AUTHN_PAIR_DELIMITERS+.
473
474
  def raw_params(auth)
474
- auth.sub(TOKEN_REGEX, '').split(/\s*#{AUTHN_PAIR_DELIMITERS}\s*/)
475
+ _raw_params = auth.sub(TOKEN_REGEX, '').split(/\s*#{AUTHN_PAIR_DELIMITERS}\s*/)
476
+
477
+ if !(_raw_params.first =~ %r{\A#{TOKEN_KEY}})
478
+ _raw_params[0] = "#{TOKEN_KEY}#{_raw_params.first}"
479
+ end
480
+
481
+ _raw_params
475
482
  end
476
483
 
477
484
  # Encodes the given token and options into an Authorization header value.
@@ -481,7 +488,7 @@ module ActionController
481
488
  #
482
489
  # Returns String.
483
490
  def encode_credentials(token, options = {})
484
- values = ["token=#{token.to_s.inspect}"] + options.map do |key, value|
491
+ values = ["#{TOKEN_KEY}#{token.to_s.inspect}"] + options.map do |key, value|
485
492
  "#{key}=#{value.to_s.inspect}"
486
493
  end
487
494
  "Token #{values * ", "}"
@@ -21,7 +21,7 @@ module ActionController
21
21
  :action => self.action_name,
22
22
  :params => request.filtered_parameters,
23
23
  :format => request.format.try(:ref),
24
- :method => request.method,
24
+ :method => request.request_method,
25
25
  :path => (request.fullpath rescue "unknown")
26
26
  }
27
27
 
@@ -102,7 +102,7 @@ module ActionController
102
102
  end
103
103
  end
104
104
 
105
- message = json.gsub("\n", "\ndata: ")
105
+ message = json.gsub(/\n/, "\ndata: ")
106
106
  @stream.write "data: #{message}\n\n"
107
107
  end
108
108
  end
@@ -135,18 +135,6 @@ module ActionController #:nodoc:
135
135
  #
136
136
  # render json: @people
137
137
  #
138
- # Since this is a common pattern, you can use the class method respond_to
139
- # with the respond_with method to have the same results:
140
- #
141
- # class PeopleController < ApplicationController
142
- # respond_to :html, :xml, :json
143
- #
144
- # def index
145
- # @people = Person.all
146
- # respond_with(@people)
147
- # end
148
- # end
149
- #
150
138
  # Formats can have different variants.
151
139
  #
152
140
  # The request variant is a specialization of the request format, like <tt>:tablet</tt>,
@@ -214,8 +202,8 @@ module ActionController #:nodoc:
214
202
  # format.html.phone # this gets rendered
215
203
  # end
216
204
  #
217
- # Be sure to check the documentation of +respond_with+ and
218
- # <tt>ActionController::MimeResponds.respond_to</tt> for more examples.
205
+ # Be sure to check the documentation of <tt>ActionController::MimeResponds.respond_to</tt>
206
+ # for more examples.
219
207
  def respond_to(*mimes)
220
208
  raise ArgumentError, "respond_to takes either types or a block, never both" if mimes.any? && block_given?
221
209
 
@@ -234,8 +222,8 @@ module ActionController #:nodoc:
234
222
  # A container for responses available from the current controller for
235
223
  # requests for different mime-types sent to a particular action.
236
224
  #
237
- # The public controller methods +respond_with+ and +respond_to+ may be called
238
- # with a block that is used to define responses to different mime-types, e.g.
225
+ # The public controller methods +respond_to+ may be called with a block
226
+ # that is used to define responses to different mime-types, e.g.
239
227
  # for +respond_to+ :
240
228
  #
241
229
  # respond_to do |format|
@@ -86,8 +86,7 @@ module ActionController
86
86
  # end
87
87
  # end
88
88
  # To use renderers and their mime types in more concise ways, see
89
- # <tt>ActionController::MimeResponds::ClassMethods.respond_to</tt> and
90
- # <tt>ActionController::MimeResponds#respond_with</tt>
89
+ # <tt>ActionController::MimeResponds::ClassMethods.respond_to</tt>
91
90
  def self.add(key, &block)
92
91
  define_method(_render_with_renderer_method_name(key), &block)
93
92
  RENDERERS << key.to_sym
@@ -2,6 +2,7 @@ require 'rack/session/abstract/id'
2
2
  require 'active_support/core_ext/object/to_query'
3
3
  require 'active_support/core_ext/module/anonymous'
4
4
  require 'active_support/core_ext/hash/keys'
5
+ require 'active_support/deprecation'
5
6
 
6
7
  require 'rails-dom-testing'
7
8
 
@@ -689,7 +690,7 @@ module ActionController
689
690
  private
690
691
 
691
692
  def document_root_element
692
- html_document
693
+ html_document.root
693
694
  end
694
695
 
695
696
  def check_required_ivars
@@ -710,7 +711,28 @@ module ActionController
710
711
  :relative_url_root => nil,
711
712
  :_recall => @request.path_parameters)
712
713
 
713
- url, query_string = @routes.path_for(options).split("?", 2)
714
+ if route_name = options.delete(:use_route)
715
+ ActiveSupport::Deprecation.warn <<-MSG.squish
716
+ Passing the `use_route` option in functional tests are deprecated.
717
+ Support for this option in the `process` method (and the related
718
+ `get`, `head`, `post`, `patch`, `put` and `delete` helpers) will
719
+ be removed in the next version without replacement.
720
+
721
+ Functional tests are essentially unit tests for controllers and
722
+ they should not require knowledge to how the application's routes
723
+ are configured. Instead, you should explicitly pass the appropiate
724
+ params to the `process` method.
725
+
726
+ Previously the engines guide also contained an incorrect example
727
+ that recommended using this option to test an engine's controllers
728
+ within the dummy application. That recommendation was incorrect
729
+ and has since been corrected. Instead, you should override the
730
+ `@routes` variable in the test case with `Foo::Engine.routes`. See
731
+ the updated engines guide for details.
732
+ MSG
733
+ end
734
+
735
+ url, query_string = @routes.path_for(options, route_name).split("?", 2)
714
736
 
715
737
  @request.env["SCRIPT_NAME"] = @controller.config.relative_url_root
716
738
  @request.env["PATH_INFO"] = url
@@ -68,7 +68,9 @@ module ActionDispatch
68
68
  end
69
69
 
70
70
  def add_anchor(path, anchor)
71
- path << "##{Journey::Router::Utils.escape_fragment(anchor.to_param.to_s)}"
71
+ if anchor
72
+ path << "##{Journey::Router::Utils.escape_fragment(anchor.to_param)}"
73
+ end
72
74
  end
73
75
 
74
76
  def extract_domain_from(host, tld_length)
@@ -1,4 +1,5 @@
1
1
  require 'action_controller/metal/exceptions'
2
+ require 'active_support/deprecation'
2
3
 
3
4
  module ActionDispatch
4
5
  module Journey
@@ -80,6 +81,9 @@ module ActionDispatch
80
81
  if named_routes.key?(name)
81
82
  yield named_routes[name]
82
83
  else
84
+ # Make sure we don't show the deprecation warning more than once
85
+ warned = false
86
+
83
87
  routes = non_recursive(cache, options)
84
88
 
85
89
  hash = routes.group_by { |_, r| r.score(options) }
@@ -88,6 +92,17 @@ module ActionDispatch
88
92
  break if score < 0
89
93
 
90
94
  hash[score].sort_by { |i, _| i }.each do |_, route|
95
+ if name && !warned
96
+ ActiveSupport::Deprecation.warn <<-MSG.squish
97
+ You are trying to generate the URL for a named route called
98
+ #{name.inspect} but no such route was found. In the future,
99
+ this will result in an `ActionController::UrlGenerationError`
100
+ exception.
101
+ MSG
102
+
103
+ warned = true
104
+ end
105
+
91
106
  yield route
92
107
  end
93
108
  end
@@ -16,10 +16,6 @@ h2 {
16
16
  font-size: 0.5em;
17
17
  }
18
18
 
19
- div#chart-2 {
20
- height: 350px;
21
- }
22
-
23
19
  .clearfix {display: inline-block; }
24
20
  .input { overflow: show;}
25
21
  .instruction { color: #666; padding: 0 30px 20px; font-size: 0.9em}
@@ -1,6 +1,6 @@
1
1
 
2
2
  module ActionDispatch
3
- # Provide callbacks to be executed before and after the request dispatch.
3
+ # Provides callbacks to be executed before and after dispatching the request.
4
4
  class Callbacks
5
5
  include ActiveSupport::Callbacks
6
6
 
@@ -71,11 +71,13 @@ module ActionDispatch
71
71
  # restrict to the domain level. If you use a schema like www.example.com
72
72
  # and want to share session with user.example.com set <tt>:domain</tt>
73
73
  # to <tt>:all</tt>. Make sure to specify the <tt>:domain</tt> option with
74
- # <tt>:all</tt> again when deleting cookies.
74
+ # <tt>:all</tt> or <tt>Array</tt> again when deleting cookies.
75
75
  #
76
76
  # domain: nil # Does not sets cookie domain. (default)
77
77
  # domain: :all # Allow the cookie for the top most level
78
78
  # # domain and subdomains.
79
+ # domain: %w(.example.com .example.org) # Allow the cookie
80
+ # # for concrete domain names.
79
81
  #
80
82
  # * <tt>:expires</tt> - The time at which this cookie expires, as a \Time object.
81
83
  # * <tt>:secure</tt> - Whether this cookie is only transmitted to HTTPS servers.
@@ -120,7 +122,7 @@ module ActionDispatch
120
122
  # the cookie again. This is useful for creating cookies with values that the user is not supposed to change. If a signed
121
123
  # cookie was tampered with by the user (or a 3rd party), nil will be returned.
122
124
  #
123
- # If +secrets.secret_key_base+ and +config.secret_token+ (deprecated) are both set,
125
+ # If +secrets.secret_key_base+ and +secrets.secret_token+ (deprecated) are both set,
124
126
  # legacy cookies signed with the old key generator will be transparently upgraded.
125
127
  #
126
128
  # This jar requires that you set a suitable secret for the verification on your app's +secrets.secret_key_base+.
@@ -143,7 +145,7 @@ module ActionDispatch
143
145
  # Returns a jar that'll automatically encrypt cookie values before sending them to the client and will decrypt them for read.
144
146
  # If the cookie was tampered with by the user (or a 3rd party), nil will be returned.
145
147
  #
146
- # If +secrets.secret_key_base+ and +config.secret_token+ (deprecated) are both set,
148
+ # If +secrets.secret_key_base+ and +secrets.secret_token+ (deprecated) are both set,
147
149
  # legacy cookies signed with the old key generator will be transparently upgraded.
148
150
  #
149
151
  # This jar requires that you set a suitable secret for the verification on your app's +secrets.secret_key_base+.
@@ -479,7 +481,7 @@ module ActionDispatch
479
481
  end
480
482
 
481
483
  # UpgradeLegacySignedCookieJar is used instead of SignedCookieJar if
482
- # config.secret_token and secrets.secret_key_base are both set. It reads
484
+ # secrets.secret_token and secrets.secret_key_base are both set. It reads
483
485
  # legacy cookies signed with the old dummy key generator and re-saves
484
486
  # them using the new key generator to provide a smooth upgrade path.
485
487
  class UpgradeLegacySignedCookieJar < SignedCookieJar #:nodoc:
@@ -537,7 +539,7 @@ module ActionDispatch
537
539
  end
538
540
 
539
541
  # UpgradeLegacyEncryptedCookieJar is used by ActionDispatch::Session::CookieStore
540
- # instead of EncryptedCookieJar if config.secret_token and secrets.secret_key_base
542
+ # instead of EncryptedCookieJar if secrets.secret_token and secrets.secret_key_base
541
543
  # are both set. It reads legacy cookies signed with the old dummy key generator and
542
544
  # encrypts and re-saves them using the new key generator to provide a smooth upgrade path.
543
545
  class UpgradeLegacyEncryptedCookieJar < EncryptedCookieJar #:nodoc:
@@ -35,10 +35,10 @@ 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)
38
+ traces = wrapper.traces
39
39
 
40
40
  trace_to_show = 'Application Trace'
41
- if traces[trace_to_show].empty?
41
+ if traces[trace_to_show].empty? && wrapper.rescue_template != 'routing_error'
42
42
  trace_to_show = 'Full Trace'
43
43
  end
44
44
 
@@ -53,7 +53,7 @@ module ActionDispatch
53
53
  show_source_idx: source_to_show_id,
54
54
  trace_to_show: trace_to_show,
55
55
  routes_inspector: routes_inspector(exception),
56
- source_extract: wrapper.source_extract,
56
+ source_extracts: wrapper.source_extracts,
57
57
  line_number: wrapper.line_number,
58
58
  file: wrapper.file
59
59
  )
@@ -106,33 +106,5 @@ module ActionDispatch
106
106
  ActionDispatch::Routing::RoutesInspector.new(@routes_app.routes.routes)
107
107
  end
108
108
  end
109
-
110
- # Augment the exception traces by providing ids for all unique stack frame
111
- def traces_from_wrapper(wrapper)
112
- application_trace = wrapper.application_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
129
- end
130
- end
131
- {
132
- "Application Trace" => appplication_trace_with_ids,
133
- "Framework Trace" => framework_trace_with_ids,
134
- "Full Trace" => full_trace_with_ids
135
- }
136
- end
137
109
  end
138
110
  end
@@ -57,24 +57,52 @@ module ActionDispatch
57
57
  clean_backtrace(:all)
58
58
  end
59
59
 
60
+ def traces
61
+ appplication_trace_with_ids = []
62
+ framework_trace_with_ids = []
63
+ full_trace_with_ids = []
64
+
65
+ full_trace.each_with_index do |trace, idx|
66
+ trace_with_id = { id: idx, trace: trace }
67
+
68
+ if application_trace.include?(trace)
69
+ appplication_trace_with_ids << trace_with_id
70
+ else
71
+ framework_trace_with_ids << trace_with_id
72
+ end
73
+
74
+ full_trace_with_ids << trace_with_id
75
+ end
76
+
77
+ {
78
+ "Application Trace" => appplication_trace_with_ids,
79
+ "Framework Trace" => framework_trace_with_ids,
80
+ "Full Trace" => full_trace_with_ids
81
+ }
82
+ end
83
+
60
84
  def self.status_code_for_exception(class_name)
61
85
  Rack::Utils.status_code(@@rescue_responses[class_name])
62
86
  end
63
87
 
64
- def source_extract
65
- exception.backtrace.map do |trace|
88
+ def source_extracts
89
+ backtrace.map do |trace|
66
90
  file, line = trace.split(":")
67
91
  line_number = line.to_i
92
+
68
93
  {
69
94
  code: source_fragment(file, line_number),
70
- file: file,
71
95
  line_number: line_number
72
96
  }
73
- end if exception.backtrace
97
+ end
74
98
  end
75
99
 
76
100
  private
77
101
 
102
+ def backtrace
103
+ Array(@exception.backtrace)
104
+ end
105
+
78
106
  def original_exception(exception)
79
107
  if registered_original_exception?(exception)
80
108
  exception.original_exception
@@ -89,9 +117,9 @@ module ActionDispatch
89
117
 
90
118
  def clean_backtrace(*args)
91
119
  if backtrace_cleaner
92
- backtrace_cleaner.clean(@exception.backtrace, *args)
120
+ backtrace_cleaner.clean(backtrace, *args)
93
121
  else
94
- @exception.backtrace
122
+ backtrace
95
123
  end
96
124
  end
97
125
 
@@ -79,7 +79,7 @@ module ActionDispatch
79
79
  class FlashHash
80
80
  include Enumerable
81
81
 
82
- def self.from_session_value(value)
82
+ def self.from_session_value(value) #:nodoc:
83
83
  flash = case value
84
84
  when FlashHash # Rails 3.1, 3.2
85
85
  new(value.instance_variable_get(:@flashes), value.instance_variable_get(:@used))
@@ -91,8 +91,11 @@ module ActionDispatch
91
91
 
92
92
  flash.tap(&:sweep)
93
93
  end
94
-
95
- def to_session_value
94
+
95
+ # Builds a hash containing the discarded values and the hashes
96
+ # representing the flashes.
97
+ # If there are no values in @flashes, returns nil.
98
+ def to_session_value #:nodoc:
96
99
  return nil if empty?
97
100
  {'discard' => @discard.to_a, 'flashes' => @flashes}
98
101
  end
@@ -132,7 +135,7 @@ module ActionDispatch
132
135
  end
133
136
 
134
137
  def key?(name)
135
- @flashes.key? name
138
+ @flashes.key? name.to_s
136
139
  end
137
140
 
138
141
  def delete(key)
@@ -47,7 +47,7 @@ module ActionDispatch
47
47
  else
48
48
  false
49
49
  end
50
- rescue Exception => e # JSON or Ruby code block errors
50
+ rescue => e # JSON or Ruby code block errors
51
51
  logger(env).debug "Error occurred while parsing request parameters.\nContents:\n\n#{request.raw_post}"
52
52
 
53
53
  raise ParseError.new(e.message, e)
@@ -1,29 +1,27 @@
1
- <% if @source_extract %>
2
- <% @source_extract.each_with_index do |extract_source, index| %>
3
- <% if extract_source[:code] %>
4
- <div class="source <%="hidden" if @show_source_idx != index%>" id="frame-source-<%=index%>">
5
- <div class="info">
6
- Extracted source (around line <strong>#<%= extract_source[:line_number] %></strong>):
7
- </div>
8
- <div class="data">
9
- <table cellpadding="0" cellspacing="0" class="lines">
10
- <tr>
11
- <td>
12
- <pre class="line_numbers">
13
- <% extract_source[:code].each_key do |line_number| %>
1
+ <% @source_extracts.each_with_index do |source_extract, index| %>
2
+ <% if source_extract[:code] %>
3
+ <div class="source <%="hidden" if @show_source_idx != index%>" id="frame-source-<%=index%>">
4
+ <div class="info">
5
+ Extracted source (around line <strong>#<%= source_extract[:line_number] %></strong>):
6
+ </div>
7
+ <div class="data">
8
+ <table cellpadding="0" cellspacing="0" class="lines">
9
+ <tr>
10
+ <td>
11
+ <pre class="line_numbers">
12
+ <% source_extract[:code].each_key do |line_number| %>
14
13
  <span><%= line_number -%></span>
15
- <% end %>
16
- </pre>
17
- </td>
14
+ <% end %>
15
+ </pre>
16
+ </td>
18
17
  <td width="100%">
19
18
  <pre>
20
- <% extract_source[:code].each do |line, source| -%><div class="line<%= " active" if line == extract_source[:line_number] -%>"><%= source -%></div><% end -%>
19
+ <% source_extract[:code].each do |line, source| -%><div class="line<%= " active" if line == source_extract[:line_number] -%>"><%= source -%></div><% end -%>
21
20
  </pre>
22
21
  </td>
23
- </tr>
24
- </table>
25
- </div>
22
+ </tr>
23
+ </table>
26
24
  </div>
27
- <% end %>
25
+ </div>
28
26
  <% end %>
29
27
  <% end %>
@@ -4,4 +4,8 @@
4
4
 
5
5
  <div id="container">
6
6
  <h2><%= h @exception.message %></h2>
7
+
8
+ <%= render template: "rescues/_source" %>
9
+ <%= render template: "rescues/_trace" %>
10
+ <%= render template: "rescues/_request_and_response" %>
7
11
  </div>
@@ -27,4 +27,6 @@
27
27
 
28
28
  <%= @routes_inspector.format(ActionDispatch::Routing::HtmlTableFormatter.new(self)) %>
29
29
  <% end %>
30
+
31
+ <%= render template: "rescues/_request_and_response" %>
30
32
  </div>
@@ -1,6 +1,6 @@
1
1
  <% content_for :style do %>
2
2
  #route_table {
3
- margin: 0 auto 0;
3
+ margin: 0;
4
4
  border-collapse: collapse;
5
5
  }
6
6
 
@@ -244,12 +244,10 @@ module ActionDispatch
244
244
  def app(blocks)
245
245
  if to.respond_to?(:call)
246
246
  Constraints.new(to, blocks, false)
247
+ elsif blocks.any?
248
+ Constraints.new(dispatcher(defaults), blocks, true)
247
249
  else
248
- if blocks.any?
249
- Constraints.new(dispatcher(defaults), blocks, true)
250
- else
251
- dispatcher(defaults)
252
- end
250
+ dispatcher(defaults)
253
251
  end
254
252
  end
255
253
 
@@ -391,7 +389,7 @@ module ActionDispatch
391
389
 
392
390
  # Matches a url pattern to one or more routes.
393
391
  #
394
- # You should not use the `match` method in your router
392
+ # You should not use the +match+ method in your router
395
393
  # without specifying an HTTP method.
396
394
  #
397
395
  # If you want to expose your action to both GET and POST, use:
@@ -402,7 +400,7 @@ module ActionDispatch
402
400
  # Note that +:controller+, +:action+ and +:id+ are interpreted as url
403
401
  # query parameters and thus available through +params+ in an action.
404
402
  #
405
- # If you want to expose your action to GET, use `get` in the router:
403
+ # If you want to expose your action to GET, use +get+ in the router:
406
404
  #
407
405
  # Instead of:
408
406
  #
@@ -457,7 +455,7 @@ module ActionDispatch
457
455
  # The route's action.
458
456
  #
459
457
  # [:param]
460
- # Overrides the default resource identifier `:id` (name of the
458
+ # Overrides the default resource identifier +:id+ (name of the
461
459
  # dynamic segment used to generate the routes).
462
460
  # You can access that segment from your controller using
463
461
  # <tt>params[<:param>]</tt>.
@@ -271,7 +271,7 @@ module ActionDispatch
271
271
  controller_options = t.url_options
272
272
  options = controller_options.merge @options
273
273
  hash = handle_positional_args(controller_options,
274
- inner_options || {},
274
+ deprecate_string_options(inner_options) || {},
275
275
  args,
276
276
  options,
277
277
  @segment_keys)
@@ -293,6 +293,22 @@ module ActionDispatch
293
293
 
294
294
  result.merge!(inner_options)
295
295
  end
296
+
297
+ DEPRECATED_STRING_OPTIONS = %w[controller action]
298
+
299
+ def deprecate_string_options(options)
300
+ options ||= {}
301
+ deprecated_string_options = options.keys & DEPRECATED_STRING_OPTIONS
302
+ if deprecated_string_options.any?
303
+ msg = "Calling URL helpers with string keys #{deprecated_string_options.join(", ")} is deprecated. Use symbols instead."
304
+ ActiveSupport::Deprecation.warn(msg)
305
+ deprecated_string_options.each do |option|
306
+ value = options.delete(option)
307
+ options[option.to_sym] = value
308
+ end
309
+ end
310
+ options
311
+ end
296
312
  end
297
313
 
298
314
  private
@@ -457,7 +473,7 @@ module ActionDispatch
457
473
  RUBY
458
474
  end
459
475
 
460
- def url_helpers(include_path_helpers = true)
476
+ def url_helpers(supports_path = true)
461
477
  routes = self
462
478
 
463
479
  Module.new do
@@ -484,7 +500,7 @@ module ActionDispatch
484
500
  # named routes...
485
501
  include url_helpers
486
502
 
487
- if include_path_helpers
503
+ if supports_path
488
504
  path_helpers = routes.named_routes.path_helpers_module
489
505
  else
490
506
  path_helpers = routes.named_routes.path_helpers_module(true)
@@ -502,6 +518,10 @@ module ActionDispatch
502
518
  # UrlFor (included in this module) add extra
503
519
  # conveniences for working with @_routes.
504
520
  define_method(:_routes) { @_routes || routes }
521
+
522
+ define_method(:_generate_paths_by_default) do
523
+ supports_path
524
+ end
505
525
  end
506
526
  end
507
527
 
@@ -729,7 +749,7 @@ module ActionDispatch
729
749
  end
730
750
 
731
751
  def find_script_name(options)
732
- options.delete(:script_name) { '' }
752
+ options.delete(:script_name) || ''
733
753
  end
734
754
 
735
755
  def path_for(options, route_name = nil) # :nodoc:
@@ -184,6 +184,12 @@ module ActionDispatch
184
184
  def _routes_context
185
185
  self
186
186
  end
187
+
188
+ private
189
+
190
+ def _generate_paths_by_default
191
+ true
192
+ end
187
193
  end
188
194
  end
189
195
  end
@@ -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::DocumentFragment.parse(@response.body)
18
+ Nokogiri::HTML::Document.parse(@response.body)
19
19
  end
20
20
  end
21
21
  end
@@ -144,12 +144,6 @@ module ActionDispatch
144
144
  old_controller, @controller = @controller, @controller.clone
145
145
  _routes = @routes
146
146
 
147
- # Unfortunately, there is currently an abstraction leak between AC::Base
148
- # and AV::Base which requires having the URL helpers in both AC and AV.
149
- # To do this safely at runtime for tests, we need to bump up the helper serial
150
- # to that the old AV subclass isn't cached.
151
- #
152
- # TODO: Make this unnecessary
153
147
  @controller.singleton_class.send(:include, _routes.url_helpers)
154
148
  @controller.view_context_class = Class.new(@controller.view_context_class) do
155
149
  include _routes.url_helpers
@@ -326,13 +326,21 @@ module ActionDispatch
326
326
  @integration_session = Integration::Session.new(app)
327
327
  end
328
328
 
329
+ def remove! # :nodoc:
330
+ @integration_session = nil
331
+ end
332
+
329
333
  %w(get post patch put head delete cookies assigns
330
334
  xml_http_request xhr get_via_redirect post_via_redirect).each do |method|
331
335
  define_method(method) do |*args|
332
336
  reset! unless integration_session
333
- reset_template_assertion
334
- # reset the html_document variable, but only for new get/post calls
335
- @html_document = nil unless method == 'cookies' || method == 'assigns'
337
+
338
+ # reset the html_document variable, except for cookies/assigns calls
339
+ unless method == 'cookies' || method == 'assigns'
340
+ @html_document = nil
341
+ reset_template_assertion
342
+ end
343
+
336
344
  integration_session.__send__(method, *args).tap do
337
345
  copy_session_variables!
338
346
  end
@@ -497,7 +505,7 @@ module ActionDispatch
497
505
  end
498
506
 
499
507
  def document_root_element
500
- html_document
508
+ html_document.root
501
509
  end
502
510
  end
503
511
  end
@@ -8,7 +8,7 @@ module ActionPack
8
8
  MAJOR = 4
9
9
  MINOR = 2
10
10
  TINY = 0
11
- PRE = "beta4"
11
+ PRE = "rc1"
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.beta4
4
+ version: 4.2.0.rc1
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-30 00:00:00.000000000 Z
11
+ date: 2014-11-28 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.beta4
19
+ version: 4.2.0.rc1
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.beta4
26
+ version: 4.2.0.rc1
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
- version: 1.6.0.beta
33
+ version: 1.6.0.beta2
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
- version: 1.6.0.beta
40
+ version: 1.6.0.beta2
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.4
84
+ version: 1.0.5
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.4
94
+ version: 1.0.5
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.beta4
101
+ version: 4.2.0.rc1
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.beta4
108
+ version: 4.2.0.rc1
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.beta4
115
+ version: 4.2.0.rc1
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.beta4
122
+ version: 4.2.0.rc1
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.1
303
+ rubygems_version: 2.2.2
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).