actionpack 5.0.1 → 5.0.2.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.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: adec2805e3c4f12afd7b77c089a935256fe447a8
4
- data.tar.gz: be1f90611b0af1bf8d080e774082fe5bd1e8089c
3
+ metadata.gz: 8304e0927987560ee3b4cf340c49a11b39cd537b
4
+ data.tar.gz: 58b073850966d686f2f34991915c5f45ea10a032
5
5
  SHA512:
6
- metadata.gz: d04129d8134b698dc545544d196cb480bca76a8b273f5d78dba8fc34d643f9d1c52a45989c7dbf0c48ca0c272ea74d4579e77278e8a49db49e3bf27bc4052280
7
- data.tar.gz: 6b33c7eda6aba889bda90ceb08c9f085a96cce9a4c5e49dd257b6f09edb8aaed9e68336e881f85f4316056e3762dcc9061bb262ba313ce99203140b120e83a32
6
+ metadata.gz: 6fb7a974f1345e7d0fe4a87405c929f6a43b2654d0f0cc9338640f838a882cb69a8c509748a04b9bc3fcd29df4c034f48a111a9aa18237e8bec70fbd5610b619
7
+ data.tar.gz: abc839fda7edc49a9f9a1c4f455ea16b3c809d3015987197f5507a6bff273055d135bf382bb403c5c6076e6264bae01ad83d78d3c270f939f32eccaad4e75f73
@@ -1,3 +1,10 @@
1
+ ## Rails 5.0.2.rc1 (February 24, 2017) ##
2
+
3
+ * Make `with_routing` test helper work when testing controllers inheriting from `ActionController::API`.
4
+
5
+ *Julia López*
6
+
7
+
1
8
  ## Rails 5.0.1 (December 21, 2016) ##
2
9
 
3
10
  * Restored correct `charset` behavior on `send_data` and `send_file`: while
@@ -26,7 +33,7 @@
26
33
  * Fixed error caused by `force_ssl_redirect` when `session_store` is
27
34
  enabled.
28
35
 
29
- Fixes #19679
36
+ Fixes #19679.
30
37
 
31
38
  *Taishi Kasuga*
32
39
 
@@ -67,7 +67,7 @@ module ActionController
67
67
  end
68
68
 
69
69
  def _set_rendered_content_type(format)
70
- unless response.content_type
70
+ if format && !response.content_type
71
71
  self.content_type = format.to_s
72
72
  end
73
73
  end
@@ -60,8 +60,7 @@ module ActionController
60
60
  # })
61
61
  #
62
62
  # permitted = params.require(:person).permit(:name, :age)
63
- # permitted # => {"name"=>"Francesco", "age"=>22}
64
- # permitted.class # => ActionController::Parameters
63
+ # permitted # => <ActionController::Parameters {"name"=>"Francesco", "age"=>22} permitted: true>
65
64
  # permitted.permitted? # => true
66
65
  #
67
66
  # Person.first.update!(permitted)
@@ -89,7 +88,7 @@ module ActionController
89
88
  #
90
89
  # params = ActionController::Parameters.new(a: "123", b: "456")
91
90
  # params.permit(:c)
92
- # # => {}
91
+ # # => <ActionController::Parameters {} permitted: true>
93
92
  #
94
93
  # ActionController::Parameters.action_on_unpermitted_parameters = :raise
95
94
  #
@@ -257,7 +256,7 @@ module ActionController
257
256
  # either present or the singleton +false+, returns said value:
258
257
  #
259
258
  # ActionController::Parameters.new(person: { name: 'Francesco' }).require(:person)
260
- # # => {"name"=>"Francesco"}
259
+ # # => <ActionController::Parameters {"name"=>"Francesco"} permitted: false>
261
260
  #
262
261
  # Otherwise raises <tt>ActionController::ParameterMissing</tt>:
263
262
  #
@@ -278,12 +277,12 @@ module ActionController
278
277
  # returned:
279
278
  #
280
279
  # params = ActionController::Parameters.new(user: { ... }, profile: { ... })
281
- # user_params, profile_params = params.require(:user, :profile)
280
+ # user_params, profile_params = params.require([:user, :profile])
282
281
  #
283
282
  # Otherwise, the method re-raises the first exception found:
284
283
  #
285
284
  # params = ActionController::Parameters.new(user: {}, profile: {})
286
- # user_params, profile_params = params.require(:user, :profile)
285
+ # user_params, profile_params = params.require([:user, :profile])
287
286
  # # ActionController::ParameterMissing: param is missing or the value is empty: user
288
287
  #
289
288
  # Technically this method can be used to fetch terminal values:
@@ -376,13 +375,13 @@ module ActionController
376
375
  # })
377
376
  #
378
377
  # params.require(:person).permit(:contact)
379
- # # => {}
378
+ # # => <ActionController::Parameters {} permitted: true>
380
379
  #
381
380
  # params.require(:person).permit(contact: :phone)
382
- # # => {"contact"=>{"phone"=>"555-1234"}}
381
+ # # => <ActionController::Parameters {"contact"=><ActionController::Parameters {"phone"=>"555-1234"} permitted: true>} permitted: true>
383
382
  #
384
383
  # params.require(:person).permit(contact: [ :email, :phone ])
385
- # # => {"contact"=>{"email"=>"none@test.com", "phone"=>"555-1234"}}
384
+ # # => <ActionController::Parameters {"contact"=><ActionController::Parameters {"email"=>"none@test.com", "phone"=>"555-1234"} permitted: true>} permitted: true>
386
385
  def permit(*filters)
387
386
  params = self.class.new
388
387
 
@@ -404,7 +403,7 @@ module ActionController
404
403
  # returns +nil+.
405
404
  #
406
405
  # params = ActionController::Parameters.new(person: { name: 'Francesco' })
407
- # params[:person] # => {"name"=>"Francesco"}
406
+ # params[:person] # => <ActionController::Parameters {"name"=>"Francesco"} permitted: false>
408
407
  # params[:none] # => nil
409
408
  def [](key)
410
409
  convert_hashes_to_parameters(key, @parameters[key])
@@ -423,7 +422,7 @@ module ActionController
423
422
  # is given, then that will be run and its result returned.
424
423
  #
425
424
  # params = ActionController::Parameters.new(person: { name: 'Francesco' })
426
- # params.fetch(:person) # => {"name"=>"Francesco"}
425
+ # params.fetch(:person) # => <ActionController::Parameters {"name"=>"Francesco"} permitted: false>
427
426
  # params.fetch(:none) # => ActionController::ParameterMissing: param is missing or the value is empty: none
428
427
  # params.fetch(:none, 'Francesco') # => "Francesco"
429
428
  # params.fetch(:none) { 'Francesco' } # => "Francesco"
@@ -459,8 +458,8 @@ module ActionController
459
458
  # don't exist, returns an empty hash.
460
459
  #
461
460
  # params = ActionController::Parameters.new(a: 1, b: 2, c: 3)
462
- # params.slice(:a, :b) # => {"a"=>1, "b"=>2}
463
- # params.slice(:d) # => {}
461
+ # params.slice(:a, :b) # => <ActionController::Parameters {"a"=>1, "b"=>2} permitted: false>
462
+ # params.slice(:d) # => <ActionController::Parameters {} permitted: false>
464
463
  def slice(*keys)
465
464
  new_instance_with_inherited_permitted_status(@parameters.slice(*keys))
466
465
  end
@@ -476,8 +475,8 @@ module ActionController
476
475
  # filters out the given +keys+.
477
476
  #
478
477
  # params = ActionController::Parameters.new(a: 1, b: 2, c: 3)
479
- # params.except(:a, :b) # => {"c"=>3}
480
- # params.except(:d) # => {"a"=>1,"b"=>2,"c"=>3}
478
+ # params.except(:a, :b) # => <ActionController::Parameters {"c"=>3} permitted: false>
479
+ # params.except(:d) # => <ActionController::Parameters {"a"=>1, "b"=>2, "c"=>3} permitted: false>
481
480
  def except(*keys)
482
481
  new_instance_with_inherited_permitted_status(@parameters.except(*keys))
483
482
  end
@@ -485,8 +484,8 @@ module ActionController
485
484
  # Removes and returns the key/value pairs matching the given keys.
486
485
  #
487
486
  # params = ActionController::Parameters.new(a: 1, b: 2, c: 3)
488
- # params.extract!(:a, :b) # => {"a"=>1, "b"=>2}
489
- # params # => {"c"=>3}
487
+ # params.extract!(:a, :b) # => <ActionController::Parameters {"a"=>1, "b"=>2} permitted: false>
488
+ # params # => <ActionController::Parameters {"c"=>3} permitted: false>
490
489
  def extract!(*keys)
491
490
  new_instance_with_inherited_permitted_status(@parameters.extract!(*keys))
492
491
  end
@@ -496,7 +495,7 @@ module ActionController
496
495
  #
497
496
  # params = ActionController::Parameters.new(a: 1, b: 2, c: 3)
498
497
  # params.transform_values { |x| x * 2 }
499
- # # => {"a"=>2, "b"=>4, "c"=>6}
498
+ # # => <ActionController::Parameters {"a"=>2, "b"=>4, "c"=>6} permitted: false>
500
499
  def transform_values(&block)
501
500
  if block
502
501
  new_instance_with_inherited_permitted_status(
@@ -60,7 +60,8 @@ module ActionController
60
60
  end
61
61
 
62
62
  # Accepts a custom Rack environment to render templates in.
63
- # It will be merged with ActionController::Renderer.defaults
63
+ # It will be merged with the default Rack environment defined by
64
+ # +ActionController::Renderer::DEFAULTS+.
64
65
  def initialize(controller, env, defaults)
65
66
  @controller = controller
66
67
  @defaults = defaults
@@ -549,8 +549,6 @@ module ActionController
549
549
  @request = @controller.request
550
550
  @response = @controller.response
551
551
 
552
- @request.delete_header 'HTTP_COOKIE'
553
-
554
552
  if @request.have_cookie_jar?
555
553
  unless @request.cookie_jar.committed?
556
554
  @request.cookie_jar.write(@response)
@@ -570,6 +568,7 @@ module ActionController
570
568
  @request.delete_header 'HTTP_ACCEPT'
571
569
  end
572
570
  @request.query_string = ''
571
+ @request.env.delete "PATH_INFO"
573
572
 
574
573
  @response.sent!
575
574
  end
@@ -653,9 +652,10 @@ module ActionController
653
652
  end
654
653
 
655
654
  REQUEST_KWARGS = %i(params session flash method body xhr)
655
+ FORMAT_KWARGS = %i(format as)
656
656
  def kwarg_request?(args)
657
- args[0].respond_to?(:keys) && (
658
- (args[0].key?(:format) && args[0].keys.size == 1) ||
657
+ args.size == 1 && args[0].respond_to?(:keys) && (
658
+ args[0].keys.all? { |k| FORMAT_KWARGS.include?(k) } ||
659
659
  args[0].keys.any? { |k| REQUEST_KWARGS.include?(k) }
660
660
  )
661
661
  end
@@ -14,6 +14,7 @@ module ActionDispatch
14
14
 
15
15
  included do
16
16
  class << self
17
+ # Returns the parameter parsers.
17
18
  attr_reader :parameter_parsers
18
19
  end
19
20
 
@@ -21,7 +22,16 @@ module ActionDispatch
21
22
  end
22
23
 
23
24
  module ClassMethods
24
- def parameter_parsers=(parsers) # :nodoc:
25
+ # Configure the parameter parser for a give mime type.
26
+ #
27
+ # It accepts a hash where the key is the symbol of the mime type
28
+ # and the value is a proc.
29
+ #
30
+ # original_parsers = ActionDispatch::Request.parameter_parsers
31
+ # xml_parser = -> (raw_post) { Hash.from_xml(raw_post) || {} }
32
+ # new_parsers = original_parsers.merge(xml: xml_parser)
33
+ # ActionDispatch::Request.parameter_parsers = new_parsers
34
+ def parameter_parsers=(parsers)
25
35
  @parameter_parsers = parsers.transform_keys { |key| key.respond_to?(:symbol) ? key.symbol : key }
26
36
  end
27
37
  end
@@ -410,7 +410,7 @@ module ActionDispatch # :nodoc:
410
410
  def parse_content_type(content_type)
411
411
  if content_type
412
412
  type, charset = content_type.split(/;\s*charset=/)
413
- type = nil if type.empty?
413
+ type = nil if type && type.empty?
414
414
  ContentTypeHeader.new(type, charset)
415
415
  else
416
416
  NullContentTypeHeader
@@ -36,7 +36,7 @@ module ActionDispatch
36
36
 
37
37
  route.parts.reverse_each do |key|
38
38
  break if defaults[key].nil? && parameterized_parts[key].present?
39
- break if parameterized_parts[key].to_s != defaults[key].to_s
39
+ next if parameterized_parts[key].to_s != defaults[key].to_s
40
40
  break if required_parts.include?(key)
41
41
 
42
42
  parameterized_parts.delete(key)
@@ -88,7 +88,11 @@ module ActionDispatch
88
88
  else
89
89
  routes = non_recursive(cache, options)
90
90
 
91
- hash = routes.group_by { |_, r| r.score(options) }
91
+ supplied_keys = options.each_with_object({}) do |(k, v), h|
92
+ h[k.to_s] = true if v
93
+ end
94
+
95
+ hash = routes.group_by { |_, r| r.score(supplied_keys) }
92
96
 
93
97
  hash.keys.sort.reverse_each do |score|
94
98
  break if score < 0
@@ -97,13 +97,18 @@ module ActionDispatch
97
97
  required_parts + required_defaults.keys
98
98
  end
99
99
 
100
- def score(constraints)
100
+ def score(supplied_keys)
101
101
  required_keys = path.required_names
102
- supplied_keys = constraints.map { |k,v| v && k.to_s }.compact
103
102
 
104
- return -1 unless (required_keys - supplied_keys).empty?
103
+ required_keys.each do |k|
104
+ return -1 unless supplied_keys.include?(k)
105
+ end
106
+
107
+ score = 0
108
+ path.names.each do |k|
109
+ score += 1 if supplied_keys.include?(k)
110
+ end
105
111
 
106
- score = (supplied_keys & path.names).length
107
112
  score + (required_defaults.length * 2)
108
113
  end
109
114
 
@@ -517,14 +517,14 @@ module ActionDispatch
517
517
  if route.segment_keys.include?(:controller)
518
518
  ActiveSupport::Deprecation.warn(<<-MSG.squish)
519
519
  Using a dynamic :controller segment in a route is deprecated and
520
- will be removed in Rails 5.1.
520
+ will be removed in Rails 5.2.
521
521
  MSG
522
522
  end
523
523
 
524
524
  if route.segment_keys.include?(:action)
525
525
  ActiveSupport::Deprecation.warn(<<-MSG.squish)
526
526
  Using a dynamic :action segment in a route is deprecated and
527
- will be removed in Rails 5.1.
527
+ will be removed in Rails 5.2.
528
528
  MSG
529
529
  end
530
530
 
@@ -152,8 +152,11 @@ module ActionDispatch
152
152
  _routes = @routes
153
153
 
154
154
  @controller.singleton_class.include(_routes.url_helpers)
155
- @controller.view_context_class = Class.new(@controller.view_context_class) do
156
- include _routes.url_helpers
155
+
156
+ if @controller.respond_to? :view_context_class
157
+ @controller.view_context_class = Class.new(@controller.view_context_class) do
158
+ include _routes.url_helpers
159
+ end
157
160
  end
158
161
  end
159
162
  yield @routes
@@ -395,9 +395,13 @@ module ActionDispatch
395
395
 
396
396
  attr_reader :app
397
397
 
398
+ def initialize(*args, &blk)
399
+ super(*args, &blk)
400
+ @integration_session = nil
401
+ end
402
+
398
403
  def before_setup # :nodoc:
399
404
  @app = nil
400
- @integration_session = nil
401
405
  super
402
406
  end
403
407
 
@@ -7,8 +7,8 @@ module ActionPack
7
7
  module VERSION
8
8
  MAJOR = 5
9
9
  MINOR = 0
10
- TINY = 1
11
- PRE = nil
10
+ TINY = 2
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: 5.0.1
4
+ version: 5.0.2.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: 2016-12-21 00:00:00.000000000 Z
11
+ date: 2017-02-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 5.0.1
19
+ version: 5.0.2.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: 5.0.1
26
+ version: 5.0.2.rc1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rack
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -92,28 +92,28 @@ dependencies:
92
92
  requirements:
93
93
  - - '='
94
94
  - !ruby/object:Gem::Version
95
- version: 5.0.1
95
+ version: 5.0.2.rc1
96
96
  type: :runtime
97
97
  prerelease: false
98
98
  version_requirements: !ruby/object:Gem::Requirement
99
99
  requirements:
100
100
  - - '='
101
101
  - !ruby/object:Gem::Version
102
- version: 5.0.1
102
+ version: 5.0.2.rc1
103
103
  - !ruby/object:Gem::Dependency
104
104
  name: activemodel
105
105
  requirement: !ruby/object:Gem::Requirement
106
106
  requirements:
107
107
  - - '='
108
108
  - !ruby/object:Gem::Version
109
- version: 5.0.1
109
+ version: 5.0.2.rc1
110
110
  type: :development
111
111
  prerelease: false
112
112
  version_requirements: !ruby/object:Gem::Requirement
113
113
  requirements:
114
114
  - - '='
115
115
  - !ruby/object:Gem::Version
116
- version: 5.0.1
116
+ version: 5.0.2.rc1
117
117
  description: Web apps on Rails. Simple, battle-tested conventions for building and
118
118
  testing MVC web applications. Works with any Rack-compatible server.
119
119
  email: david@loudthinking.com
@@ -292,15 +292,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
292
292
  version: 2.2.2
293
293
  required_rubygems_version: !ruby/object:Gem::Requirement
294
294
  requirements:
295
- - - ">="
295
+ - - ">"
296
296
  - !ruby/object:Gem::Version
297
- version: '0'
297
+ version: 1.3.1
298
298
  requirements:
299
299
  - none
300
300
  rubyforge_project:
301
- rubygems_version: 2.5.2
301
+ rubygems_version: 2.6.10
302
302
  signing_key:
303
303
  specification_version: 4
304
304
  summary: Web-flow and rendering framework putting the VC in MVC (part of Rails).
305
305
  test_files: []
306
- has_rdoc: